def calculate_total_distance_from_input(input_data):
    # Parse the input into two lists
    left_list = []
    right_list = []
    
    for line in input_data.strip().split("\n"):
        left, right = map(int, line.split())
        left_list.append(left)
        right_list.append(right)
    
    # Sort both lists
    left_sorted = sorted(left_list)
    right_sorted = sorted(right_list)
    
    # Calculate the total distance
    total_distance = 0
    for left, right in zip(left_sorted, right_sorted):
        total_distance += abs(left - right)
    
    return total_distance


# Example Input
input_data = """
76309   75213
79731   28444
29583   71339
60992   99148
34680   74530
45691   82519
55358   22047
95523   45384
37661   82208
33464   91461
26897   96393
76556   76554
82316   98880
92079   23082
55539   10033
65931   66060
98880   60464
19348   41458
72003   84074
78401   78856
53187   72003
"""

# Calculate and print the result
result = calculate_total_distance_from_input(input_data)
print("Total Distance:", result)