Harryxun/stf_run huggingface dataset:
def solve(s):
    l, r = 0, len(s) - 1

    ans = 0
    while l != r:
        if s[l] != s[r] and s[l] != 'x' and s[r] != 'x':
            return -1
        if s[l] == s[r]:
            l += 1
            r -= 1
        elif s[l] == 'x':
            ans += 1
            l += 1
        elif s[r] == 'x':
            ans += 1
            r -= 1
    return ans


if __name__ == '__main__':
    print(solve(input()))

### FIXED CODE ###

def solve(s):
    l, r = 0, len(s) - 1

    ans = 0
    while l < r:
        if s[l] != s[r] and s[l] != 'x' and s[r] != 'x':
            return -1
        if s[l] == s[r]:
            l += 1
            r -= 1
        elif s[l] == 'x':
            ans += 1
            l += 1
        elif s[r] == 'x':
            ans += 1
            r -= 1
    return ans


if __name__ == '__main__':
    print(solve(input()))
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
Nl =[]
for i in range(N):
    Nl.append(i+1)

P_answer = 0
Q_answer = 0
for i, permu in enumerate(itertools.permutations(Nl)):
    if list(permu) == P:
        P_answer = i+1
    if list(permu) == Q:
        Q_answer = i+1

print(abs(P_answer-Q_answer))

### FIXED CODE ###

import itertools
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
Nl =[]
for i in range(N):
    Nl.append(i+1)

P_answer = 0
Q_answer = 0
for i, permu in enumerate(itertools.permutations(Nl)):
    if list(permu) == P:
        P_answer = i+1
    if list(permu) == Q:
        Q_answer = i+1

print(abs(P_answer-Q_answer))
S = input()
N = len(S)
a = 0
ans = 0
for i in range(N):
    if S[i] == 'A':
        a += 1
    elif S[i] == 'B':
        if S[i+1] == 'C':
            ans += a
        else:
            a = 0
    else:
        a = 0
print(ans)

### FIXED CODE ###

S = input()
N = len(S)
a = 0
ans = 0
f = 0
for i in range(N-1):
    if S[i] == 'A':
        a += 1
    elif S[i] == 'B':
        if S[i+1] == 'C':
            ans += a
            f = 1
        else:
            a = 0
    else:
        if f != 1:
            a = 0
        else:
            f = 0
print(ans)
a = input()
b = a.split(" ")
for i in len(b):
  if b[i] == "0":
    print(i+1)
    break


### FIXED CODE ###

a = input()
b = a.split(" ")
for i in range(len(b)):
    if b[i] == "0":
        print(i + 1)
        break
if __name__ == "__main__":


    def isDivBy9(n): 
        if (n == 0 or n == 9): 
            return True
        if (n < 9): 
            return False
    
        # If n is greater than 9, 
        # then recur for [floor(n / 9) - n % 8] 
        return isDivBy9((int)(n>>3) - (int)(n&7)) 

    N = int(input())
    
    if(isDivBy9(N)):
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

def check(st) : 
  
    # Compute sum of digits 
    n = len(st) 
    digitSum = 0
      
    for i in range(0,n) : 
        digitSum = digitSum + (int)(st[i]) 
  
    # Check if sum of digits 
    # is divisible by 9. 
    return (digitSum % 9 == 0) 
  
# Driver code 
x = input()
st= str(x)
  
if(check(st)) : 
    print("Yes") 
else :  
    print("No")
from scipy.spatial import distance

N, D = map(int, input().split())
xy = [list(map(int, input().split())) for xy in range(N)]
o = [0, 0]
count = 0

for i in range(N):
    if distance.euclidean(xy[i], o) <= D:
        count += 1
    else:
        pass

print(count)


### FIXED CODE ###

import numpy as np

N, D = map(int, input().split())
xy = np.array([list(map(int, input().split())) for xy in range(N)])
o = np.array([0, 0])
count = 0

for i in range(N):
    if np.linalg.norm(xy[i] - o) <= D:
        count += 1
    else:
        pass

print(count)
import math
N = int(input())
if N % 2 == 1:
    print(0)
else:
    div10 = N // 10
    sum_val = div10
    count_5 = math.floor(math.log(div10, 5))
    for i in range(count_5):
        sum_val += div10 // pow(5, i + 1)
    print(sum_val)


### FIXED CODE ###

import math
N = int(input())
if N % 2 == 1:
    print(0)
else:
    div10 = N // 10
    sum_val = div10
    if sum_val > 0:
        count_5 = math.floor(math.log(div10, 5))
        for i in range(count_5):
            sum_val += div10 // pow(5, i + 1)
    print(sum_val)
m = int(input())
c = m[0]+m[1]+m[2]
print(c)


### FIXED CODE ###

try:
  s = str(input())
  c = 0

  if s[0]=='1':
    c += 1
  if s[1]=='1':
    c += 1
  if s[2]=='1':
    c += 1
  print(c)
except:EOFError
import sys
import numpy as np
input = sys.stdin.readline
N, M = [int(x) for x in input().split()]
I = []
for _ in range(M):
    I.append([int(x) for x in input().split()])
s_1 = {}
s_N = {}
for i in I:
    if i[0] == 1 and i[1] == N:
        print("POSSIBLE")
        sys.exit()
    if i[0] == 1:
        if i[1] in s_N:
            print("POSSIBLE")
            sys.exit()
        s_1.add(i[1])
    if i[1] == N:
        if i[0] in s_1:
            print("POSSIBLE")
            sys.exit()
        s_N.add(i[0])
for j in s_1:
    if j in s_N:
        print("POSSIBLE")
        sys.exit()
print("IMPOSSIBLE")
    



### FIXED CODE ###

import sys
import numpy as np
input = sys.stdin.readline
N, M = [int(x) for x in input().split()]
I = []
for _ in range(M):
    I.append([int(x) for x in input().split()])
s_1 = set()
s_N = set()
for i in I:
    if i[0] == 1 and i[1] == N:
        print("POSSIBLE")
        sys.exit()
    if i[0] == 1:
        if i[1] in s_N:
            print("POSSIBLE")
            sys.exit()
        s_1.add(i[1])
    if i[1] == N:
        if i[0] in s_1:
            print("POSSIBLE")
            sys.exit()
        s_N.add(i[0])
for j in s_1:
    if j in s_N:
        print("POSSIBLE")
        sys.exit()
print("IMPOSSIBLE")
n = int(input())
s = []
for i in range(n):
    s += [int(input())]
a = sum(s)
if a % 10 != 0:
    print(a)
    exit()
else:
    for i in range(n):
        if s[i] % 10 != 0:
            a -= s[i]
        if a % 10 != 0:
            print(a)
            f = 0
            exit()
        else:
            f = 1
if f:
    print(0)

### FIXED CODE ###

a,b = map(int,input().split())
s=a+b
if s >= 10:
  print('error')
else:
  print(s)
import sys,queue,copy
sys.setrecursionlimit(10**8)
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
INF = float('inf')


N = int(input())
S = input()

ans = 0
i = 0
while i < N:
    if S[i] == "A":
        i += 1
        if S[i] == "B":
            i += 1
            if S[i] == "C":
                ans += 1
                i+=1
            else:
                continue
        else:
            continue
    else:
        i += 1
        continue


print(ans)




### FIXED CODE ###

import sys,queue,copy
sys.setrecursionlimit(10**8)
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
INF = float('inf')


N = int(input())
S = input()

ans = 0
i = 0
while i < N:
    if S[i] == "A":
        if i +1 < N:
            i += 1
            if S[i] == "B":
                if i + 1 < N:
                    i += 1
                    if S[i] == "C":
                        ans += 1
                        if i + 1 < N:
                            i+=1
                        else:
                            break
                    else:
                        continue
                else:
                    break
            else:
                continue
        else:
            break
    else:
        i += 1
        continue


print(ans)
import sys

INF = 10 ** 18
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())

N = II()
A_li = LI()
N = len(A_li)

def dp(i,j):
    if i == 0:
        if j == 0: return 0
        elif j == 1: return -INF
    else:
        if j == 0: return max(dp(i-1,0) + A_li[i-1], dp(i-1,1) - A_li[i-1])
        if j == 1: return max(dp(i-1,0) - A_li[i-1], dp(i-1,1) + A_li[i-1])

print(dp(N,0))


### FIXED CODE ###

import sys

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())

N = II()
A_li = LI()

import numpy as np

A_abs = np.abs(A_li)
A_neg_count = sum([1 if i<0 else 0 for i in A_li])

if 0 in A_li or A_neg_count%2 == 0: print(sum(A_abs))
else: print(sum(A_abs) - 2 * min(A_abs))
import math
import collections

n = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

if n == 1:
    print(0)
else:
    c = collections.Counter(prime_factorize(n))

res = 0
for x, y in c.items():
    num = int( (-1 + (1 +8*y)**(0.5))/2 )
    res += num

print(res)


### FIXED CODE ###

import math
import collections

n = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

if n == 1:
    print(0)
    exit()
else:
    c = collections.Counter(prime_factorize(n))

res = 0
for x, y in c.items():
    num = int( (-1 + (1 +8*y)**(0.5))/2 )
    res += num

print(res)
if len(set(input()))==2:
  print('Yes')
else
  print('No')


### FIXED CODE ###

S = input()

if len(set(S)) == 2:
  print('Yes')
else:
  print('No')
import sys
input = sys.stdin.readline
import numpy as np

N, K = [int(item) for item in input().split()]
h =np.array([int(item) for item in input().split()])

dp = np.full(N+1, 10**5)
dp[1] = abs(h[1] - h[0])

for i in range(1,N):
    start = max(0, i-K)
    cost = np.abs(h[start:i] - h[i])
    dp[i] =min(np.minimum(dp[start:i] + cost, dp[i]))
    # print(start, i)
    # print(dp)
print(dp[N-K-1])


### FIXED CODE ###

import numpy as np

N, K = [int(item) for item in input().split()]
h =np.array([int(item) for item in input().split()])
# print(h.shape)
dp = np.full(N+K, 10**10+1, dtype='int64')
dp[0] = 0

for i in range(1, N):
    max1 = min(N, i+K)
    cost = abs(h[i:max1] - h[i-1])
    # print(cost.shape, dp[i:max1].shape)
    dp[i:max1] = np.minimum(dp[i:max1], dp[i-1] + cost)

    # print(dp)
print(dp[N-1])
S, W = map(int, input.split())

print('unsafe' if W>=S else 'safe')

### FIXED CODE ###

S, W = map(int, input().split())

print('unsafe' if W>=S else 'safe')
n = int(input())
m = n
for i in range(20):
    tmp = 0
    for j in range(1, i):
        tmp += 26 ** j
    if 26 ** (i - 2) < n <= tmp:
        digit = i - 1
        break
ans = ""
"""
for i in range(digit)[::-1]:
    ans += chr(96 + n // (26 ** i))
    print(n // (26 ** i))
    n = n % (26 ** i)
print(ans)
"""
for i in range(digit)[::-1]:
    m = n // 26 ** i
    if m == 27:
        n -= (m - 1) * 26 ** i
        ans += chr(96 + (m - 1))
    else:
        n -= m * 26 ** i
        ans += chr(96 + m)

print(ans)

### FIXED CODE ###

N = int(input())
ans = ''
for i in range(1, 99):
    if N <= 26 ** i:
        N -= 1
        for j in range(i):
            ans += chr(ord('a') + N % 26)
            N //= 26
        break
    else:
        N -= 26 ** i

print(ans[::-1])
n = int(input())
li = list(map(int,input().split()))

dp = [[-1 for i in range(1100)] for j in range(1100)]
ans = [100000]*n
ans[0] = 0
def solve(a,b,dp,li):
    # print(f"{a,b}")
    if dp[a][b] !=-1 :
        # print(f"結果{dp[a][b]}")
        return dp[a][b]
    else:
        dp[a][b] = abs(li[a]-li[b])
        # print(f"結果{a,b,dp[a][b]}")
        return dp[a][b]

for i in range(2,n+1):
    # print(i)
    if i == 2:
        dp[1][0] = abs(li[1]-li[0])
        ans[i-1] = dp[1][0]
    else:
        # print(solve(i-1,i-2,dp,li)+ans[i-2],solve(i-1,i-3,dp,li)+ans[i-3])
        # print(solve(i-1,i-2,dp,li),solve(i-1,i-3,dp,li))
        # print(ans[i-2],ans[i-3])
        # print(li[i-1],li[i-3])
        ans[i-1] = min(solve(i-1,i-2,dp,li)+ans[i-2],solve(i-1,i-3,dp,li)+ans[i-3])

print(ans[-1])
# print(dp)

### FIXED CODE ###


n = int(input())
li = list(map(int,input().split()))

# dp = [[-1 for i in range(1100)] for j in range(1100)]
ans = [0]*n
ans[0] = 0
# def solve(a,b,dp,li):
#     if dp[a][b] !=-1 :
#         return dp[a][b]
#     else:
#         dp[a][b] = abs(li[a]-li[b])
#         return dp[a][b]

for i in range(2,n+1):
    if i == 2:
        ans[i-1]= abs(li[1]-li[0])
    else:
        ans[i-1] = min(abs(li[i-1]-li[i-2])+ans[i-2],abs(li[i-1]-li[i-3])+ans[i-3])

print(ans[-1])
N = int(input())
numbers = list(map(int,input().split()))
numOfOperation = int(input())
dic = {}

for num in numbers:
    if num in dic : dic[num] += 1
    else: dic[num] = 1
    

sums = sum(numbers)
for i in range(numOfOperation):
    B,C = map(int,input().split())
    cnt = dic[B]
    dic[B] = 0
    dic[C] += cnt
    sums += cnt * (C - B)
    print(sums)


### FIXED CODE ###

N = int(input())
numbers = list(map(int,input().split()))
numOfOperation = int(input())
dic = {}

for num in numbers:
    if num in dic : dic[num] += 1
    else: dic[num] = 1
    

sums = sum(numbers)
for i in range(numOfOperation):
    B,C = map(int,input().split())
    if (B in dic) : 
        cnt = dic[B]
        dic[B] = 0
        if (C not in dic) : dic[C] = cnt
        else : dic[C] += cnt
        sums += cnt * (C - B)
    print(sums)
n, x = map(int, input().split())
c = list(map(int, input().split()))
c = set([abs(x-c[i]) for i in range(n)])
l = min(c)
for i in range(l, 0, -1):
    d = True
    for item in c:
        if item % i != 0:
            d = False
    if d:
        print(i)
        break

### FIXED CODE ###

a, b = map(int, input().split())
if (a*b)%2 == 0:
    print("No")
else:
    print("Yes")
A,B,N=map(int,input().split())
import numpy as np
print(max([int(A*x/B)-A*int(x/B) for x in np.arange(0,N+1,max((B/A),1))])

### FIXED CODE ###

k=int(input())
a,b=map(int,input().split())

for i in range(a,b+1):
  if i%k==0:
    print('OK')
    break
  if i==b:
    print('NG')
n=int(input())
count=0
maxlen=[]
xlist=list(map(int,input().split()))
for i in range(n-1):
    if xlist[i]>=xlist[i+1]:
        count+=1
    else:
        maxlen.append(count)
        count=0
print(max(max(maxlen),count))








### FIXED CODE ###

n=int(input())
count=0
maxlen=[]
xlist=list(map(int,input().split()))
if n==1:
    print(0)
elif n==2:
    if xlist[0]>=xlist[1]:
        print(1)
    else:
        print(0)
else:
    for i in range(n - 1):
        if xlist[i] >= xlist[i + 1]:
            count += 1
            if i==n-2:
                maxlen.append(count)
        else:
            maxlen.append(count)
            count = 0
    print(max(maxlen))
import sys
input = sys.stdin.readline

N,M=map(int,input().split())
R=[tuple(map(int,input().split())) for i in range(M)]

E=[set() for i in range(N)]

for x,y in R:
    E[x-1].add(y-1)

DP=[1<<60]*N
DP[N-1]=0

for i in range(N-2,-1,-1):
    score=0
    for x in E[i]:
        score+=1+DP[x]

    DP[i]=score/len(E[i])
        
ANS=DP[0]

for i in range(N-2):
    rem=-1
    remsc=0
    for j in E[i]:
        if DP[j]>remsc:
            rem=j
            remsc=DP[j]

    E[i].remove(rem)

    NDP=[1<<60]*N
    NDP[N-1]=0

    for l in range(N-2,-1,-1):
        
        score=0
        
        if len(E[l])==0:
            continue
        
        for x in E[l]:
            score+=1+NDP[x]

        NDP[l]=score/len(E[l])

    #print(i,rem,E,NDP)

    ANS=min(ANS,NDP[0])
    E[i].add(rem)

print(ANS)

### FIXED CODE ###

import sys
input = sys.stdin.readline

N,M=map(int,input().split())
R=[tuple(map(int,input().split())) for i in range(M)]

E=[set() for i in range(N)]

for x,y in R:
    E[x-1].add(y-1)

DP=[M]*N
DP[N-1]=0

for i in range(N-2,-1,-1):
    score=0
    for x in E[i]:
        score+=1+DP[x]

    DP[i]=score/len(E[i])
        
ANS=DP[0]

for i in range(N-2):
    rem=-1
    remsc=0
    for j in E[i]:
        if DP[j]>remsc:
            rem=j
            remsc=DP[j]

    if remsc==0:
        continue

    E[i].remove(rem)

    NDP=[M]*N
    NDP[N-1]=0

    for l in range(N-2,-1,-1):
        
        score=0
        
        if len(E[l])==0:
            continue
        
        for x in E[l]:
            score+=1+NDP[x]

        NDP[l]=score/len(E[l])

    #print(i,rem,E,NDP)

    ANS=min(ANS,NDP[0])
    E[i].add(rem)

print(ANS)
import sys
dic={"A":["11","11"],"B":["1","1","1","1"],"C":["1111"],"D":["01","11","10"],
		"E":["110","011"],"F":["10","11","01"],"G":["011","110"]}
s=[]
linecnt=0
for line in sys.stdin:
	if line=="\n" or line=="":
		continue
	linecnt+=1
	if linecnt<8:
		s.append(line.rstrip("\n"))
	else:
		while s[0]=="00000000":
			del(s[0])
		while s[len(s)-1]=="00000000":
			del(s[len(s)-1])
		i=len(s[0])-1
		while i>=0:
			for l in xrange(len(s)):
				if s[l][i]=="1":
					break
			else:
				for l in xrange(len(s)):
					s[l]=s[l][0:i]+s[l][i+1:len(s[l])]
			i-=1
		for d in dic.keys():
			if dic[d]==s:
				print d
				break
		while len(s)>0:
			del(s[0])
		linecnt=0

### FIXED CODE ###

import sys
dic={"A":["11","11"],"B":["1","1","1","1"],"C":["1111"],"D":["01","11","10"],
		"E":["110","011"],"F":["10","11","01"],"G":["011","110"]}
s=[]
linecnt=0
for line in sys.stdin:
	if line=="\n" or line=="":
		continue
	linecnt+=1
	if linecnt<8:
		s.append(line.rstrip("\n"))
	else:
		s.append(line.rstrip("\n"))
		while s[0]=="00000000":
			del(s[0])
		while s[len(s)-1]=="00000000":
			del(s[len(s)-1])
		i=len(s[0])-1
		while i>=0:
			for l in xrange(len(s)):
				if s[l][i]=="1":
					break
			else:
				for l in xrange(len(s)):
					s[l]=s[l][0:i]+s[l][i+1:len(s[l])]
			i-=1
		for d in dic.keys():
			if dic[d]==s:
				print d
				break
		while len(s)>0:
			del(s[0])
		linecnt=0
N,X = (input().split())
L = list(map(int, input().split()))
x = int(X)
position = 0
count = 0
while position < x:
    position += L[count]
    count += 1
print(count)


### FIXED CODE ###

n, x = list(map(int, input().split()))
li = list(map(int, input().split()))

ans = 1
pos = 0
for i in range(n):
	pos = pos + li[i]
	if pos <= x:
		ans += 1
print(ans)
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A, B;
    cin >> A >> B;
    if (A == B) cout << "Draw" << endl;
    else if (A == 1) cout << "Alice" << endl;
    else if (B == 1) cout << "Bob" << endl;
    else if (A > B) cout << "Alice" << endl;
    else cout << "Bob" << endl;
}

### FIXED CODE ###

# A問題
a, b = map(int, input().split())
if a == 1:
    a = 14
if b == 1:
    b = 14
if a > b:
    print("Alice")
elif a == b:
    print("Draw")
else:
    print("Bob")
import sys

input = sys.stdin.readline

N, M = map(int, input().split())

sc = []
dic = dict()
for _ in range(M):
    sc.append(list(map(int, input().split())))

sc.sort(key=lambda x:x[0])

if sc[-1][0] > N:
    print(-1)
    exit()

for i in range(M):
    if sc[i][0] not in dic.keys():
        dic[sc[i][0]] = sc[i][1]
    elif dic[sc[i][0]] != sc[i][1]:
        print(-1)
        exit()

if N == 1:
    if sc[0][0] == 1 and sc[0][1] == 0:
        print(0)
        exit()
else:
    if sc[0][0] == 1 and sc[0][1] == 0:
        print(-1)
        exit()

ans = ['a'] * N

try:
    for i in range(M):
        ans[sc[i][0]-1] = sc[i][1] 
except:
    pass

if ans[0] == 'a':
    ans[0] = 1
if ans[1] == 'a':
    ans[1] = 0
if ans[2] == 'a':
    ans[2] = 0 

out = ""
for i in range(len(ans)):
    out += str(ans[i])

print(int(out))

### FIXED CODE ###

import sys

input = sys.stdin.readline

N, M = map(int, input().split())

if M == 0:
    ans = 0
    if N == 2:
        ans = 10
    if N == 3:
        ans = 100
    print(ans)
    exit()

sc = []
dic = dict()
for _ in range(M):
    sc.append(list(map(int, input().split())))

sc.sort(key=lambda x:x[1])
sc.sort(key=lambda x:x[0])

if sc[-1][0] > N:
    print(-1)
    exit()

for i in range(M):
    if sc[i][0] not in dic.keys():
        dic[sc[i][0]] = [sc[i][1]]
    elif sc[i][1] not in dic[sc[i][0]]:
        dic[sc[i][0]].append(sc[i][1])

for value in dic.values():
    if len(value) > 1:
        print(-1)
        exit()

if N == 1:
    if sc[0][0] == 1 and sc[0][1] == 0:
        print(0)
        exit()
else:
    if sc[0][0] == 1 and sc[0][1] == 0:
        print(-1)
        exit()

ans = ['a'] * N

for i in range(M):
    ans[sc[i][0]-1] = sc[i][1] 

if ans[0] == 'a':
    ans[0] = 1
for i in range(len(ans)):
    if ans[i] == 'a':
        ans[i] = 0

out = ""
for i in range(len(ans)):
    out += str(ans[i])

print(int(out))
N = input()

if N%2 == 1:
  print(int(N/2)+1)
else:
  print(N/2)

### FIXED CODE ###

N = int(input()) 
if N % 2 == 1:
    print((N//2) + 1)
else:
    print(N//2)
n,a,b = map(int,input().split())
if n==1:
  if a==b:
    print(1)
  else:
    print(0)
else:
  if b-a < 0:
    print(0)
  elif k==1:
    print(1)
  else:
    print(b*k - a*k+1)

### FIXED CODE ###

n,a,b = map(int,input().split())
if n==1:
  if a==b:
    print(1)
  else:
    print(0)
else:
  k = b-a
  if k < 0:
    print(0)
  elif k==0:
    print(1)
  else:
    print((b-a)*(n-2)+1)
import itertools
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

l = list(itertools.permutations(range(1,n+1)))

print(abs(l.index(a) - l.index(b)))





### FIXED CODE ###

import itertools
n = int(input())
a = tuple(map(int, input().split()))
b = tuple(map(int, input().split()))

l = list(itertools.permutations(range(1,n+1)))

print(abs(l.index(a) - l.index(b)))
N, T = map(int, input().split())
cage,cage2=[],[]
for n,i in enumerate(N):
  c, t = map(int, input().split())
  if t<=T:
	cage.append(c)
    cage2.append(n)
if cage==None:
  print("TLE")
else:
  print(soted(cage)[0]

### FIXED CODE ###

N, T = map(int, input().split())
cage,cage2=[],[]
for i in range(N):
  c, t = map(int, input().split())
  if t<=T:
      cage.append(c)
if len(cage)==0:
  print("TLE")
else:
  print(min(cage))
from collections import defaultdict
from collections import deque

N, K = map(int, input().split())
ab = defaultdict(list)
for i in range(N-1):
    a, b = map(int, input().split())
    ab[a-1].append(b-1)
    ab[b-1].append(a-1)

MOD = 10**9+7


def dfs(v, pv, n):
    k = K-1 if pv == -1 else K-2
    a = 1
    for u in ab[v]:
        if u != pv:
            a *= dfs(u, v, k)
            a %= MOD
            k -= 1
    return a*n % MOD


print(dfs(0, -1, K))


### FIXED CODE ###

from collections import defaultdict
from collections import deque
import sys
sys.setrecursionlimit(10**6)

N, K = map(int, input().split())
ab = defaultdict(list)
for i in range(N-1):
    a, b = map(int, input().split())
    ab[a-1].append(b-1)
    ab[b-1].append(a-1)

MOD = 10**9+7


def dfs(v, pv, n):
    k = K-1 if pv == -1 else K-2
    a = 1
    for u in ab[v]:
        if u != pv:
            a *= dfs(u, v, k)
            a %= MOD
            k -= 1
    return a*n % MOD


print(dfs(0, -1, K))
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
    
    
N = int(input())
ss = []
for i in range(N):
	ss.append("".join(sorted(list(input()))))
	
dicS = {}
for s in ss:
	if s not in dicS:
		dicS[s] = 1
	else:
		dicS[s] += 1
		
ans = 0
for v in dicS.values():
	ans += cmb(v, 2)
	
print(ans)

### FIXED CODE ###

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
    
    
N = int(input())
ss = []
for i in range(N):
	ss.append("".join(sorted(list(input()))))
	
dicS = {}
for s in ss:
	if s not in dicS:
		dicS[s] = 1
	else:
		dicS[s] += 1
		
#print(dicS)
		
ans = 0
for v in dicS.values():
	if v != 1:
		ans += cmb(v, 2)
	
print(ans)
n = (int)(input())
l_o = [v for v in range(1,n+1,2)]
l_e = [v for v in range(2,n+1,2)]
return (len(l_o)*len(l_e))

### FIXED CODE ###

n=(int)(input())
if n%2==0:
    print((n//2)**2)
else:
    print((n//2)*(n//2+1))