Harryxun/stf_run huggingface dataset:
a,b,c=(int(x) for x in input().split())
7_count=0
5_count=0
def check(x):
	if x==5:
		global 5_count
        5_count+=1
	elif x==7:
 	    global 7_count
		7_count+=1
check(a)
check(b)
check(c)
if 7_count=1 and 5_count=2:
  print("YES")
else:
  print("NO")


### FIXED CODE ###

a,b,c=(int(x) for x in input().split())
nana_count=0
go_count=0
def check(x):
  if x==5:
      global go_count
      go_count+=1
  elif x==7:
      global nana_count
      nana_count+=1
check(a)
check(b)
check(c)
if nana_count==1 and go_count==2:
  print("YES")
else:
  print("NO")
import sys
input = sys.stdin.readline
cheak = 10**18
match = 0

def make_divisors(n):
    divisors = []
    ans = 1
    i_box = []
    for i in range(1, int(n**0.5)+1):
        if n%i == 0:
            i_box.append(i)
            ans *= i
            if ans >= int(n**0.5):
                for i in range(len(i_box)):
                    for j in range(len(i_box)):
                        cheak = ans // i_box[j]
                        if cheak < 10**9 and n//cheak < 10**9:
                            match = 1
                            break
                        cheak = ans
                    if match == 1:
                        break
                divisors.append(cheak)
                divisors.append(n//cheak)
                break
    return divisors

s = int(input())
if s%2 == 0:
    s_1 = make_divisors(s)
    x_2 = 0
    y_1 = 0
else:
    s_1 = make_divisors(s+1)
    x_2 = 1
    y_1 = 1
x_1 = s_1[0]
y_2 = s_1[1]
x_3 = 0
y_3 = 0
print(str(x_1), str(y_1), str(x_2), str(y_2), str(x_3), str(y_3))

### FIXED CODE ###

import sys
import math
input = sys.stdin.readline

s = int(input())
if s == 10**18:
    print(0, 0, 0, 10**9, 10**9, 0)
    sys.exit()
t = math.floor(math.sqrt(s))
if t*(t+1) < s:
    x1 = t+1
    y2 = t+1
else:
    x1 = t
    y2 = t+1
x2 = 1
y1 = x1*y2 - s

print(0, 0, x1, y1, x2, y2)
x= input()
a = int(x[0])
b = int(x[2])
print(a*b)end
print(a*2+b*2)

### FIXED CODE ###

x=input().split()
a = int(x[0])
b = int(x[1])

print( a*b , a*2+b*2 )
a, b, c = map(int, input().split())
if a + b = c or b + c = a or c + a = b:
    print('Yes')
else:
    prtnt('No')


### FIXED CODE ###

a, b, c = map(int, input().split())
if a + b == c or b + c == a or c + a == b:
    print('Yes')
else:
    print('No')
import sys
sys.setrecursionlimit(2000)

a=open(0)
N,_,*a = map(int, a.read().split())

dp = [-1 for _ in range(150000)]
dp[0] = 0
def rec(i):
    if dp[i] >= 0:
        return dp[i]
    if i in a:
        dp[i] = 0
        return 0
    if i<3:
        dp[i] = rec(i-1) + 1
        return dp[i]
    dp[i] = (rec(i-1)+rec(i-2))%1000000007
    return dp[i]
    
print(rec(N))




### FIXED CODE ###

import sys

sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 1000000007

a=open(0)
N,_,*a = map(int, a.read().split())

dp = [-1 for _ in range(100010)]
dp[0] = 0
for i in a: dp[i] = 0
def rec(i):
    if dp[i] > -1:
        return dp[i]
    if i<3:
        dp[i] = rec(i-1) + 1
        return dp[i]
    dp[i] = (rec(i-1)+rec(i-2))%MOD
    return dp[i]
    
print(rec(N))
N,M = map(int,input().split())
note = [[0]*M for i in range(N)]
visited = [False]*N
ans = 0
for i in range(M):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    note[a][b] = 1
    note[b][a] = 1

def dfs(p = 0):
    True_count = 0
    False_count = 0
    for f in visited:
        if f is True:
            True_count += 1
        elif f is False:
            False_count += 1
    if True_count == N-1 and False_count == 1:
        global ans 
        ans += 1
        return
    visited[p] = True
    for i in range(N):
        if note[p][i] == 1 and visited[i] is False:
            dfs(i)

dfs()
print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)
N,M = map(int,input().split())
note = [[0]*N for i in range(N)]
visited = [False]*N
visited[0] = True
ans = 0
for i in range(M):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    note[a][b] = 1
    note[b][a] = 1

def dfs(p=0, depth=0):
    if depth == N-1:
        global ans
        ans += 1
        return
    for i in range(N):
        if note[p][i] == 1 and visited[i] is False:
            visited[i] = True
            dfs(i,depth+1)
            visited[i] = False

dfs()
print(ans)
from math import pi
r = int(input())
print("{0:.6f} {1:.6f}".format(float(r*r*pi), float(2*r*pi)))

### FIXED CODE ###

from math import pi
r = float(input())
print("{0:.6f} {1:.6f}".format(float(r*r*pi), float(2*r*pi)))
z=input().split()
return z[:-8]

### FIXED CODE ###

z=input()
print(z[:-8])
# coding: utf-8

# In[17]:

N = int(input())
A = list(map(int, input().split()))


# In[21]:

import copy
import numpy as np


# In[6]:

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)


# In[26]:

gcd_list = []
for i in range(N):
    Ac = copy.copy(A)
    Ac.pop(i)
    #print(Ac)
    gcd_list.append(gcd(*Ac))


# In[ ]:

print(np.max(np.array(gcd_list)))



### FIXED CODE ###


# coding: utf-8

# In[1]:

N = int(input())
A = list(map(int, input().split()))


# In[2]:

#import copy
#import numpy as np
try:
    from fractions import gcd
except:
    from math import gcd


# In[ ]:

# 左からn個の最大公約数を求める O(n)
# 右からn個の最大公約数を求める O(n)
# n個目を抜いた最大公約数は n-1個目までの公約数とn+1個目からの公約数との公約数


# In[3]:

lg = [1]*(N)
rg = [1]*(N)
ans = 0


# In[4]:

#print(lg)
#print(rg)
#print(A)


# In[5]:

lg[0] = A[1]
rg[0] = A[N-2]
lg[1] = A[0]
rg[1] = A[N-1]
#print(lg, rg)
for i in range(1, N-1):
    #print(i)
    lg[i+1] = gcd(lg[i], A[i])
    #print(lg[i], A[i])
    rg[i+1] = gcd(rg[i], A[N-1-i])
    #print(rg[N-1-i], A[N-1-i])
#print(lg, rg)

for i in range(N):
    #print(i, lg[i], rg[N-i-1])
    tmp = gcd(lg[i], rg[N-i-1])
    #print(tmp)
    if ans < tmp:
        ans = tmp
    #print(ans)


# In[6]:

print(ans)


# In[ ]:

"""
[42 54 69 92 12 23]のとき
 1 [54 69 92 12 23]の最大公約数
 2 [42 69 92 12 23]
 3 [42 54 92 12 23]
 4 [42 54 69 12 23]

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

for i in range(min(N,K):
    if S[i] != "1":
        print(S[i])
        quit()

print(1)

### FIXED CODE ###

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

for i in range(min(N,len(S))):
    if S[i] != "1":
        print(S[i])
        quit()

print(1)
n = input()
  n_max = -1000000000
  n_min = input()

  for i in range(0, n-1):
   R = input()
   if n_max < R - n_min:
    n_max = R - n_min
   if R < n_min:
    n_min = R

  print n_max

### FIXED CODE ###

n = int(raw_input())
minv = int(raw_input())
maxv = -1*10**9
  
for j in range(n-1):
  nums = int(raw_input())  
  diff = nums - minv
  if maxv < diff:
    maxv = diff
  if nums < minv:
    minv = nums
  
print maxv
x,y = map(int,input().split())
if (x + y) % == 0:
  print((x+y)/2)
else:
  print((x+y+1)/2)

### FIXED CODE ###

a, b = map(int, input().split())
x = (a + b)
xx = -(-x // 2)
print(xx)
cal = {"SUN":0,"MON":1,"TUE":2,"WEN":3,"THU":4,"FRI":5,"SAT":6}
S = input()
print(7-cal[S])

### FIXED CODE ###

cal = {"SUN":0,"MON":1,"TUE":2,"WED":3,"THU":4,"FRI":5,"SAT":6}
S = input()
print(7-cal[S])
S=int(input())

a=S/100
b=S%100

if((a>12 or a==0) and 1<=b<=12):
        print("YYMM")

elif(1<=a<=12 and (b>12 or b==0)):
        print("MMYY")

elif(1<=a<=12 and 1<=b<=12):
        print('AMBIGUOUS')

else:
    print("NA")


### FIXED CODE ###

N,K=(int(i) for i in input().split())
s=input()
S=list(s)

if(S[K-1]=='A'):
    S[K-1]='a'
elif(S[K-1]=='B'):
    S[K-1]='b'
elif(S[K-1]=='C'):
    S[K-1]='c'

A=''.join(S)
print(A)
# たこふぇす
n = int(input())
d = [int(i) for i in input().split()]

ans = 0
for i in range(n):
    x = d[i]
    for y in d[i+1:]:
        ans += x*y
print(ans

### FIXED CODE ###

# たこふぇす
n = int(input())
d = [int(i) for i in input().split()]

ans = 0
for i in range(n):
    x = d[i]
    for y in d[i+1:]:
        ans += x*y
print(ans)
a = list(map(int,input().split()))
b = 0
f a[0]==a[1]:
    if a[1] == a[2]:
        print("No")
        b=1
if b==0:
    print("Yes")

### FIXED CODE ###

a = list(map(int,input().split()))
b = 0
if a[0]==a[1] and a[1]==a[2]:
    print("No")
elif a[0]!=a[1] and a[1]!=a[2] and a[0]!=a[2]:
    print("No")
else:
    print("Yes")
w=input()
w1=input()
num=len(w)
num1=len(w1)
if num<num1:
  b=False
for i in range(num-num1+1):
  b=True
  for j in range(num1):
    if w[i+j]=="?" or w[i+j]==w1[j]:
      pass
    else:
      b=False
  if b:
      start=i
      break
if not b:
  print("UNRESTORABLE")
else:
  word=""
  if start!=0:
    for i in range(start):
      if w[i]=="?":
        word+="a"
      else:
        word+=w[i]
    for i in range(start,num):
      word+=w1[i-start]
  else:
    word+=w1
    for i in range(num1,num):
      if w[num]=="?":
        word+="a"
      else:
        word+=w[num]
  print(word)

### FIXED CODE ###

w=input()
w1=input()
num=len(w)
num1=len(w1)
start=-1
if num<num1:
  b1=False
for i in range(num-num1+1):
  b=True
  for j in range(num1):
    if w[i+j]=="?" or w[i+j]==w1[j]:
      pass
    else:
      b=False
  if b:
      start=i
if start==-1:
  print("UNRESTORABLE")
else:
  word=""
  for i in range(num):
    if i<start:
      if w[i]=="?":
        word+="a"
      else:
        word+=w[i]
    elif start<=i and i<=start+num1-1:
      word+=w1[i-start]
    else:
      if w[i]=="?":
        word+="a"
      else:
        word+=w[i]
  print(word)
S, T= input().split()

num = 0
for ind, s in enumerate(S):
    if  S[ind] != T[ind]:
        num = num + 1
print(num)

### FIXED CODE ###

S = input()
T = input()

num = 0
for ind, s in enumerate(S):
    if  S[ind] != T[ind]:
        num = num + 1
print(num)
jkl;

### FIXED CODE ###

#!/usr/bin/env python3
import sys
try: from typing import Any, Union, List, Tuple, Dict
except ImportError: pass
def debug(*args): print(*args, file=sys.stderr)
def exit(): sys.exit(0)


s = input()
K = int(input())
n = len(s)


def code(s):
    return ord(s)-97

def char(c):
    c = c % 26
    return chr(c+97)


# ans = ""
ans_list = []
for p in range(n):
    c = code(s[p])
    if c == 0:
        # ans += "a"
        ans_list.append("a")
        continue
    if 26-c > K:
        # ans += s[p]
        ans_list.append(s[p])
        continue
    # ans += "a"
    ans_list.append("a")
    K -= 26-c
ans = "".join(ans_list)
ans = ans[:-1] + char(code(ans[-1])+K)

print(ans)
class UnionFind():
    def __init__(self,n):
        self.parents = [-1]*n

    def find(self,x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x,y = y,x
            
        self.parents[x] += self.parents[y]
        self.parents[y] = x
        
N,M = map(int,input().split())    
uf = UnionFind(N)

for i in range(M):
    A,B = map(int,input().split())
    uf.union(A,B)
    #print(uf.parents)

print(abs(min(uf.parents)))

### FIXED CODE ###

class UnionFind():
    def __init__(self,n):
        self.parents = [-1]*n

    def find(self,x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x,y = y,x
            
        self.parents[x] += self.parents[y]
        self.parents[y] = x
        
N,M = map(int,input().split())    
uf = UnionFind(N)

for i in range(M):
    A,B = map(lambda x:int(x)-1,input().split())
    uf.union(A,B)
    #print(uf.parents)

print(abs(min(uf.parents)))
N=int(input())
List='a b c d e f g h i j k l m n o p q r s t u v d x y z'.split()
print(List)

Ans=''

while N>=1:
    Amari=N%26
    
    if Amari==0:
        Ans='z'+Ans
    else:
        Ans=List[Amari-1]+Ans
        
    N=(N-1)//26
    
print(Ans)

### FIXED CODE ###

a=input()
if a.islower():
    print('a')
else:
    print('A')
from math import gcd
T = int(input())
for _ in range(T):
    A,B,C,D = map(int,input().split())
    if A < B or D < B:
        print('No')
    else:
        g = gcd(B,D)
        k = B//g
        r = (A-C)%B
        if r == 0:
            sm = C
        else:
            sm = C+r-B
        if sm < 0:
            print('No')
        else:
            s = sm%g
            if s + (k-1)*g <= C:
                print('Yes')
            else:
                print('No')

### FIXED CODE ###

def gcd(a, b):
    if a < b:
        a,b = b,a
    while b:
        a, b = b, a % b
    return a
T = int(input())
for _ in range(T):
    A,B,C,D = map(int,input().split())
    if A < B or D < B:
        print('No')
    else:
        g = gcd(B,D)
        k = B//g
        r = (A-C)%B
        if r == 0:
            sm = C
        else:
            sm = C+r-B
        if sm < 0:
            print('No')
        else:
            s = sm%g
            if s + (k-1)*g <= C:
                print('Yes')
            else:
                print('No')
A,B,C,D = map(int,input())

print(max(A*B,C*D))

### FIXED CODE ###

A,B,C,D = map(int,input().split())

print(max(A*B,C*D))
s = input()

if 0 < int(s[0:2]) <= 12 and 0 < int(s[2:4]) <= 12 :
  print("AMBIGUOUS")
elif (12 < int(s[0:2]) or int(s[0:2]) == 0) and  0 < int(s[2:4]) <= 12:
  print("YYMM")
elif 0 < int(s[0:2]) <= 12 and (12 < int(s[2:4] or int(s[2:4]) == 0):
  print("MMYY")
else:
  print("NA")

### FIXED CODE ###

s = input()

if 0 < int(s[0:2]) <= 12 and 0 < int(s[2:4]) <= 12 :
  print("AMBIGUOUS")
elif (12 < int(s[0:2]) or int(s[0:2]) == 0) and  0 < int(s[2:4]) <= 12:
  print("YYMM")
elif 0 < int(s[0:2]) <= 12 and (12 < int(s[2:4]) or int(s[2:4]) == 0):
  print("MMYY")
else:
  print("NA")
n=int(input())
w=list(map(int,input().split()))
x=0
for i in range(n):
  s=abs(sum(w(0,i+1))-sum(w(i+1,n+1)))
  if x==0 or x<s:
    x=s
print(x)


### FIXED CODE ###

from itertools import accumulate
n=int(input())
w=list(map(int,input().split()))
w=list(accumulate(w))
for i in range(n):
  if w[i]*2==w[-1]:
    print(0)
    break
  elif w[i]*2>w[-1]:
    print(min((w[i]*2-w[-1]),(w[-1]-w[i-1]*2)))
    break
X,Y,Z,K = (int(num) for num in input().split())
a = [int(num) for num in input().split()]
b = [int(num) for num in input().split()]
c = [int(num) for num in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

l = []
for i in range(X):
    if i+1 > K:
        break
    
    for j in range(Y):
        if (i+1) + (j+1) > K:
            break
        
        for k in range(Z):
            if (i+1) + (j+1) + (k+1) > K:
                break
            
            l.append(a[i]+b[j]+c[k])
            
            
l.sort(reverse=True)
for i in range(K):
    print(l[i])

### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if e-a > k:
    print(":(")
else:
    print("Yay!")
import itertools

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

candidate = list(range(a, b+1, 1))
if n == 1:
    if a == b:
        print(1)
    else:
        print(0)
elif n == 2:
    print(1)
elif n >= 3:

    smin = a * n + (b-a)
    smax = b * n - (b-a)
    sl = list(range(smin, smax+1, 1))
    print(len(sl))

### FIXED CODE ###

import itertools

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

if n == 1:
    if a == b:
        print(1)
    else:
        print(0)
elif n == 2:
    print(1)
elif n >= 3:
    if a > b:
        print(0)
    else:
        smin = a * n + (b-a)
        smax = b * n - (b-a)
        print(smax-smin+1)
N,A = map(int, input().split())
if N%500< A:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

N = int(input())
A = int(input())

if N%500 <= A:
    print("Yes")
else:
    print("No")
def ext_gcd(p, a):
  #require a, m be relative prime
  #m > a  
  if a == 0:
    return 1, 0
  else:
    x1, y1 = ext_gcd(a, p%a)
    y = x1 - y1 * int(p/a)
    x = y1
    return x, y

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

n = (-1/3)*x + (2/3)*y
m = (-1/3)*y + (2/3)*x

if n != int(n) or m != int(m) or n<0 or m<0:
  ans = 0
else:
   n = int(n)
   m = int(m)
   if n < m :
      m = c
      m = n
      n = c
   # (n+m!)/(n!)(m!) mod (1e9+7)
   ans = 1
   prime = 1000000007 
   for i in range(n+1,m+n+1):
        ans = int(ans * i) 
        ans = (ans % prime)
   for i in range(1, m+1):
      ori_inv = int(ext_gcd(prime, i)[1])
      while ori_inv < 0 :
        ori_inv += prime
      ans = int(ans * ori_inv)  
      ans = (ans % prime)
print(ans)

### FIXED CODE ###

def ext_gcd(p, a):
  #require a, m be relative prime
  #m > a  
  if a == 0:
    return 1, 0
  else:
    x1, y1 = ext_gcd(a, p%a)
    y = x1 - y1 * int(p/a)
    x = y1
    return x, y

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

n = (2 * y - x)/3
m = (2 * x - y)/3

if n != int(n) or m != int(m) or n<0 or m<0:
  ans = 0
else:
   n = int(n)
   m = int(m)
   if n < m :
      c = m
      m = n
      n = c
   # (n+m!)/(n!)(m!) mod (1e9+7)
   ans = 1
   prime = 1000000007 
   for i in range(n+1,m+n+1):
        ans = int(ans * i) 
        ans = (ans % prime)
   for i in range(1, m+1):
      ori_inv = int(ext_gcd(prime, i)[1])
      while ori_inv < 0 :
        ori_inv += prime
      ans = int(ans * ori_inv)  
      ans = (ans % prime)
print(ans)
s = input()
k = int(input())
cnt = 0
flag = 0
for i in range(len(s)-1):
  if s[i] == s[i+1]:
    cnt += 1
    if i-1 >=0 and s[i-1] == s[i] and flag == 0:
      cnt -= 1
      flag = 1
    else:
      flag = 0
  else:
    flag = 0
tmp = 0
if len(s)%2 and s.count(s[0]) == len(s):
  tmp = k//2
if s[0] == s[-1] and s[0] != s[1] and s[0] != s[-2]:
  tmp += k-1
print(cnt*k + tmp)

### FIXED CODE ###

from itertools import groupby

s = input()
k = int(input())
a = [sum(1 for _ in g) for _, g in groupby(s)]
if len(a) == 1:
  print(len(s) * k // 2)
else:
  ans = sum(x // 2 for x in a) * k
  if s[0] == s[-1] and a[0] & a[-1] & 1:
    ans += k - 1
  print(ans)
x = int(input())
for a in range(x):
 y = map(int,raw_input(),split())
  sort(y[3])


if y[2]**2-y[1]**2 == y[0]**2:
  print "YES"
else:
  print "NO"

### FIXED CODE ###

for i in range(input()):
    q = map(int,raw_input().split())
    q.sort()
    a = "YES" if q[0]**2 + q[1]**2 == q[2]**2 else "NO"
    print a
# -*- coding: utf-8 -*-
"""
Created on Fri Sep  6 16:59:47 2019

@author: ask07
"""

A=int(input("Aの文字数を入力:"))
B=int(input("Bの文字数を入力:"))
C=int(input("Cの文字数を入力:"))

if A==5 and B==5 and C==7:
    print("YES")
elif A==5 and B==7 and C==5:
    print("YES")
elif A==7 and B==5 and C==5:
    print("YES")
else:
    print("NO")




### FIXED CODE ###

a, b, c = map(int, input().split())
if a * b * c == 5 * 7 * 5:
  print("YES")
else:
  print("NO")
N = int(input())
H = input().split()
list = [int(x) for x in H]
 
flg, add = 'Yes', False
for i, l in enumerate(list):
  if i == len(list): break
  if add: l = l - 1
  if l > list[i + 1]:
    flg = 'No'
    break
  elif l - 1 == list[i + 1]:
    add = True
  elif l - 1 > list[i + 1]:
    flg = 'No'
    break
  else:
    add = False
 
print(flg)

### FIXED CODE ###

N = int(input())
H = input().split()
list = [int(x) for x in H]
 
flg, add = 'Yes', False
for i, l in enumerate(list):
  if i + 1 == len(list):
    break
  if add: l = l + 1 
  if l - 1 > list[i + 1] and l < list[i + 1]:
    flg = 'No'
    break
  elif l - 1 == list[i + 1]:
    add = True
  elif l > list[i + 1]:
    flg = 'No'
    break
  else:
    add = False
 
print(flg)
x=int(input())
print(str(int(x/3600))+":"+str((x-h*3600)/60)+":"+str((x-h*3600)%60))

### FIXED CODE ###

x = int(input())
h = int(x/3600)
m = int((x - h*3600)/60)
s = int((x - h*3600)%60)
print(str(h)+":"+str(m)+":"+str(s))
import numpy as np
from scipy.spatial.distance import cityblock
B = []

H,W = map(int,input().split())
for row in range(H):
    Inputs = input().split()
    for column in [i for i, x in enumerate(Inputs) if x == '#']:
        B.append((column,row))
OO = [cityblock((0,0),b) for b in B]
OI = [cityblock((0,W-1),b) for b in B]
IO = [cityblock((H-1,0),b) for b in B]
II = [cityblock((H-1,W-1),b) for b in B]
print(min(min(OO),min(OI),min(IO),min(II)))

### FIXED CODE ###

# -*- coding: utf-8 -*-
h, w = map(int, input().split())
a = []
a = [[True] * (w + 2)]
for i in range(h):
    a.append([True] + [x == '#' for x in input()] + [True])
a.append([True] * (w + 2))
q = []

for i in range(1, h + 1):
    for j in range(1, w + 1):
        if a[i][j]:
            q.append((i, j))

count = 0
while True:
    qq = []
    for i, j in q:
        if not a[i-1][j]:
            a[i-1][j] = True
            qq.append((i - 1, j))
        if not a[i+1][j]:
            a[i+1][j] = True
            qq.append((i + 1, j))
        if not a[i][j-1]:
            a[i][j-1] = True
            qq.append((i, j - 1))
        if not a[i][j+1]:
            a[i][j+1] = True
            qq.append((i, j + 1))
    q = qq
    if len(q) <= 0:
        break
    count += 1

print(count)
import math 
 
h=int(input())
x =math.floor(math.log2(h))
print( sum([2**y for y in range(x+1)]))

### FIXED CODE ###

import math 
 
h=int(input())
x =math.floor(math.log(h,2))
print( sum([2**y for y in range(x+1)]))
import numpy as np
from collections import deque

@np.vectorize
def trans(s):
    return 1 if s == "#" else 0

def parse(inp):
    H, W = map(int, next(inp).split())
    return np.array([trans([w for w in next(inp).strip()]) for _ in range(H)])

def search(S, start, C):
    Q = deque([start])
    H, W = S.shape
    n0 = 0
    n1 = 0
    while Q:
        i, j = Q.popleft()
        if C[i, j] != 0:
            continue
        else:
            C[i, j] = 1
            if S[i, j] == 0:
                n0 += 1
            else:
                n1 += 1
        if i + 1 < H and C[i+1, j] == 0 and S[i, j] != S[i+1, j]:
            Q.append((i + 1, j))
        if i > 0 and C[i-1, j] == 0 and S[i, j] != S[i-1, j]:
            Q.append((i - 1, j))
        if j + 1 < W and C[i, j+1] == 0 and S[i, j] != S[i, j+1]:
            Q.append((i, j + 1))
        if j > 0 and C[i, j-1] == 0 and S[i, j] != S[i, j-1]:
            Q.append((i, j - 1))
    return n0, n1


def search_all(S):
    C = np.full_like(S, 0)
    D = np.full_like(S, 0)
    ret = 0
    for i in range(S.shape[0]):
        for j in range(S.shape[1]):
            if D[i, j] == 0:
                n0, n1 = search(S, (i, j), C)
                D += C
                ret += n1 * n0
                if np.all(D):
                    return ret
                else:
                    C[:, :] = 0

    
print(search_all(parse(sys.stdin)))

### FIXED CODE ###


import numpy as np
from collections import deque
import sys

def parse(inp):
    H, W = map(int, next(inp).split())
    return np.array([list(next(inp).strip()) for _ in range(H)])

dis = [0, 0, 1, -1]
djs = [1, -1, 0, 0]

def search(S, i, j, Q, R):
    H, W = S.shape
    R[i, j] = True
    Q.append((i, j))
    n0 = 0
    n1 = 0
    while Q:
        i, j = Q.popleft()
        if S[i, j] == "#":
            n1 += 1
        else:
            n0 += 1
        gen = ((i + di, j + dj) for di, dj in zip(dis, djs))
        ijs = (g for g in gen if 0 <= g[0] and g[0] < H and 0 <= g[1] and g[1] < W)
        for ni, nj in ijs:
            if not R[ni, nj] and S[ni, nj] != S[i, j]:
                R[ni, nj] = True
                Q.append((ni, nj))
    return n0 * n1


def test(S):
    i, j = 0, 0
    Q = deque()
    R = np.full(S.shape, False)
    H, W = S.shape
    n = 0
    for i in range(H):
        for j in range(W):
            if not R[i, j]:
                n += search(S, i, j, Q, R)
    return n

print(test(parse(sys.stdin)))