n = int(input())
x = [[None for _ in range(n + 2)] for _ in range(2)]
y = [[None for _ in range(n + 2)] for _ in range(2)]
for j in range(2):
xy = list(map(int, input().split()))
for i in range(1, n + 1):
x[j][i], y[j][i] = xy[2*i-2], xy[2*i-1]
x[j][0] = x[j][n]
y[j][0] = y[j][n]
x[j][n + 1] = x[j][1]
y[j][n + 1] = y[j][1]
a = [None for _ in range(3 * n + 2)]
for j in range(2):
for i in range(1, n + 1):
idx = i + (n + 1 if j == 0 else 0)
a[idx] = ((x[j][i] - x[j][i - 1])**2 + (y[j][i] - y[j][i - 1])**2, (x[j][i] - x[j][i + 1])**2 + (y[j][i] - y[j][i + 1])**2,
(x[j][i] - x[j][i - 1])*(x[j][i + 1] - x[j][i]) + (y[j][i] - y[j][i - 1])*(y[j][i + 1] - y[j][i]),
(x[j][i] - x[j][i - 1])*(y[j][i + 1] - y[j][i]) - (y[j][i] - y[j][i - 1])*(x[j][i + 1] - x[j][i]))
if j == 0:
a[i + 2 * n + 1] = a[i + n + 1]
a[n + 1] = (-1, -1, 0, 0)
pi = [0 for _ in range(3 * n + 2)]
for i in range(2, 3 * n + 2):
k = i - 1
while k > 1 and a[i] != a[pi[k]+1]:
k = pi[k]
if a[i] == a[pi[k]+1]:
pi[i] = pi[k] + 1
else:
pi[i] = 0
if pi[i] == n:
print(i-2*n)
break