qyliang/CodeNanoFix huggingface dataset:
# Buggy code:
def getdata_input():
    while True:
        yield input()

it=getdata_input()
N=int(next(it))
arr=[-1]*N
arr[0],*arr[1:]=map(int,next(it).split())
n=1
out=[]
i=-1
while True:
    try:
        i=arr.index(n,i+1)
        out.append(i)
        n+=1
    except ValueError:
        if(i<N-1):
            out.append(N)
        break
if len(out) ==0: 
    print(-1)
else:
    i,j=0,0
    total=0
    for x in out:
        j=x
        total+=(j-i)
        i=j+1
        
    print(total)

# Fixed code:
def getdata_input():
    while True:
        yield input()

it=getdata_input()
N=int(next(it))
arr=[-1]*N
arr[0],*arr[1:]=map(int,next(it).split())
n=1
out=[]
i=-1
while True:
    try:
        i=arr.index(n,i+1)
        out.append(i)
        n+=1
    except ValueError:
        if i<N-1 and n>1 :
            out.append(N)
        break
if len(out) ==0: 
    print(-1)
else:
    i,j=0,0
    total=0
    for x in out:
        j=x
        total+=(j-i)
        i=j+1
        
    print(total)
# Buggy code:
n=int(input())
a=list(map(int,input().split()))
tmp=1
block=[]
for i in range(n):
    if a[i]==tmp:
        block.append(a[i])
        tmp+=1
print(n-len(block))

# Fixed code:
n=int(input())
a=list(map(int,input().split()))
tmp=1
block=[]
for i in range(n):
    if a[i]==tmp:
        block.append(a[i])
        tmp+=1
if len(block)>0:
    print(n-len(block))
else:
    print(-1)
# Buggy code:
N = int(input())
Ali = list(map(int,input().split()))
s = 1
res = 0

for i in range(N):
  if Ali[i] == s:
    s += 1
  else:
    res += 1
    
print(res)

# Fixed code:
N = int(input())
Ali = list(map(int,input().split()))
s = 1
res = 0

for i in range(N):
  if Ali[i] == s:
    s += 1
  else:
    res += 1
    
if s == 1:
  print(-1)
else:
  print(res)
# Buggy code:
N = int(input())
Ar =list(map(int,input().split()))

cnt=1
for i in range(N):
  if Ar[i]==cnt:
    cnt+=1
print(N-cnt+1)

# Fixed code:
N = int(input())
Ar =list(map(int,input().split()))

cnt=1
for i in range(N):
  if Ar[i]==cnt:
    cnt+=1

if cnt==1:
  print(-1)
else:
  print(N-cnt+1)
# Buggy code:
n=int(input())
A=list(map(int,input().split()))
f=0
g=1
for i in range(0,n):
    if A[i]!=g:
      f++
    else:
      g++
    #printf("%d %d\n",f,g)
if g!=1:
    print(f)
else:
    print(-1)
 

# Fixed code:
n=int(input())
A=list(map(int,input().split()))
#print(A)
f=0
g=1
for i in range(0,n):
    if A[i]!=g:
        f+=1
    else:
        g+=1
#printf("%d %d\n",f,g)
if g!=1:
    print(f)
else:
    print(-1)
# Buggy code:
n = int(input())
block = [int(x) for x in input().split()]
s = 1
c = 0
for i in range(n):
  if block[i] == s:
    s += 1
  else:
    c += 1
if s == 0:
  print(-1)
else:
  print(c)

# Fixed code:
n = int(input())
block = [int(x) for x in input().split()]
s = 1
c = 0
for i in range(n):
  if block[i] == s:
    s += 1
  else:
    c += 1
if block == [1]:
  print(c)
elif s == 1:
  print(-1)
else:
  print(c)
# Buggy code:
n=int(input())
A=list(map(int,input().split()))

bef=1
ans=0
for i in range(n):
    if A[i]==bef:
        bef+=1
        ans+=1
print(n-ans)   
    

# Fixed code:
n=int(input())
A=list(map(int,input().split()))

bef=1
ans=0

if 1 not in A:
    print(-1)
    exit()

for i in range(n):
    if A[i]==bef:
        bef+=1
        ans+=1
print(n-ans)
# Buggy code:
N = int(input())
a = list(map(int,input().split()))
count = currentnum = 0

for i in a:
  if i!=currentnum+1: count+=1
  else: currentnum+=1
print(-1 if count==0 else count)

# Fixed code:
N = int(input())
a = list(map(int,input().split()))
count = currentnum = 0

if a==(list(i+1 for i in range(N))):
       print(0)
       exit()

for i in a:
  if i!=currentnum+1: count+=1
  else: currentnum+=1
print(-1 if currentnum==0 else count)
# Buggy code:
n=int(input())
a=list(int(x) for x in input().split())

count=0
z=True
j=0

if  1 not in a:
    print(-1)

for k in range(j,n):
    if a[k]==count+1:
        j=k
        count=count+1

print(n-count)

# Fixed code:
n=int(input())
a=list(int(x) for x in input().split())

count=0
z=True
j=0

if  1 not in a:
    print(-1)
else:
    for k in range(j,n):
        if a[k]==count+1:
            j=k
            count=count+1

    print(n-count)
# Buggy code:
n=int(input())
a=list(map(int,input().split()))
count=1
sum1=0
for i in range(n):
    if a[i]==count:
        count+=1
    else:
        sum1+=1
if n==sum:
    print("-1")
else:
    print(sum1)

# Fixed code:
n=int(input())
a=list(map(int,input().split()))
count=1
sum1=0
for i in range(n):
    if a[i]==count:
        count+=1
    else:
        sum1+=1
if n==sum1:
    print("-1")
else:
    print(sum1)
# Buggy code:
n = int(input())
a = list(map(int,input().split()))

ans = 1
cnt = 0

if ans not in a:
  print(-1)
  exit()
for i in range(n):
  if i == ans:
    ans += 1
    continue
  cnt += 1
  
print(cnt)

# Fixed code:
n = int(input())
a = list(map(int,input().split()))

ans = 1
cnt = 0

if ans not in a:
  print(-1)
  exit()
for i in a:
  if i == ans:
    ans += 1
    continue
  cnt += 1
  
print(cnt)
# Buggy code:
n = int(input()) - 1
k = 1
for x in map(int, input().split()):
  if x == k:
    k += 1
print(n-(k or n+1))

# Fixed code:
n = int(input())
k = 0
for x in map(int, input().split()):
  if x == k + 1:
    k += 1
print(n-(k or n+1))
# Buggy code:
n = int(input())
L = list(map(int,input().split()))
i = 0
num = 1
cnt = 0
while i <=n-1:
    if L[i] == num:
        num +=1 
    else:
        cnt +=1
    i+= 1
print(cnt)

# Fixed code:
n = int(input())
L = list(map(int,input().split()))
i = 0
num = 1
cnt = 0
while i <=n-1:
    if L[i] == num:
        num +=1 
    else:
        cnt +=1
    i+= 1
if num == 1:
    print(-1)
else:
    print(cnt)
# Buggy code:
n = int(input())
A = list(map(int, input().split()))

now = 1
hit = 0
for a in A:
    if a != now:
        hit += 1
    else:
        now += 1
print(hit)

# Fixed code:
n = int(input())
A = list(map(int, input().split()))

now = 1
hit = 0
for a in A:
    if a != now:
        hit += 1
    else:
        now += 1
if hit == n:
    print(-1)
else:
    print(hit)
# Buggy code:
# abc148_d.py
from sys import stdin
N = int(stdin.readline().rstrip())
a = [int(x) for x in stdin.readline().rstrip().split()]
print(a)
cnt = 0
idx = 1
flg = 1
for i in a:
	if i == idx:
		idx = idx + 1
		flg = 0
	else:
		cnt = cnt + 1
		if idx != 1:
			flg = 1

if flg == 1:
	print(-1)
else:
	print(cnt)



# Fixed code:
# abc148_d.py
from sys import stdin
N = int(stdin.readline().rstrip())
a = [int(x) for x in stdin.readline().rstrip().split()]
#print(a)
cnt = 0
idx = 1
#flg = 1
for i in a:
	if i == idx:
		idx = idx + 1
		#flg = 0
	else:
		cnt = cnt + 1
		#if idx != 1:
			#flg = 1

if cnt == N:
	print(-1)
else:
	print(cnt)
# Buggy code:
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
count = 0
k=0
t=0

while k<len(A):
    if A[t] == k+1:
            k += 1
            t += 1
    else:
            count += 1
            t =+ 1
if count == N:
    print(-1)
else:
    print(count)


# Fixed code:
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
count = 0
k=0
t=0

while t<len(A):
    if A[t] == k+1:
            k += 1
            t += 1
    else:
            count += 1
            t += 1
if count == N:
    print(-1)
else:
    print(count)
# Buggy code:
def main():
    N = int(input())
    b = list(map(int, input().split()))
    i = 1

    for j in range(N):
        if b[j] == i:
            i += 1
    
    print(i - 1)

if __name__ == '__main__':
    main()

# Fixed code:
def main():
    N = int(input())
    b = list(map(int, input().split()))
    i = 1

    for j in range(N):
        if b[j] == i:
            i += 1
    
    if i == 1:
        print(-1)
    else:
        print(N - i + 1)

if __name__ == '__main__':
    main()
# Buggy code:
n = int(input())
A = list(map(int, input().split()))
num = 1
ans = 0
for i in range(n):
  if A[i] == num:
    num += 1
    ans += 1
print(n-ans)

# Fixed code:
n = int(input())
A = list(map(int, input().split()))
num = 1
ans = 0
for i in range(n):
  if A[i] == num:
    num += 1
    ans += 1
if ans == 0:
  print("-1")
else:
  print(n-ans)
# Buggy code:
n = int(input())
A = list(map(int, input().split()))

c = 1
res = 0
for a in A :
    if c == a :
        c += 1
    else :
        res += 1

print(res)


# Fixed code:
n = int(input())
A = list(map(int, input().split()))

c = 1
res = 0
for a in A :
    if c == a :
        c += 1
    else :
        res += 1

print(res if not res == n else -1)
# Buggy code:
N=int(input())
a=list(map(int,input().split()))
ans=0
l=1
for i in a:
  if i!=l:
    ans+=1
  else:
    l+=1
print(ans)

# Fixed code:
N=int(input())
a=list(map(int,input().split()))
ans=0
l=1
for i in a:
  if i!=l:
    ans+=1
  else:
    l+=1
if ans==N:
  print("-1")
else:
  print(ans)
# Buggy code:


from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


def main():
    n = ii()
    a = li()

    cnt = 1
    for i in a:
        if i == cnt:
            cnt+=1
    print(n-cnt+1)

    
main()


# Fixed code:


from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


def main():
    n = ii()
    a = li()

    cnt = 1
    for i in a:
        if i == cnt:
            cnt+=1
    if cnt == 1:
        print(-1)
    else:
        print(n-cnt+1)

    
main()
# Buggy code:
N=int(input())
a=list(map(int, input().split()))

cnt=0
j=1
for i in range(N):
  if j!=a[i]:
    cnt+=1
  else:
    j+=1
print(N-cnt)

# Fixed code:
N=int(input())
a=list(map(int, input().split()))
 
cnt=0
j=1
for i in range(N):
  if j!=a[i]:
    cnt+=1
  else:
    j+=1
if cnt==N:
  print(-1)
else:
  print(cnt)
# Buggy code:
N = int(input())
ori = [int(i) for i in input().split()]
print(N,ori)
count = ori.count(1)
print(count)
if count == 0:
    print(-1)
savepoint = 0
Break = 0
quit  = 0
for j in range(1,N+1):
    for i in range(savepoint+1,N):
        if ori[i] == j:
            Break = i
            savepoint = i
            #print(Break)
            #print(savepoint)
            #print(j,i)
            sub = j
            break
        #else: 
            #quit = 1
            #break
    #if quit == 1:
        #print(quit)
        #break
print(Break+1-sub)

# Fixed code:
N = int(input())
ori = [int(i) for i in input().split()]
count = ori.count(1)
if count == 0:
    print(-1)

else:
    savepoint = 0
    for j in range(1,N+1):
        for i in range(savepoint,N):
            if ori[i] == j:
                savepoint = i
                #print(savepoint)
                #print(j,i)
                sub = j
                break
        if i == N-1:
            break
    print(N-sub)
# Buggy code:
N=int(input())
A=list(map(int,input().split()))
s=1
i=0
while i<N:
  if s==A[i]:
    s+=1
  i+=1
mi=N-s
if mi==N:
  print(-1)
else:
  print(mi)

# Fixed code:
N=int(input())
A=list(map(int,input().split()))
s=1
i=0
while i<N:
  if s==A[i]:
    s+=1
  i+=1
mi=N-(s-1)
if 1 not in A:
  print(-1)
else:
  print(mi)
# Buggy code:
n=int(input())
a=list(map(int,input().split()))
k=1
cnt=0
for i in range(n):
  if a[i]==k:
    k+=1
    cnt+=1
print(n-cnt)

# Fixed code:
n=int(input())
a=list(map(int,input().split()))
k=1
cnt=0
for i in range(n):
  if a[i]==k:
    k+=1
    cnt+=1
if cnt>0:
  print(n-cnt)
else:
  print(-1)
# Buggy code:
N = int(input())
arr = list(map(int, input().split()))
exp = 1
for num in arr:
  if exp == num:
    exp += 1
if exp == 1:
  print('-1')
else:
  print(N-exp)

# Fixed code:
def resolve():
    N = int(input())
    arr = list(map(int, input().split()))
    exp = 1
    for num in arr:
        if exp == num:
            exp += 1

    if exp == 1:
        print('-1')
    else:
        print(N - (exp - 1))

resolve()
# Buggy code:
a = int(input())
l=list(map(int ,input().split()))
p=0
u=1
for i in range(a):
    if l[i]==u:
        u+=1
    else:
        p+=1    
print(p)

# Fixed code:
a = int(input())
l=list(map(int ,input().split()))
p=0
u=1
for i in range(a):
    if l[i]==u:
        u+=1
    else:
        p+=1
if p==a:
    print(-1)
else:
    print(p)
# Buggy code:
S=input()
count=0
for i in range(len(S)):
  if S[i]!=S[-i-1]:
    count+=1
print(count)

# Fixed code:
S = input()
count = 0
for i in range(len(S) // 2):
    if S[i] != S[len(S)- i - 1]:
        count += 1

print(count)
# Buggy code:
s=input()
n=len(s)
ans=0
for i,j in zip(s[:n//2-1],s[n:n//2-1:-1]):
  if i!=j:
    ans+=1
print(ans)

# Fixed code:
s=input()
n=len(s)
ans=0
for i,j in zip(s[:n//2],s[:n//2-1:-1]):
  if i!=j:
    ans+=1
print(ans)
# Buggy code:
s=input()
n=len(n)

c=0
i=0
while i<n-i-1
  if s[i]!=s[n-i-1]:
    c+=1
  i+=1
print(c)

# Fixed code:
s=input()
n=len(s)
 
c=0
i=0
while i<n-i-1:
  if s[i]!=s[n-i-1]:
    c+=1
  i+=1
print(c)
# Buggy code:
# -*- coding: utf-8 -*-

s = input()
s_list = list(s)
s_len = len(s_list)

hag = 0

for i in range(s_len//2):
  if s_list[i] != s_list[(s_len-1)-i]:
    s_list[s_len-i] = s_list[i]
    hag += 1
  
print(hag)

# Fixed code:
# -*- coding: utf-8 -*-

s = input()
s_list = list(s)
s_len = len(s_list)

hag = 0

for i in range(s_len//2):
  if s_list[i] != s_list[(s_len-1)-i]:
    s_list[(s_len-1)-i] = s_list[i]
    hag += 1
  
print(hag)
# Buggy code:
def palin(S):
    lst = list(S)
    num = len(lst)//2
    count = 0
    for i in range(num):
        if not lst[i] == lst[-i-1]:
            count += 1
    return count

S = input()
palin(S)

# Fixed code:
def palin(S):
    lst = list(S)
    num = len(lst)//2
    count = 0
    for i in range(num):
        if not lst[i] == lst[-i-1]:
            count += 1
    return count

S = input()
print(palin(S))
# Buggy code:
S = input()
n = len(S) // 2
c = 0;
for s1, s2 in zip(S[:n], S[n:]):
    if s1 != s2:
        c += 1
print(c)

# Fixed code:
S = input()
n = len(S) // 2
c = 0;
for s1, s2 in zip(S[:n], S[-1:n-1:-1]):
    if s1 != s2:
        c += 1
print(c)
# Buggy code:
# -*- coding: utf-8 -*-
s = input()
sum = 0
for i in range(len(s)//2):
    if s[i] != s[-i]:
        sum += 1
print(sum)


# Fixed code:
# -*- coding: utf-8 -*-
s = input()
sum = 0
for i in range(len(s)//2):
    if s[i] != s[-(i+1)]:
        sum += 1
print(sum)
# Buggy code:
s = input()
ans = 0
for i in range(len(s) // 2):
    if s[i] == s[-i - 1]:
        ans += 1
print(ans)

# Fixed code:
s = input()
l = len(s)//2
ans = 0
for i in range(l):
    if s[i] != s[-(i+1)]:
        ans += 1
print(ans)
# Buggy code:
s = input()

n = len(s) // 2

sf = s[0:n]
ss = s[::-1]
sb = ss[0:n]
print(sf, sb)
cnt = 0
for i in range(n):
    if sf[i] != sb[i]:
        cnt += 1
print(cnt)

# Fixed code:
s = input()

n = len(s) // 2

sf = s[0:n]
ss = s[::-1]
sb = ss[0:n]
cnt = 0
for i in range(n):
    if sf[i] != sb[i]:
        cnt += 1
print(cnt)
# Buggy code:
S = input()
S_inv = S[::-1]

out = 0
for i in range(len(S)):
  print(S[:-i])
  #if S[i] != S[:-i]:
#    out = out + 1
#
#out = out // 2
#print(out)


# Fixed code:
S = input()
S_inv = S[::-1]

out = 0
for i in range(len(S)):
  if S[i] != S_inv[i]:
    out = out + 1

out = out // 2
#if out % 2 == 1:
#  out == out // 2 + 1
#else:
#  out == out // 2 
print(out)
# Buggy code:

a = list(input())
b = len(a)
c = int(b/2)
result = []
if b%2 == 0:
    A = a[:c]
    B = a[c:]
    BB = B[::-1]
    for v in range(c):
        if A[v] != BB[v]:
            result.append(v)
        else:
            x.append(v)
        
else:
    C = a[:c]
    D = a[c+1:]
    DD = D[::-1]
    for v in range(c):
        if C[v] != DD[v]:
            result.append(v)
        else:
            x.append(v)
print(len(result))

# Fixed code:
a = list(input())
b = len(a)
c = int(b/2)
x = []
result = []
if b%2 == 0:
    A = a[:c]
    B = a[c:]
    BB = B[::-1]
    for v in range(c):
        if A[v] != BB[v]:
            result.append(v)
        else:
            x.append(v)
        
else:
    C = a[:c]
    D = a[c+1:]
    DD = D[::-1]
    for v in range(c):
        if C[v] != DD[v]:
            result.append(v)
        else:
            x.append(v)
print(len(result))
# Buggy code:
x = input()
a = x[::-1]
b = 0
c = 0
d = len(x)

while b >= d:
  if x[b] == a[b]:
    c = c
    b = b + 1
  else:
    c = c + 1
    b = b + 1
c = int(c/2)
print(c)

# Fixed code:
x = input()
a = x[::-1]
b = 0
c = 0
d = int(len(x))
while b + 1 <= d:
  if x[b] == a[b]:
    c = c
    b = b + 1
  else:
    c = c + 1
    b = b + 1
c = int(c/2)
print(c)
# Buggy code:
S = input()
count=0

mid = len(S)//2

for i in range(mid):
  print(S[i], S[-i-1])
  if S[i] != S[-i-1]:
    count+=1
print(count)

# Fixed code:
S = input()
count=0

mid = len(S)//2

for i in range(mid):
  if S[i] != S[-i-1]:
    count+=1
print(count)
# Buggy code:
s = input()
ans = 0
for i in range(len(s)//2):
    if s[i] != s[-i-1]:
        print(s[i])
        ans+=1
print(ans)

# Fixed code:
s = input()
count = 0
for i in range(len(s)//2):
    if s[i]!=s[len(s)-i-1]:
        count += 1
print(count)
# Buggy code:
s = input()
i = len(s) // 2
flont = 0
back = -1
miss = 0
for n in range(i):
    if s[flont] != s[back]:
        miss += 1
print(miss)

# Fixed code:
s = input()
i = len(s) // 2
flont = 0
back = -1
miss = 0
for n in range(i):
    if s[flont] != s[back]:
        miss += 1
    flont += 1
    back -= 1
print(miss)
# Buggy code:
s=list(input())
n=len(s)
cnt=0
for i in range(n//2):
  if s[i] != s[n-i]: cnt+=1
print(cnt)

# Fixed code:
s = input()
cnt = 0
for i in range(len(s)//2):
    if s[i] != s[-(i+1)]:
        cnt += 1
print(cnt)
# Buggy code:
bun = input()
nub = reversed(S)
n = int(len(S) / 2)

i = hug = 0
while i < n:
    if bun[i] != nub[i]:
        hug += 1
    i += 1
print(hug)

# Fixed code:
bun = input()
nub = list(reversed(bun))
n = int(len(bun) / 2)

i = hug = 0
while i < n:
    if bun[i] != nub[i]:
        hug += 1
    i += 1
print(hug)
# Buggy code:
a = input()
hl = int(len(a)/2)
first = a[:hl]
last = a[:hl:-1]
ans = 0
for fi,la in zip(first,last):
    if fi != la :
        ans += 1
print(ans)

# Fixed code:
a = input()
hl = int(len(a)/2)
first = a[:hl]
last = a[:hl+(len(a)%2-1):-1]
ans = 0
# print(first)
# print(last)
for fi,la in zip(first,last):
    if fi != la :
        ans += 1
print(ans)
# Buggy code:
s = input()
count = 0
for i in range(len(s)):
  if s[i] != s[len(n)-1-i]:
    count += 1
print(count//2)

# Fixed code:
s = input()
count = 0
for i in range(len(s)):
  if s[i] != s[len(s)-1-i]:
    count += 1
print(count//2)
# Buggy code:
def actual(s):
    N = len(s)
    count_operation = 0

    for i in range(N):
        head = s[i]
        tail = s[N - 1 - i]

        if head != tail:
            count_operation += 1

    return count_operation / 2

s = input()
print(actual(s))

# Fixed code:
def actual(s):
    N = len(s)
    count_operation = 0

    for i in range(N):
        head = s[i]
        tail = s[N - 1 - i]

        if head != tail:
            count_operation += 1

    return int(count_operation / 2)

s = input()
print(actual(s))
# Buggy code:
s = input()

count = 0

for i in range(len(s) // 2):
  if s[i] != s[-i]:
    count += 1
    
print(count)

# Fixed code:
s=input()
l=len(s)
count=0
for i in range(l//2):
    if s[i]!=s[-1-i]:
        count+=1
print(count)
# Buggy code:
from math import modf
word=input()
word=list(set(word))
n=len(word)/2
decimal,integer=modf(n)
integer=int(integer)
count=0
print(integer)
for i in range(integer):
  if word[i]!=word[-i-1]:
    word[-i-1]=word[i]
    count+=1
print(count)

# Fixed code:
from math import modf
word=input()
word=list(word)
n=len(word)/2
decimal,integer=modf(n)
integer=int(integer)
count=0
for i in range(integer):
  if word[i]!=word[-i-1]:
    word[-i-1]=word[i]
    count+=1
print(count)
# Buggy code:
S = input()
c = 0
for n in range(len(S)//2):
    if(S[n] != S[-n]):
        c = c + 1
print(c)

# Fixed code:
S=input()

c=0

for i in range(len(S)//2):
    if S[i]!=S[len(S)-1-i]:
        c+=1

print(c)
# Buggy code:
s = input()

cnt = 0
for i in range(len(s)//2):
    if s[i] != s[-i-1]:
        cnt += 1
        s[-i-1] = s[i]
print(cnt)


# Fixed code:
s = input()

cnt = 0
s = list(s)
for i in range(len(s)//2):
    if s[i] != s[-i-1]:
        cnt += 1
        s[-i-1] = s[i]
print(cnt)
# Buggy code:
S=input()
hug=0
for i in range(len(S)//2):
    if S[i]!=S[-i]:
      hug+=1
print(hug)

# Fixed code:
S=input()
hug=0
for i in range(len(S)//2):
    if S[i]!=S[len(S)-i-1]:
      hug+=1
print(hug)
# Buggy code:
s=input();n=len(s)-1;print(sum(s[i]!=s[n-i]for i in range(n+1))//2)s=input();n=len(s)-1;print(sum(s[i]!=s[n-i]for i in range(n+1))//2)

# Fixed code:
s=input();print(sum(s[i]!=s[len(s)-i-1] for i in range(len(s)))//2)
# Buggy code:
S = list(input())

cnt = 0

if len(S)%2 == 0:
  for i in range(0,int(len(S)/2+1)):
    if S[i] != S[-1-i]:
      cnt +=1
else:
  for i in range(0,int(len(S)/2)):
    if S[i] != S[-1-i]:
      cnt +=1

print(cnt)
                



# Fixed code:
S = list(input())

cnt = 0

if len(S)%2 == 0:
  for i in range(0,int(len(S)/2)):
    if S[i] != S[-1-i]:
      cnt +=1
else:
  for i in range(0,int(len(S)/2)):
    if S[i] != S[-1-i]:
      cnt +=1

print(cnt)
# Buggy code:
s = input()
l = len(s)
ans = 0

for i in range(l // 2):
    if s[i]!=s[-i]:
        ans += 1

print(ans)


# Fixed code:
s = input()

length = len(s)

ans = 0

for i in range(length // 2):
    if s[i] != s[-(i+1)]:
        ans += 1

print(ans)
# Buggy code:
import sys

s = sys.stdin.read().strip()
c = 0
l = len(s)
print(int(l/2))
for i in range(int(l/2)):
  if s[i] != s[l-i-1]:
    c += 1
print(c)


# Fixed code:
import sys

s = sys.stdin.read().strip()
c = 0
l = len(s)
for i in range(int(l/2)):
  if s[i] != s[l-i-1]:
    c += 1
print(c)
# Buggy code:
s = input()
n = len(s) // 2
p = n
j = -1

for i in range(n):
    if n[i] == n[j]:
        p -= 1
    j -= 1

print(p)

# Fixed code:
s = input()
n = len(s) // 2
p = n
j = -1

for i in range(n):
    if s[i] == s[j]:
        p -= 1
    j -= 1

print(p)
# Buggy code:
kotae=[]
N = int(input())
Sst=input()
S = list(Sst)
L=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','Q','V','W','X','Y','Z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','Q','V','W','X','Y','Z','A','B','C']

for i in range(len(Sst)):
    for j in range(26):
        if S[i] == L[j]:
            kotae.append(L[j+N])

Sed = "".join(kotae)
print(Sed)

# Fixed code:
kotae=[]
N = int(input())
Sst=input()
S = list(Sst)
L=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','A','B','C']

for i in range(len(Sst)):
    for j in range(26):
        if S[i] == L[j]:
            kotae.append(L[j+N])

Sed = "".join(kotae)
print(Sed)
# Buggy code:
def shiftText(plain_text, key):
    plain_text.lower
    encoded_text = ""
    for i in plain_text:
        char = ord(i)+key
        if (char > 122):
            char -= 26
            encoded_text += chr(char)
        else:
            encoded_text += chr(char)
    return encoded_text


key = int(input())
plain_text = input()

print(shiftText(plain_text, key))


# Fixed code:
def shiftText(plain_text, key):
    plain_text.lower
    encoded_text = ""
    for i in plain_text:
        char = ord(i)+key
        if (char > 90):
            char -= 26
            encoded_text += chr(char)
        else:
            encoded_text += chr(char)
    return encoded_text


key = int(input())
plain_text = input()

print(shiftText(plain_text, key))
# Buggy code:
n = int(input())
s = list(input())

for i in range(len(s)):
    ascii = ord(s[i])
    if((ascii+n)>90):
        print(chr(65+(ascii+n-90)),end='')
    else:
        print(chr(ascii+n),end='')



# Fixed code:
n = int(input())
s = list(input())

for i in range(len(s)):
    ascii = ord(s[i])
    if((ascii+n)>90):
        print(chr(64+(ascii+n-90)),end='')
    else:
        print(chr(ascii+n),end='')