Harryxun/stf_run huggingface dataset:
gyou,retu=map(int,input().split())
l=[input() for _ in range(gyou)]
d=[(-1,-1),(-1,0),(-1,1),(0,-1),(0,1),(1,-1),(1,0),(1,1)]
for g in range(gyou):
  preans=str()
  for r in range(retu):
    s=0
    if l[g][r]=="#":
      preans += "#"
    else:
      for x in range(8):
        a,b=*d[x]
        try:
          if l[g+a][r+b]=="#" and g+a>=0 and r+b>=0:
            s+=1
        except IndexError:
          s+=0
      preans += str(s)
  print(preans)

### FIXED CODE ###

gyou,retu=map(int,input().split())
l=[input() for _ in range(gyou)]
d=[(-1,-1),(-1,0),(-1,1),(0,-1),(0,1),(1,-1),(1,0),(1,1)]
for g in range(gyou):
  preans=str()
  for r in range(retu):
    s=0
    if l[g][r]=="#":
      preans += "#"
    else:
      for x in range(8):
        a,b=d[x]
        try:
          if l[g+a][r+b]=="#" and g+a>=0 and r+b>=0:
            s+=1
        except IndexError:
          s+=0
      preans += str(s)
  print(preans)
from collections import Counter
N=int(input())
lis=list(input() for _ in range(N))
ans=[]
high=0

counter=Counter(lis)
high=counter.most_common()[0][1]

for  j in se:
  if lis.count(j)==high:
    ans.append(j)
ans.sort()

for k in ans:
  print(k)

### FIXED CODE ###

from collections import Counter
N=int(input())
lis=list(input() for _ in range(N))
ans=[]

counter=Counter(lis)
high=counter.most_common()[0][1]

for k,v in counter.most_common():
  if v==high:
    ans.append(k)
  else:
    break
ans.sort()
for i in ans:
  print(i)
k,s = map(int, input().split())

l = 0

if s <= k:
  l = int((k+2)(k+1)/2)
else:
  for x in range(0,k+1):
    if s-x > 2k:
      l += 0
    elif k < s-x <= 2k:
      l += 2*k - s + x + 1
    elif s-x <= k:
      l += s-x+1      
print(l)

### FIXED CODE ###

k,s = map(int, input().split())

l = 0

if s <= k:
  l = int((s+2)*(s+1)/2)
else:
  for x in range(0,k+1):
    if s-x > 2*k:
      l += 0
    elif k < s-x <= 2*k:
      l += 2*k - s + x + 1
    elif s-x <= k:
      l += s-x+1      
print(l)
N = input()
inp = input()
listA = inp.split(' ')
out = YES
for k in listA:
  count = 0
  for j in listA:
    if k == j:
      count += 1
      if count >= 2:
        out = NO
        break
print(out)
  

### FIXED CODE ###

N = int(input())
inputA = input()
listA = inputA.split(' ')
listA.sort()
output = 'YES'
for i in range (len(listA) - 1):
    if listA[i] == listA[i + 1]:
        output = 'NO'
print(output)
abc = input().split()
a =int(abc[0])
b = int(abc[1])
c = int(abc[2])
if a<B and b<c:
    print("Yes")
else:
    print("No")
    


### FIXED CODE ###

a,b,c = input().split()
a =int(a)
b = int(b)
c = int(c)
if a<b and b<c:
    print("Yes")
else:
    print("No")
N=int(input())
H=[int(x) for x in input().split()]
can_watch = 0
for i in range(N):
  if H[i] >= max(H[:i]):
    can_watch = can_watch + 1
  else:
    pass
print(can_watch)

### FIXED CODE ###

N=int(input())
H=[int(x) for x in input().split()]
can_watch = 0
for i in range(N):
  if i > 0:
    if H[i] >= max(H[:i]):
      can_watch = can_watch + 1
    else:
      pass
  else:
    can_watch = can_watch + 1
print(can_watch)
w,c = map(int,input().split())
     
    res = w - (c+c)
    if res < 0:
      res =0
    print(res)

### FIXED CODE ###

w,c = map(int,input().split())
         
res = w - (2*c)

if res < 0:
    res =0
print(res)
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**10]*n
dp[0]=0
for i in range(1,n):
    if i>=k:
        for j in range(i-k,i):
            dp[i]=dp[j]+min(h[j]-h[i])
print(dp[n-1])


### FIXED CODE ###

n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**5]*n
dp[0]=0
for i in range(1,n):
    dp[i]=min(dp[j]+abs(h[j]-h[i]) for j in range(max(0,i-k),i))
print(dp[n-1])
#a,b,c = [int(i) for i in input().split()]

import sys
input = sys.stdin.readline

SIZE=200002; 
MOD = 10**9+7
2bai= 500000000+4

inv = [0]*(SIZE+1)# inv[j] = j^{-1} mod MOD
fac = [0]*(SIZE+1)# fac[j] = j! mod MOD
finv = [0]*(SIZE+1)# finv[j] = (j!)^{-1} mod MOD
inv[1] = 1
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
for i in range(2,SIZE+1):
    inv[i] = MOD -(MOD//i)*inv[MOD%i]%MOD
    fac[i] = fac[i-1]*i%MOD
    finv[i]= finv[i-1]*inv[i]%MOD

def choose(n,r): # nCk mod MOD の計算
    if 0 <= r <= n:
        return (fac[n]*finv[r]%MOD)*finv[n-r]%MOD
    else:
        return 0



b,w = [int(i) for i in input().split()]

ans = [0]*(b+1)
ans[x] = 1

c = min(b,w)
for i in [0]*c:
    print(2bai)

ans = 2bai
for i in range(c,b+w+1):
    ans += pow(2,i-1,MOD)*(choose(i-1,i-1-w) - choose(i-1,b-1)
    ans %= MOD
    print(ans)



        
                           

### FIXED CODE ###

#a,b,c = [int(i) for i in input().split()]

import sys
input = sys.stdin.readline

SIZE=200002; 
MOD = 10**9+7
bai= 500000000+4

inv = [0]*(SIZE+1)# inv[j] = j^{-1} mod MOD
fac = [0]*(SIZE+1)# fac[j] = j! mod MOD
finv = [0]*(SIZE+1)# finv[j] = (j!)^{-1} mod MOD
inv[1] = 1
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
for i in range(2,SIZE+1):
    inv[i] = MOD -(MOD//i)*inv[MOD%i]%MOD
    fac[i] = fac[i-1]*i%MOD
    finv[i]= finv[i-1]*inv[i]%MOD

def choose(n,r): # nCk mod MOD の計算
    if 0 <= r <= n:
        return (fac[n]*finv[r]%MOD)*finv[n-r]%MOD
    else:
        return 0



b,w = [int(i) for i in input().split()]

c = min(b,w)
for i in [0]*c:
    print(bai)

ans = bai
p=pow(bai,c+1,MOD)
for i in range(c,b+w):
#    print(p,i-1,i-w,b-1)
    ans += p*(choose(i-1,i-w) - choose(i-1,b-1))
    p= p*bai; p%=MOD
    ans = ans%MOD
    print(ans)
N,D = map(int,input().split())
a = N%(2*D+1)
b = N//(2*D+1)
if a=0:
  print(b)
else:
  print(int(b+1))


### FIXED CODE ###

N,D = map(int,input().split())
a = N%(2*D+1)
b = N//(2*D+1)
if a==0:
  print(int(b))
else:
  print(int(b+1))
L.R,d = map(int,input().split())
ans = 0
for i in range(L,R+1):
  if i % d == 0:
    ans += 1
print(ans)

### FIXED CODE ###

L,R,d = map(int,input().split())
ans = 0
for i in range(L,R+1):
  if i % d == 0:
    ans += 1
print(ans)
import numpy as np
inputs = open(0).readlines()

for i in range(1, count+1):
    x, y = coords[i]
    x0, y0 = x-1, y-1
    x1, y1 = x+1, y+1
    while 0 < x0 and cake[y0, x0] == 0:
        cake[y, x0] = i
        x0 -= 1
    while x1 < w and cake[y0, x1] == 0:
        cake[y, x1] = i
        x1 += 1
    while 0 < y0 and np.all(cake[y0, x0:x1] == 0):
        cake[y0, x0:x1] = i
        y0 -= 1
    while y1 < h and np.all(cake[y1, x0:x1] == 0):
        cake[y1, x0:x1] = i
        y1 += 1

### FIXED CODE ###

import numpy as np
inputs = open(0).readlines()

def main(inputs):
    h, w, k = map(int, inputs[0].split())
    cake, count, coords = np.zeros((h, w), dtype=np.uint), 0, {}
    for i, s in enumerate(inputs[1:]):
        for j, c in enumerate(s):
            if c == '#':
                count += 1
                cake[i, j] = count
                coords[count] = (j, i)
    empty_rows = {i for i, rows in enumerate(cake) if not np.any(rows)}

    for i in range(1, count+1):
        x, y = coords[i]
        x0, y0 = x-1, y-1
        x1, y1 = x+1, y+1
        while 0 <= x0 and cake[y, x0] == 0:
            cake[y, x0] = i
            x0 -= 1
        x0 += 1
        while x1 < w and cake[y, x1] == 0:
            cake[y, x1] = i
            x1 += 1
        while 0 <= y0 and y0 in empty_rows:
            cake[y0, x0:x1] = i
            y0 -= 1
        while y1 < h and y1 in empty_rows:
            cake[y1, x0:x1] = i
            y1 += 1

    for rows in cake:
        print(*rows)

main(inputs)
n, x = map(int, input().split())
l = list(map(int, input().split()))
now = 0
i = 0

while now <= x:
    now += l[i]
    i += 1
    
print(i)

### FIXED CODE ###

n, x = map(int, input().split())
l = list(map(int, input().split()))
now = 0

for i in range(len(l)):
    now += l[i]
    if now > x:
        break
else:
    i += 1
    
print(i+1)
abc = input()
abc_int = int(abc)
prolist = []
chk = int(abc_int**0.5)+2
for c1 in range(chk):
	if abc_int % c1 == 0:
		prolist.append(c1+abc_int//c1-2)
print(min(prolist))

### FIXED CODE ###

j=input()
i = j.split(' ')
k = []
for c in i:
    k.append(int(c))
if k[0]<10 and k[1]<10:
	print(k[0]*k[1])
else:
	print(-1)
a,op,b=map(str,input().split())
if(op=="+"):
  print(a+b)
else:
  print(a-b)


### FIXED CODE ###

a,op,b=map(str,input().split())
if(op=="+"):
  print(int(a)+int(b))
else:
  print(int(a)-int(b))
#!/usr/bin/python3
# -*- coding: utf-8 -*-

s = input()
words = ['dream', 'dreamer', 'erase', 'eraser']


def dfs(n):
    if n == len(s):
        return True
    for w in words:
        if s[n:].startswith(w):
            if dfs(n + len(w)):
                return True
    return False


if dfs(0):
    print('YES')
else:
    print('NO')


### FIXED CODE ###

#!/usr/bin/python3
# -*- coding: utf-8 -*-

s = input()
revs = s[::-1]
words = ['maerd', 'remaerd', 'esare', 'resare']


def scan(n):
    for w in words:
        if revs[n:].startswith(w):
            return len(w)
    print('NO')
    exit()


n = 0
while revs[n:] != '':
    n += scan(n)

print('YES')
n,m = list(map(int,input().strip().split()))
h = list(map(int,input().split()))
temp = [1] * n
for i in range(m):
    a,b = list(map(int,input().strip().split()))
    if h[a-1] > h[b-1]:
        temp[b-1] *= 0
    elif h[a-1] == h[b-i]:
        temp[a-1] *= 0
        temp[b-1] *= 0
    else:
        temp[a-1] *= 0
ans = temp.count(1)
print(ans)



### FIXED CODE ###

n,m = list(map(int,input().strip().split()))
h = list(map(int,input().split()))
temp = [1] * n
ans = int(0)
for i in range(m):
    a,b = list(map(int,input().strip().split()))
    if h[a-1] > h[b-1]:
        temp[b-1] *= 0
    elif h[a-1] == h[b-1]:
        temp[a-1] *= 0
        temp[b-1] *= 0
    else:
        temp[a-1] *= 0
ans += temp.count(1)
print(ans)
N = int(input())
S = list(map(int,input().split()))
S.sort()

parents = [(S.pop(),N)]

flg = True
while parents and flg:
    s,n = parents.pop(0)
    for i in range(1,n+1):
        x = S.pop()
        if s > x and n-i != 0:
            parents.append((x,n-i))
            
        elif s <= x:
            flg = False
            break
    print(parents)
    print(S)
 
if flg:
    print('Yes')
else:
    print('No')
    

### FIXED CODE ###

N = int(input())
A = sorted((int(x) for x in input().split()))
 
parent = [A[-1]]
rest = A[:-1]
bl = True
for _ in range(N):
    next_parent = []
    next_rest = []
    for p in parent[::-1]:
        while rest:
            x = rest.pop()
            if x < p:
                next_parent.append(x)
                break
            else:
                next_rest.append(x)
                continue
    parent += next_parent
    parent.sort()
    rest = rest + next_rest[::-1]
 
bl = len(parent) == (2**N)
answer = 'Yes' if bl else 'No'
print(answer)
N=int(input())
A=[]
for i in range(1:10):
  for j in range(1:10):
    A.append(i*j)
if  N in A:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

N=int(input())
list=[]
for i in range(1,10):
  for j in range(1,10):
    list.append(i*j)
if N in list:
   print("Yes")
else:
   print("No")
n = int(input())
a = list(map(int, input().split()))
hai, tya midori = 0, 0, 0
mmiz, ao, ki = 0, 0, 0
yanagi, aka, got = 0, 0, 0

for i in a:
  if i<=399:
    hai = 1
  elif i<=799:
    tya = 1
  elif i<=1199:
    midori = 1
  elif i <= 1599:
    miz = 1
  elif i <= 1999:
    ao = 1
  elif i <= 2399:
      ki = 1
  elif i <= 2799:
      yanagi = 1
  elif i <= 3199:
      aka = 1
  elif i <= 4800:
    got += 1
minn = sum(hai+tya+midori+miz+ao+ki+yanagi+aka)
if minn + got >= 8:
  maxx = 8
else:
  maxx = minn+got
print(minn, maxx)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
hai, tya, midori = 0, 0, 0
miz, ao, ki = 0, 0, 0
yanagi, aka, got = 0, 0, 0

for i in a:
  if i<=399:
    hai = 1
  elif i<=799:
    tya = 1
  elif i<=1199:
    midori = 1
  elif i <= 1599:
    miz = 1
  elif i <= 1999:
    ao = 1
  elif i <= 2399:
      ki = 1
  elif i <= 2799:
      yanagi = 1
  elif i <= 3199:
      aka = 1
  elif i <= 4800:
    got += 1
minn = hai+tya+midori+miz+ao+ki+yanagi+aka
maxx = minn+got
if minn==0:
    minn = 1
print(minn, maxx)
a, b = map(int, input().split())
if a + b == 15:
    print("+")
elif a * b =- 15:
    print("*")
else:
    print("x")

### FIXED CODE ###

a, b = map(int, input().split())
if a + b == 15:
    print("+")
elif a * b == 15:
    print("*")
else:
    print("x")
import math
import sys
import itertools
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
x,y = IL()
N = len(s)

xlist = []
ylist = []

f = 0
cnt = 0
for i in range(N):
  if s[i] == "F":
    cnt += 1
  elif s[i] == "T":
    if f == 0:
      xlist.append(cnt)
      f = 1
    else:
      ylist.append(cnt)
      f = 0
    cnt = 0
else:
  if f == 0:
    xlist.append(cnt)
  else:
    ylist.append(cnt)

#print(xlist)
#print(ylist)

Xsum = sum(xlist)
Ysum = sum(ylist)

if (Xsum-x)%2 != 0:
  print("No")
  exit()
else:
  Xnum = (Xsum-x)//2
if (Ysum-y)%2 != 0:
  print("No")
  exit()
else:
  Ynum = (Ysum-y)//2

XDP = [[0]*(Xnum+2) for _ in range(len(xlist)+2)]
YDP = [[0]*(Ynum+2) for _ in range(len(ylist)+2)]

XDP[0][0] = 1
YDP[0][0] = 1

for i in range(1,len(xlist)+1):
  for j in range(Xnum+1):
    if XDP[i-1][j] == 1:
      XDP[i][j] = 1
      if j+xlist[i-1] < Xnum+1:
        XDP[i][j+xlist[i-1]] = 1
#print(XDP)
for i in range(1,len(ylist)+1):
  for j in range(Ynum+1):
    if YDP[i-1][j] == 1:
      YDP[i][j] = 1
      if j+ylist[i-1] < Ynum+1:
        YDP[i][j+ylist[i-1]] = 1
#print(YDP)
if XDP[-2][-2] == 1 and YDP[-2][-2] == 1:
  print("Yes")
else:
  print("No")
"""
FFTFFTFFFFTFFFFTFFTFFTFFFFTFFFFTFFTFF
2 2

FFFFFF
2 2
"""

### FIXED CODE ###

#import numpy as np
import math
import sys
import itertools
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
x,y = IL()
N = len(s)

xlist = []
ylist = []

f = 0
cnt = 0
for i in range(N):
  if s[i] == "F":
    cnt += 1
  elif s[i] == "T":
    if f == 0:
      xlist.append(cnt)
      f = 1
    else:
      ylist.append(cnt)
      f = 0
    cnt = 0
else:
  if f == 0:
    xlist.append(cnt)
  else:
    ylist.append(cnt)

x -= xlist.pop(0)
Xsum = sum(xlist)
Ysum = sum(ylist)

if (Xsum-x)%2 != 0:
  print("No")
  exit()
else:
  Xnum = (Xsum-abs(x))//2
if (Ysum-y)%2 != 0:
  print("No")
  exit()
else:
  Ynum = (Ysum-abs(y))//2

#print(Xnum,Ynum)

XDP = [[0]*(abs(Xnum)+1) for _ in range(len(xlist)+1)]
YDP = [[0]*(abs(Ynum)+1) for _ in range(len(ylist)+1)]

XDP[0][0] = 1
YDP[0][0] = 1

for i in range(1,len(xlist)+1):
  for j in range(Xnum+1):
    if XDP[i-1][j] == 1:
      XDP[i][j] = 1
      if j+xlist[i-1] < Xnum+1:
        XDP[i][j+xlist[i-1]] = 1
#print(Xnum)
#print(xlist)
#print(XDP)

for i in range(1,len(ylist)+1):
  for j in range(Ynum+1):
    if YDP[i-1][j] == 1:
      YDP[i][j] = 1
      if j+ylist[i-1] < Ynum+1:
        YDP[i][j+ylist[i-1]] = 1
#print(Ynum)
#print(ylist)
#print(YDP)

if XDP[-1][-1] == 1 and YDP[-1][-1] == 1:
  print("Yes")
else:
  print("No")
from collections import defaultdict

s = input()
x, y = map(int, input().split())

arr = list(map(len, s.split('T')))
EW = [arr[ew] for ew in range(0, len(arr), 2)]
NS = [arr[ns] for ns in range(1, len(arr), 2)]

# dp[i][j] := i回目までの移動で座標jにいることができるか
dp = [defaultdict(bool) for i in range(len(EW))]
dp[0][EW[0]] = True
for i in range(1, len(EW)):
    for prev in dp[i - 1].keys():
        dp[i][prev + EW[i]] = True
        dp[i][prev - EW[i]] = True
if not dp[-1][x]:
    print('No')
    exit(0)

dp = [defaultdict(bool) for i in range(len(NS))]
dp[0][NS[0]] = True
dp[0][-NS[0]] = True
for i in range(1, len(NS)):
    for prev in dp[i - 1].keys():
        dp[i][prev + NS[i]] = True
        dp[i][prev - NS[i]] = True
if not dp[-1][y]:
    print('No')
    exit(0)

print('Yes')


### FIXED CODE ###

from collections import defaultdict

s = input()
x, y = map(int, input().split())

arr = list(map(len, s.split('T')))
EW = [arr[ew] for ew in range(0, len(arr), 2)]
NS = [arr[ns] for ns in range(1, len(arr), 2)]

# dp[i][j] := i回目までの移動で座標jにいることができるか
dp = [defaultdict(bool) for i in range(len(EW))]
dp[0][EW[0]] = True
for i in range(1, len(EW)):
    for prev in dp[i - 1].keys():
        dp[i][prev + EW[i]] = True
        dp[i][prev - EW[i]] = True
if not dp[-1][x]:
    print('No')
    exit(0)

if len(NS) > 0:
    dp = [defaultdict(bool) for i in range(len(NS))]
    dp[0][NS[0]] = True
    dp[0][-NS[0]] = True
    for i in range(1, len(NS)):
        for prev in dp[i - 1].keys():
            dp[i][prev + NS[i]] = True
            dp[i][prev - NS[i]] = True
    if not dp[-1][y]:
        print('No')
        exit(0)

print('Yes')
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
G = [0] * N
for i in range(N):
    dif = V[i] - C[i]
    if(dif > 0):
        G[i] = dif
print(sum(G[i]))

### FIXED CODE ###

N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
G = [0] * N
for i in range(N):
    dif = V[i] - C[i]
    if(dif > 0):
        G[i] = dif
print(sum(G))
n = int(input())
i=0
while (2**i <= n):
  i += 1
  
 print(2**(i-1))

### FIXED CODE ###

n = int(input())
a = []
b=[]

for i in range(1,n+1):
  a.append(i)
count = 0


for i in range(1,n+1):
  
  count = 0
  while True:
    if (a[i-1]%2) == 0:
      count += 1
      a[i-1] = a[i-1]/2
      
    else:
      break
  b.append(count)


c =max(b)
print(b.index(c)+1)
import numpy as np

def main():
    A, B = list(map(int, input().split()))
    print(np.lcm(A, B))

if __name__ == "__main__":
    main()


### FIXED CODE ###

import fractions

def main():
    A, B = list(map(int, input().split()))
    print(lcm(A, B))

def lcm(a, b):
    return a * b // fractions.gcd(a, b)

if __name__ == "__main__":
    main()
import math

n = int(input())
a = list(map(int, input().split()))
cnt = 0
for i in range(n):
  for j in range(i+1, n):
    cnt += math.sqrt((a[i][0] - a[j][0]) ** 2 + (a[i][1] - a[j][1]) ** 2)
print(cnt * 2 / n)

### FIXED CODE ###

import math

n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
cnt = 0
for i in range(n):
  for j in range(i+1, n):
    cnt += math.sqrt((a[i][0] - a[j][0]) ** 2 + (a[i][1] - a[j][1]) ** 2)
print(cnt * 2 / n)
s = input()
flag = False
for i in range(len(s)):
    if s[i] == "C":
        flag = True
        break


if flag:
    flag = False
    for j in range(len(s)-1, -1, -1):
        if s[j] == "F":
            flag = True
            break

print("Yes" if i < j and flag else "No")

### FIXED CODE ###

s = input()
flag = False
for i in range(len(s)):
    if s[i] == "C":
        flag = True
        break


if flag:
    flag = False
    for j in range(len(s)-1, -1, -1):
        if s[j] == "F":
            flag = True
            break

print("Yes" if (flag and i < j) else "No")
K = int(input())
A = int(input())
B = int(input())
""" K=4
A=5
B=7 """
q=0


for i in range(1,1000):
    if A <= i*K & i*K <= B:
        print("OK")
        q=1
        break

if q == 1:
    print("NG")




### FIXED CODE ###

k=int(input())
a,b= map(int, input().split())
q=0
 
for i in range(1,1000):
  if a<=k*i and k*i<=b:
    print('OK')
    q=1
    break
 
if q==0:
  print('NG')
s = input()
left = 0
right = len(s) - 1
x_left = 0
x_right = 0
if len(s) >= 2:
    while (left <= right):
        if s[left] == s[right]:
            left += 1
            right -= 1
        elif s[left] == "x":
            x_left += 1
            left += 1
        elif s[right] == "x":
            x_right += 1
            right -= 1
        if (right - left == 1) & (s[left] != s[right]):
            if (s[left] != "x") & (s[right] != "x"):
                print(-1)
                exit()
    print(x_left + x_right)
else:
    print(0)

### FIXED CODE ###

s = input()
left = 0
right = len(s) - 1
x_left = 0
x_right = 0
if len(s) >= 2:
    while (left <= right):
        if s[left] == s[right]:
            left += 1
            right -= 1
        elif s[left] == "x":
            x_left += 1
            left += 1
        elif s[right] == "x":
            x_right += 1
            right -= 1
        else:
            print(-1)
            exit()
    print(x_left + x_right)
else:
    print(0)
def main():
    n = int(input())
    bit = input()[::-1]
    count = bit.count("1")
    count_plus = count+1
    count_minus = count-1
    pow_plus = [1 % count_plus]
    pow_minus = [1 % count_minus]
    for i in range(n):
        pow_plus.append(pow_plus[-1]*2 % count_plus)
    for i in range(n):
        pow_minus.append(pow_minus[-1]*2 % count_minus)

    bit_plus = 0
    bit_minus = 0

    for i in range(n):
        if bit[i] == "1":
            bit_plus = (bit_plus+pow_plus[i]) % count_plus
    for i in range(n):
        if bit[i] == "1":
            bit_minus = (bit_minus+pow_minus[i]) % count_minus
    ans = []
    for i in range(n):
        if bit[i] == "1":
            bit_ans = (bit_minus-pow_minus[i]) % count_minus
            count = count_minus
            if count_minus == 0:
                ans.append(0)
                continue
        else:
            bit_ans = (bit_plus+pow_plus[i]) % count_plus
            count = count_plus
        cnt = 1
        while bit_ans:
            b = str(bin(bit_ans)).count("1")
            bit_ans = bit_ans % b
            cnt += 1
        ans.append(cnt)
    for i in ans[::-1]:
        print(i)


main()

### FIXED CODE ###

def main():
    n = int(input())
    bit = input()[::-1]
    count = bit.count("1")
    count_plus = count+1
    count_minus = count-1
    pow_plus = [1 % count_plus]
    for i in range(n):
        pow_plus.append(pow_plus[-1]*2 % count_plus)
    if count_minus != 0:
        pow_minus = [1 % count_minus]
        for i in range(n):
            pow_minus.append(pow_minus[-1]*2 % count_minus)
    else:
        pow_minus = []

    bit_plus = 0
    bit_minus = 0

    for i in range(n):
        if bit[i] == "1":
            bit_plus = (bit_plus+pow_plus[i]) % count_plus
    if count_minus != 0:
        for i in range(n):
            if bit[i] == "1":
                bit_minus = (bit_minus+pow_minus[i]) % count_minus
    ans = []
    for i in range(n):
        if bit[i] == "1":
            if count_minus == 0:
                ans.append(0)
                continue
            bit_ans = (bit_minus-pow_minus[i]) % count_minus
            count = count_minus
        else:
            bit_ans = (bit_plus+pow_plus[i]) % count_plus
            count = count_plus
        cnt = 1
        while bit_ans:
            b = str(bin(bit_ans)).count("1")
            bit_ans = bit_ans % b
            cnt += 1
        ans.append(cnt)
    for i in ans[::-1]:
        print(i)


main()
n,m=map(int,input().split())
nums=[int(input()) for i in range(n)]
nums.sort(reverse=True)
changers=[list(map(int,input().split())) for i in range(m)]
changers.sort(key=lambda x: x[1])
ans=0
for i in range(n):
  ans+=max(nums[-i],changers[-i])
print(ans)


### FIXED CODE ###

n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
changer=[]
cl=0
flag=0
for i in range(m):
  b=list(map(int,input().split()))
  changer.append(b)
changer.sort(key=lambda x:x[1],reverse=True)
for i in range(m):
  if flag==1:
    break
  for j in range(cl,min(cl+changer[i][0],n)):
    if a[j]<changer[i][1]:
      a[j]=changer[i][1]
    else:
      flag=1
      break
  cl+=changer[i][0]
print(sum(a))
n = int(input())
t,a = [],[]
for i in range(n):
    tmp = [int(i) for i in input().split()]
    t.append(tmp[0])
    a.append(tmp[1])

p,q = 0,0
for x,y in t,a:
    tmp = max(p//x,q//y)
    p = x*tmp 
    q = y*tmp
print(p+q)  

### FIXED CODE ###

n = int(input())
t,a = [],[]
for i in range(n):
    tmp = [int(i) for i in input().split()]
    t.append(tmp[0])
    a.append(tmp[1])

p,q = 1,1
for i in range(n):
    tmp = max(-(-p//t[i]),-(-q//a[i]))
    p = t[i]*tmp 
    q = a[i]*tmp
print(p+q)
s = input()
t = input()

ss = list(s)
tt = list(input())

ss.sort()
tt.sort(reverse=True)

s1 = ''.join(ss)
t1 = ''.join(tt)

if s1 < t1:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

s = input()
t = input()

ss = list(s)
tt = list(t)

ss.sort()
tt.sort(reverse=True)

s1 = ''.join(ss)
t1 = ''.join(tt)

if s1 < t1:
    print('Yes')
else:
    print('No')