Harryxun/stf_run huggingface dataset:
import sys

def main():
    n = input()
    a = input().split()
    n = int(n)
    a = list(map(int, a))


    lst = [0]* 20
    dup = 0
    ans =0

    for i in a:
        lst[i]+=1

    for i in lst:
        if i >0:
            ans+= 1
        if i > 1:
            dup = dup + i - 1

    if dup % 2 == 0:
        print(ans)
    else:
        print(ans-1)

if __name__ == "__main__":
        main()


### FIXED CODE ###

import sys

def main():
    n = input()
    a = input().split()
    n = int(n)
    a = list(map(int, a))


    lst = [0]* 1000000
    dup = 0
    ans =0

    for i in a:
        lst[i]+=1

    for i in lst:
        if i >0:
            ans+= 1
        if i > 1:
            dup = dup + i - 1

    if dup % 2 == 0:
        print(ans)
    else:
        print(ans-1)

if __name__ == "__main__":
        main()
s=input()

if (s[3]==s[4] and s[5]==s[6]):
	print("yes")
	else:
    print("no")


### FIXED CODE ###

s = input()

if((s[2]==s[3]) and (s[4]==s[5])):
  	print("Yes")
else:
	print("No")
import math
n=int(input())
p = []
for i in range(1,10**1000):
    if n / 26 <1:
        p = [chr(n + 96)]
        break
    if n / (26**i) >=1:
        if n%(26**i) ==0:
            p.append(chr(26+96))
        else:
            p.append(chr(n%(26**i)+96))
    else:
        if n%(26**i) ==0:
            p.append(chr(26+96))
            break
        else:
            p.append(chr(round(n/26)+96))
            break
p.reverse()
print("".join(p))



### 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])
A, B, C, K = map(int, input().split())
if (A>=K):
  print(K)
else if (A+B>=K):
  print(A)
else:
  print(A-(K-A-B))

### FIXED CODE ###

A, B, C, K = map(int, input().split())
if (A>=K):
  print(K)
if (A<K and A+B>=K):
  print(A)
if (A<K and A+B<K and A+B+C>=K):
  print(A-(K-A-B))
s=int(input())
import math
from scipy.special import comb
ketamax=int(math.floor(s/3))


waru=pow(10,9)+7
ans=0
for i in range(1,ketamax+1):
  nokori=s-3*i
  kazu=comb(nokori+i-1,i-1)%waru
  ans=(ans+kazu)%waru


answer=int(ans%waru)
print(answer)

### FIXED CODE ###

s=int(input())
import math
ketamax=int(math.floor(s/3))

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

waru=pow(10,9)+7
ans=0
for i in range(1,ketamax+1):
  nokori=s-3*i
  kazu=cmb(nokori+i-1,i-1)%waru
  ans=(ans+kazu)%waru


answer=int(ans%waru)
print(answer)
N=int(input())
A=int(input()).split()
c=0
for i in A:
  c+=reciprocal(A[i])
print(reciprocal(c))


### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
c=[1/i for i in A]
print(1/sum(c))
x=input().split("")

if x[0]==9 or x[1]==9:
  print("Yes")
else:
  ("No")

### FIXED CODE ###

x=input()

if x[0]=="9" or x[1]=="9":
  print("Yes")
else:
  print("No")
s = input().split(" ")
n = int(s[0])
k = int(s[1])
sp = input().split(" ")
p = [int(pstr) for pstr in sp]

num = 1

for i in range(k - 1):
  if p[i] > p[i + 1]:
    num += 1
    break
#print(num)    
for i in range(n - k):
  if p[i] > p[i + 1] or p[i + k] > p[i + k +1]:
    num += 1
   # print("y")
  else:
    #print("no")
print(num)

### FIXED CODE ###

class MinSlideWindow:
    def __init__(self,p):
        self.pos_list = []
        self.val_list = p
        self.start_idx = 0

    def put(self,pos):
        val = self.val_list[pos]

        while len(self.pos_list) > self.start_idx:
            pos1 = self.pos_list[-1]
            val1 = self.val_list[pos1]
            if val1 >= val:
                del self.pos_list[-1]
            else:
                break
        self.pos_list.append(pos)

    def get(self,pos):
        while len(self.pos_list) > self.start_idx:
            pos1 = self.pos_list[self.start_idx]
            if pos1 <= pos:
                self.start_idx += 1
            else:
                break

    def min(self):
        pos1 = self.pos_list[self.start_idx]
        val1 = self.val_list[pos1]
        return val1

class MaxSlideWindow:
    def __init__(self,p):
        self.pos_list = []
        self.val_list = p
        self.start_idx = 0
        
    def put(self,pos):
        val = self.val_list[pos]

        while len(self.pos_list) > self.start_idx:
            pos1 = self.pos_list[-1]
            val1 = self.val_list[pos1]
            if val1 <= val:
                del self.pos_list[-1]
            else:
                break
        self.pos_list.append(pos)

    def get(self,pos):
        while len(self.pos_list) > self.start_idx:
            pos1 = self.pos_list[self.start_idx]
            if pos1 <= pos:
                del self.pos_list[self.start_idx]
            else:
                break

    def max(self):
        pos1 = self.pos_list[self.start_idx]
        val1 = self.val_list[pos1]
        return val1




s = input().split(" ")
n = int(s[0])
k = int(s[1])
sp = input().split(" ")
p = [int(pstr) for pstr in sp]
num = 1
ident = True
rv_pos = -1

minw = MinSlideWindow(p)
maxw = MaxSlideWindow(p)

for i in range(k - 1):
    if p[i] > p[i + 1]:
        rv_pos = i
        ident = False
    
for i in range(k-1):
    minw.put(i)
    maxw.put(i)

for i in range(1,n - k + 1):
    
    maxw.put(i + k - 2)
    minw.put(i + k - 2)
    maxw.get(i-1)
    minw.get(i-1)

    """    
    for j in range(k - 1):
        if p[i + j] > p[i + j +1]:
            break
    else:
        if not ident:
            ident = True
            num += 1
        continue
    """
    if p[i + k - 2] > p[i + k - 1]:
        rv_pos = i + k - 2
        

    
    if rv_pos < i:
        if not ident:
            ident = True
            num += 1
        continue
            

    if p[i - 1] > minw.min() or p[i + k - 1] < maxw.max():
        num += 1

    
print(num)
from fractions import gcd
a,b,c,d = map(int,input().split())
cab = (b//c)-((a-1)//c)
dab = (b//d)-((a-1)//d)
lcm = int(c*d/gcd(c,d))
cdab = (b//lcm)-((a-1)//lcm)
print((b-a+1)-cab-dad+cdab)

### FIXED CODE ###

from fractions import gcd
A, B, C, D = map(int,input().split())
total = B - A + 1
divC = B//C - (A-1)//C
divD = B//D - (A-1)//D
lcm = int(C * D / gcd(C, D))
divCD = B//lcm - (A-1)//lcm
print(total - divC - divD + divCD)
a=list(map(int,input.split()))
if a.sort==[5,5,7]:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

a=list(map(int,input().split()))
if sorted(a)==[5,5,7]:
  print("YES")
else:
  print("NO")
import math
#import fractions as math
n = int(input())
list1 = list(map(int,input().split()))
a = math.gcd(list1[0],list1[-1])
b = 0
for i in range(0,n):
	if a > math.gcd(a,list1[i]):
		a = math.gcd(a,list1[i])
		b = list1.index(list1[i])
del list1[b]
a = list1[0]
for i in range(0,len(list1)):
	a = min(a,math.gcd(a,list1[i]))
print(a)




### FIXED CODE ###

from collections import deque
import fractions as math
n = int(input())
list1 = list(map(int,input().split()))
list1 = deque(list1)
L = deque([0])
R = deque([0])
M = []

for i in range(len(list1)-1):
	L.append(math.gcd(L[i],list1[i]))
	R.append(math.gcd(R[i],list1[n-i-1]))

for i in range(len(L)):
	M.append(math.gcd(L[i],R[len(R)-i-1]))
print(max(M))
count = int(input())
arr = input().split()
s1 = 0
s2 = 0
for i in arr:
  s2 += int(i)
minimum_diff = s2
for i in range(0, count):
  s1 += arr[i]
  s2 -= arr[i]
  minimum_diff = min(minimum_diff, abs(s1-s2))
  

### FIXED CODE ###

count = int(input())
arr = input().split()
s1 = 0
s2 = 0
for i in arr:
  s2 += int(i)
minimum_diff = s2
for i in range(0, count):
  s1 += int(arr[i])
  s2 -= int(arr[i])
  minimum_diff = min(minimum_diff, abs(s1-s2))
  
print(minimum_diff)
import math
from functools import reduce
from sys import stdin
import itertools

def gcd(*numbers):
    return reduce(math.gcd, numbers)
  
def main:
  N = int(stdin.readline())
  N_list = lsit(range(1, N+1))
  
  ans = 0
  
  for xs in itertools.combinations_with_replacement(N_list, 3):
    if len(set(xs)) == 1:
      ans += 6*gcd(xs[0], xs[1], xs[2])
    elif len(set(xs)) == 2:
      ans += 3*gcd(xs[0], xs[1], xs[2])
    else:
      ans += gcd(xs[0], xs[1], xs[2])
      
  print(ans)

### FIXED CODE ###

import math
from functools import reduce
from sys import stdin
import itertools

def gcd(*numbers):
    return reduce(math.gcd, numbers)
  
def main():
  N = int(stdin.readline())
  N_list = list(range(1, N+1))
  
  ans = 0
  
  for xs in itertools.combinations_with_replacement(N_list, 3):
    if len(set(xs)) == 1:
      ans += gcd(xs[0], xs[1], xs[2])
    elif len(set(xs)) == 2:
      ans += 3*gcd(xs[0], xs[1], xs[2])
    else:
      ans += 6*gcd(xs[0], xs[1], xs[2])
      
  print(ans)

if __name__ == '__main__':
  main()
import sys
import math
input = sys.stdin.readline

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


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


print(lcm(A, B))


### FIXED CODE ###

import sys
import fractions
input = sys.stdin.readline


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


A, B = map(int, input().split())
print(lcm(A, B))
N = int(input())
A = list(map(int,input().split()))
rank = []

for i in range(1,N+1):
    print(A.count(i))


### FIXED CODE ###

R = input()

print( 2 * 3.141 * int(R) )
a

### FIXED CODE ###

K=int(input())
s=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(s[K-1])
import queue

n,m = map(int,input().split())
hen = [[] for i in range(m)]
ans = [0 for i in range(n)]
a,b = 0,0

for i in range(m):
    a,b = map(int,input().split())
    hen[a-1].append(b)
    hen[b-1].append(a)

q = queue.Queue()
q.put(1)

while q.empty() == False:
    head = q.get()
    for h in hen[head-1]:
        if h != 1 and ans[h-1] == 0:
            ans[h-1] = head
            q.put(h)

flag = 0

for i in range(n):
    if i != 0 and ans[i] == 0:
        flag = 1

if flag == 0:
    print('Yes')
    for i in range(n-1):
        print(ans[i+1])
else:
    print('No')


### FIXED CODE ###

import queue

n,m = map(int,input().split())
hen = [[] for i in range(n)]
ans = [0 for i in range(n)]
a,b = 0,0



for i in range(m):
    a,b = map(int,input().split())
    hen[a-1].append(b)
    hen[b-1].append(a)

q = queue.Queue()
q.put(1)

while q.empty() == False:
    head = q.get()
    for h in hen[head-1]:
        if h != 1 and ans[h-1] == 0:
            ans[h-1] = head
            q.put(h)

flag = 0

for i in range(n):
    if i != 0 and ans[i] == 0:
        flag = 1

if flag == 0:
    print('Yes')
    for i in range(n-1):
        print(ans[i+1])
else:
    print('No')
n, h = map(int, input().split())
l = []
for i in range(n):
  l.append(list(map(int,input().spplit())))

l = sorted(l, reverse=True)
c = 0
for i in range(1, n):
  if l[i][1] > l[0][0]:
    h -= l[i][1]
    c += 1
    if h <= 0:
      print(c)
      exit()

while h > l[0][1]:
  h -= l[0][0]
  c += 1

print(c+1)


### FIXED CODE ###

n, h = map(int, input().split())
h2 = h
l = []
for i in range(n):
  l.append(list(map(int,input().split())))

l_b = sorted(l, key=lambda x: x[1])
l = sorted(l_b, reverse=True, key=lambda x: x[0])
c_a = 0
c_b = 0
b_sum = 0

for i in range(n-1, -1, -1):
  if l_b[i][1] >= l[0][0]:
    b_sum += l_b[i][1]
    h -= l_b[i][1]
    c_b += 1
    if h <= 0:
      print(c_b)
      exit()
import math
c_a = math.ceil((h2 - b_sum) / l[0][0])


print(c_a+c_b)
n=input()
li=list(n)
if len(n)==1:
  print(0)
elif len(n)%2==0 and len(n) != 1:
  counta=0 
  countb=0
  a=list("10"*int((int(n)/2)))
  b=list("01"*int((int(n)/2)))
  for i in range(len(n)):
    counta+= abs(int(li[i])-int(a[i]))
    countb+=abs(int(li[i])-int(b[i]))
  print(min(counta,countb))

elif len(n)%2==1 and len(n) != 1:
  countaa=0 
  countbb=0
  aa=list("10"*int(((int(n)-1)/2))+"1")
  bb=list("01"*int(((int(n)-1)/2))+"0")
  for i in range(len(n)):
    countaa+=abs(int(li[i])-int(a[i]))
    countbb+=abs(int(li[i])-int(b[i]))
  print(min(countaa,countbb))

### FIXED CODE ###

n=input()
li=list(n)
if len(n)==1:
  print(0)
elif len(n)%2==0:
  counta=0 
  countb=0
  a=list("10"*int((int(len(n))/2)))
  b=list("01"*int((int(len(n))/2)))
  for i in range(len(n)):
    counta+= abs(int(li[i])-int(a[i]))
    countb+=abs(int(li[i])-int(b[i]))
  print(min(counta,countb))

elif len(n)%2==1 and len(n) != 1:
  countaa=0 
  countbb=0
  aa=list("10"*int(((int(len(n))-1)/2))+"1")
  bb=list("01"*int(((int(len(n))-1)/2))+"0")
  for i in range(len(n)):
    countaa+=abs(int(li[i])-int(aa[i]))
    countbb+=abs(int(li[i])-int(bb[i]))
  print(min(countaa,countbb))
h, w = [int(s) for s in input().split(' ')]
 
s = []
for i in range(h):
    s.append(input())
 
inf = 10000
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
queue = [(0, 0)]
d = []
for i in range(h):
    d.append([inf] * w)
d[0][0] = 1
 
while len(queue) > 0:
    x, y = queue.pop()
    for i in range(4):
        xx = x + dx[i]
        yy = y + dy[i]
        if 0 <= xx and xx < w and 0 <= yy and yy < h and s[yy][xx] == '.' and d[yy][xx] > d[y][x] + 1:
           d[yy][xx] = d[y][x] + 1
           queue.insert(0, (xx, yy))
if d[h-1][w-1] == inf:
    print('-1')
else:
    print(sum(sum(x) for x in s) - d[h-1][w-1])

### FIXED CODE ###

h, w = [int(s) for s in input().split(' ')]
 
s = []
for i in range(h):
    s.append([s == '.' for s in input()])

inf = 10000
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
q = [(0, 0)]
p = []
for i in range(h):
    p.append([inf] * w)
p[0][0] = 1

while len(q) > 0:
    x, y = q.pop()
    for i in range(4):
        xx = x + dx[i]
        yy = y + dy[i]
        if 0 <= xx and xx < w and 0 <= yy and yy < h and s[yy][xx] and (p[yy][xx] > p[y][x] + 1):
           p[yy][xx] = p[y][x] + 1
           q.insert(0, (xx, yy))
if p[h-1][w-1] == inf:
    print('-1')
else:
    print(sum(sum(x) for x in s) - p[h-1][w-1])
x,y,a,b,c=[int(i) for i in input().split()]

red_list=[int(i) for i in input().split()]
green_list=[int(i) for i in input().split()]
non_col_list=[int(i) for i in input().split()]

red_list.sort()
green_list.sort()
non_col_list.sort()

eat_red=[]
eat_green=[]
for i in range(x):
    eat_red.append(red_list.pop())
for i in range(y):
    eat_green.append(green_list.pop())


# eat_redにX個の赤いリンゴの美味しさ(降順)
# eat_greenにY個の緑のリンゴの美味しさ(降順)
# non_col_listにC個の無色のリンゴの美味しさ(昇順)


ans=0

def irekae(eat_list,non_col_list):
    if non_col_list==[]:
        return False
    global ans
    taishou=eat_list.pop()
    non_col=non_col_list.pop()
    if taishou<non_col:
        ans+=non_col
        return True
    else:
        eat_list.append(taishou)
        return False

while True:
    if eat_red[-1]<eat_green[-1]:
        if not irekae(eat_red,non_col_list):
            break

    else:
        if not irekae(eat_green,non_col_list):
            break

print(ans+sum(eat_green)+sum(eat_red))


### FIXED CODE ###

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

red_list=[int(i) for i in input().split()]
green_list=[int(i) for i in input().split()]
non_col_list=[int(i) for i in input().split()]

red_list.sort()
green_list.sort()
non_col_list.sort()

eat_red=[]
eat_green=[]
for i in range(x):
    eat_red.append(red_list.pop())
for i in range(y):
    eat_green.append(green_list.pop())


ans_list=eat_green+eat_red+non_col_list
ans_list.sort()
ans=0
for i in range(x+y):
    ans+=ans_list.pop()

print(ans)
N = int(input())
A = map(int, input().split()).sort()

Alice = 0
Bob = 0
for i, v in enumerate(A[::-1]):
	if i % 2 == 0:
      Alice += v
    else:
      Bob += v
print(Alice - Bob)

### FIXED CODE ###

N = int(input())
A = [int(v) for v in input().split()]
A.sort()

Alice = 0
Bob = 0
for i, v in enumerate(A[::-1]):
  if i % 2 == 0:
    Alice += v
  else:
    Bob += v
print(Alice - Bob)
a,b=map(int,input().split())
ans='LESS'
if a>b:
    ans='GREATER'
elif a==b:
    ans='EQUAL'
print(ans)

### FIXED CODE ###

a=int(input())
b=int(input())
ans='LESS'
if a>b:
    ans='GREATER'
elif a==b:
    ans='EQUAL'
print(ans)
import collections

s = input()
lst = []
for i in s:
    lst.append(i)
c = collections.Counter(lst)
if sum(c.values()) % 2 == 0:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

import collections

s = []
a = 0
x = input()
if len(x) % 2 != 0:
    print('No')
else:
    for i in x:
        s.append(i)
    c = collections.Counter(s)
    values, counts = zip(*c.most_common())
    for j in counts:
        if j % 2 == 0:
            a += 1
    if len(counts) == a:
        print('Yes')
    else:
        print('No')
N = int(input())
A = list(map(int, input().split(',')))

is_all_odd = True
counter = 0
while True:
    for i in range(len(A)):
        if A[i] % 2 == 0:
            A[i] = int(A[i] / 2)
        else:
            is_all_odd = False
    if is_all_odd:
        counter += 1
    else:
        break
print(counter)


### FIXED CODE ###

i = input()
print(int(i[0] == '1') + int(i[1] == '1') + int(i[2] == '1'))
n = int(input())
A = [int(i) for i in input().split()]

dp = [-1 for i in range(n+1)]

def brute(i):
    if i>=n-1:
        return 0
    if dp[i]!=-1:
        return dp[i]
    ans = 10**10
    if i+1 < n:
        ans = min(ans, abs(A[i] - A[i+1]) + brute(i+1))
    if i+2 < n:
        ans = min(ans, abs(A[i] - A[i+2]) + brute(i+2))
    dp[i] = ans
    return ans

print(brute(0))


### FIXED CODE ###

n = int(input())
A = [int(i) for i in input().split()]

dp = [-1 for i in range(n+50)]
import sys
sys.setrecursionlimit(1000000)
def brute(i):
    if i>=n-1:
        return 0
    if dp[i]!=-1:
        return dp[i]
    ans = 10**10
    if i+1 < n:
        ans = min(ans, abs(A[i] - A[i+1]) + brute(i+1))
    if i+2 < n:
        ans = min(ans, abs(A[i] - A[i+2]) + brute(i+2))
    dp[i] = ans
    return ans

print(brute(0))
num = raw_input()
print num**3

### FIXED CODE ###

num = raw_input()
print int(num)**3
def comb(n, r, mod=10**9 + 7):
    c=1
    for i in range(1, r+1):
        c = (c * (n-i+1) * pow(i, mod-2, mod)) % mod
    return c

n, a, b = map(int, input().split())
print((pow(2, n, MOD) - cmb(n, a) - cmb(n, b) - 1) % MOD)

### FIXED CODE ###

def cmb(n, r, mod):
    c=1
    for i in range(1, r+1):
        c = (c * (n-i+1) * pow(i, mod-2, mod)) % mod
    return c

n, a, b = map(int, input().split())
MOD = 10**9 + 7
print((pow(2, n, MOD) - cmb(n, a, MOD) - cmb(n, b, MOD) - 1) % MOD)
n, m = map(int, input().split())

adj = [[] for i in range(n)]

for i in range(m):
    s, t = map(int, input().split())
    adj[s].append(t)
    adj[t].append(s)

isVisited = [False] * n

CC = [None] * n

import sys
sys.setrecursionlimit(10000000)

def dfs(u, group):
    isVisited[u] = True
    CC[u] = group
    for v in adj[u]:
        if not isVisited[v]:
            dfs(v, group)

def makeCC(group):
    for i in range(n):
        if not isVisited[i]:
            dfs(i, group)
            group += 1

def isConnected(v1, v2):
    if CC[v1] == CC[v2]:
        print('yes')
    else:
        print('no')


makeCC(0)


q = int(input())

for i in range(q):
    s, t = map(int, input().split())
    isConnected(s, t)

### FIXED CODE ###

n, m = map(int, input().split())

adj = [[] for i in range(n)]

for i in range(m):
    s, t = map(int, input().split())
    adj[s].append(t)
    adj[t].append(s)

groups = [None] * n


def dfs(u, group_num):
    path = []
    path.append(u)
    groups[u] = group_num
    while path:
        u = path[-1]
        if adj[u]:
            v = adj[u].pop(0)
            if not groups[v]:
                groups[v] = group_num
                path.append(v)
        else:
            path.pop()


g_n = 1
for i in range(n):
    if not groups[i]:
        dfs(i, g_n)
        g_n += 1

def isConnected(v1, v2):
    if groups[v1] == groups[v2]:
        print('yes')
    else:
        print('no')


q = int(input())

for i in range(q):
    s, t = map(int, input().split())
    isConnected(s, t)
k,x=map(int,input().split())
lst=[]
for i in range(1,2*k):
  lst.append(x-k+i)
lst_2=lst.split('')
print(lst_2)


### FIXED CODE ###

k,x=map(int,input().split())
lst=[]
for i in range(1,2*k):
  lst.append(x-k+i)
for j in range(len(lst)):
  print(lst[j])
dwh = [[1,0],[0,1],[-1,0],[0,-1],[1,1],[-1,1],[-1,-1],[1,-1]]
def solve(field,w,h):
	if 0 <= w < W and 0 <= h < H and field[h][w] == 1:
		field[h][w] = 0
		for dw,dh in dwh:
			solve(field,w+dw,h+dh)

while 1:
	W,H = map(int,raw_input().split())
	if W == 0: break
	field = [map(int,raw_input().split()) for i in range(H)]
	ans = 0
	for h in range(H):
		for w in range(W):
			if field[h][w] == 1:
				solve(field,w,h)
				ans += 1
	print ans

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

def dfs(x, y):
    C[y][x] = 0
    for dx,dy in zip([1,1,0,-1,-1,-1,0,1],[0,1,1,1,0,-1,-1,-1]):
        if 0 <= x+dx < w and 0 <= y+dy < h and C[y+dy][x+dx] == 1:
            dfs(x+dx, y+dy)

while 1:
    w,h = map(int,raw_input().split())
    if w == h == 0: break
    C = [map(int,raw_input().split()) for _ in xrange(h)]

    ans = 0
    for y in range(h):
        for x in range(w):
            if C[y][x] == 1:
                dfs(x, y)
                ans += 1
    print ans
def rec_count(num):
    if num == 0:
        return 0
    elif num == 1:
        return 1
    elif num == 2:
        return 3
    elif num == 3:
        return 3
    else:
        split = num / 2
        return 1 + 2 * rec_count(split)

h = int(input())
print(rec_count(h))

### FIXED CODE ###

def rec_count(num):
    if num == 1:
        return 1
    elif num == 2:
        return 3
    elif num == 3:
        return 3
    else:
        split = num // 2
        return 1 + 2 * rec_count(split)

h = int(input())
print(rec_count(h))
s = list((input())
if s[0]==s[1] or s[1]==s[2] or s[2]==s[3]:
  print('Bad')
else:
  print('Good')

### FIXED CODE ###

s = list(input())
if s[0]==s[1] or s[1]==s[2] or s[2]==s[3]:
  print('Bad')
else:
  print('Good')
from collections import deque

q = deque([])

H,W = map(int,input().split())
L = []

for i in range(H) :
    S = input()
    for j in range(W) :
        if S[j] == "." :
            q.append((i,j))
    L.append(list(S))

ans = 0

while q :
    y,x = q.popleft()
    
    cnt = 1
    
    d = [1,-1]
    
    for dy in d :
        ny = y
        
        while True :
            ny += dy
            
            if (ny < 0) or (ny >= H) :
                break
            
            if L[ny][x] == "#" :
                break
            
            cnt += 1
    
    for dx in d :
        nx = x
        
        while True :
            nx += dx
            
            if (nx < 0) or (nx >= W) :
                break
            
            if L[y][nx] == "#" :
                break
            
            cnt += 1
    
    ans = max(ans,cnt)

print(ans)


### FIXED CODE ###

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

print(a+b+c-max(a,b,c))
S = input()
count = 0
first = S[:len(S)//2]
second = S[(len(S)+1)//2:]
if first == reversed(second):
    print(count)
else:
    for i in range(len(first)):
        if first[i] != second[len(second)-i-1]:
            count += 1
    print(count

### FIXED CODE ###

S = input()
count = 0
first = S[:len(S)//2]
second = S[(len(S)+1)//2:]
if first == reversed(second):
    print(count)
else:
    for i in range(len(first)):
        if first[i] != second[len(second)-i-1]:
            count += 1
    print(count)
import math
import fractions

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

a, b, c, d = map(int, input().split())
cd = lcm(c, d)
num = b - a + 1

if a <= cd <= b:
    cd_count = (b // cd) - (a // cd)
else:
    cd_count = 0

if a % c == 0:
    c_count = (b // c) - (a // c) + 1
else:
    c_count = (b // c) - (a // c)
if a % d == 0:
    d_count = (b // d) - (a // d) + 1
else:
    d_count = (b // d) - (a // d)

ans = num - c_count - d_count + cd_count

print(ans)

### FIXED CODE ###

import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

a, b, c, d = map(int, input().split())
a -= 1
cd = lcm(c, d)

upper = b - b//c - b//d + b//cd
lower = a - a//c - a//d + a//cd
ans = upper - lower

print(ans)
N,K=map(int,input().split())
i=0
while N>=k**i:
    i+=1
print(i)

### FIXED CODE ###

N,K=map(int,input().split())
i=0
while N>=K**i:
    i+=1
print(i)