n=int(input())
coordlist=[]
for i in range(n):
    m=input()
    ml=m.split(',')
    l=[]
    l.append(int(ml[0]))
    l.append(int(ml[1]))
    coordlist.append(l)
count=0
for i in range(len(coordlist)-1):
    x=abs(coordlist[i][0]-coordlist[i+1][0])
    y=abs(coordlist[i][1]-coordlist[i+1][1])
    #print(max(x,y))
    count=count+max(y,x)
print(count)
ded85cce3ae0e5ea96713040fd4dc077cb79ef2f
<mask token>

<mask token>
for i in range(n):
    m = input()
    ml = m.split(',')
    l = []
    l.append(int(ml[0]))
    l.append(int(ml[1]))
    coordlist.append(l)
<mask token>
for i in range(len(coordlist) - 1):
    x = abs(coordlist[i][0] - coordlist[i + 1][0])
    y = abs(coordlist[i][1] - coordlist[i + 1][1])
    count = count + max(y, x)
print(count)

n = int(input())
coordlist = []
for i in range(n):
    m = input()
    ml = m.split(',')
    l = []
    l.append(int(ml[0]))
    l.append(int(ml[1]))
    coordlist.append(l)
count = 0
for i in range(len(coordlist) - 1):
    x = abs(coordlist[i][0] - coordlist[i + 1][0])
    y = abs(coordlist[i][1] - coordlist[i + 1][1])
    count = count + max(y, x)
print(count)

n=int(input())
coordlist=[]
for i in range(n):
    m=input()
    ml=m.split(',')
    l=[]
    l.append(int(ml[0]))
    l.append(int(ml[1]))
    coordlist.append(l)
count=0
for i in range(len(coordlist)-1):
    x=abs(coordlist[i][0]-coordlist[i+1][0])
    y=abs(coordlist[i][1]-coordlist[i+1][1])
    #print(max(x,y))
    count=count+max(y,x)
print(count)