Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import numpy as np
N, K = map(int, input().split())
hights = np.array(list(map(int,input().split())))
steps=np.zeros(N)
steps[0]=0

for i in range(1, N):
    gaps = hights[max(0, i-K):i] - hights[i]
    gaps = np.abs(gaps)
    gaps += steps[max(0, i-K):i]
    steps[i] = np.min(gaps)
    
print(int(steps[N-1]))

### FIXED CODE ###

import numpy as np
N, K = map(int, input().split())
hights = np.array(list(map(int,input().split())))
steps=np.array([0]*N)
steps[0]=0

for i in range(1, N):
    gaps = hights[max(0, i-K):i] - hights[i]
    gaps = np.abs(gaps)
    gaps += steps[max(0, i-K):i]
    steps[i] = np.min(gaps)
    
print(int(steps[N-1]))
### BUGGY CODE ###

#D
n, k = map(int, input().split())
count = 0
for a in range(1, n+1):
    for b in range(1, n+1):
        if a % b >= k:
            count += 1
print(count)

### FIXED CODE ###

#D
n,k = map(int,input().split())
s = 0
for b in range(k+1,n+1):
    s += n//b*(b-k) + max(n%b-max(k-1,0),0)
print(s)
### BUGGY CODE ###

n = int(input())
A = [-1]
for _ in range(n):
    A.append(int(input()))

X = [0]*(n+1)
count = 0
if A[1] != 0:
    print(-1)
else:
    for i in range(n,0,-1):
        if A[i] > X[i]:
            for j in range(A[i]):
                X[i-j] = A[i] - j
            count += A[i]
        elif A[i] < X[i]:
            print(-1)
            break
    else:
        print(count)
    

### FIXED CODE ###

n = int(input())
A = [-1]
for _ in range(n):
    A.append(int(input()))

num = 0
count = 0
if A[1] != 0:
    print(-1)
else:
    for i in range(n,0,-1):
        if A[i] > num:
            num = A[i]
            count += num
        elif A[i] < num:
            print(-1)
            break
        num -= 1
    else:
        print(count)
### BUGGY CODE ###

def main():
  import sys
  input = sys.stdin.readline
  n,m=map(int,input().split())
  a=[int(input()) for _ in [0]*m]
  mod=pow(10,9)+7
  ans=[0]*n
  ans[0]=1
  for i in range(n):
    if a.count(i+1)==1:
      ans[i]=0
    else:
      if i==1:
        ans[i]=ans[0]+1
      elif i>1:
        if ans[i-1]==0 and ans[i-2]==0:
          print(0)
          exit()
        ans[i]=(ans[i-1]%mod+ans[i-2]%mod)%mod
  print(ans[-1])
if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
  import sys
  input = sys.stdin.readline
  n,m=map(int,input().split())
  mod=pow(10,9)+7
  ans=[1]*(n+1)
  for _ in [0]*m:
    ans[int(input())]=0
  for i in range(n+1):
    ans[i]=ans[i] if ans[i]==0 or i<2 else (ans[i-1]+ans[i-2])%mod
  print(ans[-1])
if __name__ == '__main__':
    main()
### BUGGY CODE ###

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

count = 0
while any([i % 2 == 0 for i in nums]):
    count += 1
    div_index = max([(i, v) for i, v in enumerate(nums) if v % 2 == 0],
                    key=lambda x: x[1])[0]
    for i in range(len(nums)):
        if i == div_index:
            nums[i] //= 2
        else:
            nums[i] *= 3

print(count)


### FIXED CODE ###

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

tmp = [i for i in nums if i % 2 == 0]
count = 0
for i in tmp:

    while i % 2 == 0:
        count += 1
        i //= 2

print(count)
### BUGGY CODE ###

A,B =[int(x) for x in input().split()]

def bunkai(n):
    sosu= {1}
    tmp = n

    for i in range(2,int(n/2)+1):
        if tmp%i == 0:
            while tmp%i==0:
                tmp //=i
            sosu.add(i)

    if tmp!=1:
        sosu.add(tmp)
                
    if sosu==[]:
        sosu.add[n]
    
    return sosu

ans = len(bunkai(A)&bunkai(B))
print(ans)

### FIXED CODE ###


A,B =[int(x) for x in input().split()]

def bunkai(n):
    sosu= {1}
    tmp = n
    stop_flag = n
    
    if tmp%2 == 0:
        while tmp%2==0:
            tmp //=2
        sosu.add(2)
    
    for i in range(3,n+1,2):
        if tmp%i == 0:
            while tmp%i==0:
                tmp //=i
            sosu.add(i)
            stop_flag = tmp 
            
        if i > stop_flag:
            break
        else:
            stop_flag = int(n/i)+1
            
    if tmp!=1:
        sosu.add(tmp)
                
    if sosu==[1]:
        sosu.add(n)
    
    return sosu

def check_sosu(n,x):
    ans=0
    tmp = n
    for i in x:
        if (tmp % i) == 0:
            ans+=1
    return ans

ans = check_sosu(B,bunkai(A))

print(ans)
### BUGGY CODE ###

from collections import Counter
s = input()

si = [0] * (len(s)+1) #mod2019の累積和用に
tmp = 0
for i in range(1,len(s)+1): #累積和の作成
    tmp += int(s[-i]) * 10**(i-1) % 2019
    si[i] = tmp % 2019

c = Counter(si)
ans = 0
for b in c.values():#aがb回出てきたよ
    ans += b*(b-1)//2

print(ans)


### FIXED CODE ###

from collections import Counter
s = str(input())

si = [0] * (len(s)+1) #mod2019の累積和用に
tmp = 0
for i in range(1,len(s)+1): #累積和の作成
    tmp += int(s[len(s)-i])%2019 * pow(10,i-1,2019)
    si[i] = tmp % 2019

c = Counter(si)
ans = 0
for b in list(c.values()):#aがb回出てきたよ
    ans += b*(b-1)//2

print(ans)
### BUGGY CODE ###

import copy
H, W = map(int, input().split())
G = [list(input()) for _ in range(H)]
pG = copy.deepcopy(G)
ans = 0

while True:
    count = 0
    for i in range(H):
        for j in range(W):
            if G[i][j] == "#":
                count += 1
                try:
                    if i-1 >= 0:
                        pG[i-1][j] = "#"
                    if j-1 >= 0:
                        pG[i][j-1] = "#"
                    pG[i+1][j] = "#"
                    pG[i][j+1] = "#"
                except IndexError:
                    pass
    if count == W*H:
        break
    ans += 1
    G = copy.deepcopy(pG)

print(ans)


### FIXED CODE ###

from collections import deque

dyx = [(0, 1), (0, -1), (1, 0), (-1, 0)]
H, W = map(int, input().split())
edge = ['#']*(W+2)
field = [edge]
q = deque()

for i in range(H):
    field.append(['#'] + list(input()) + ['#'])
    for j in range(W):
        if field[i+1][j+1] == '#':
            q.append((i+1, j+1, 0))
field.append(edge)
res = 0

while q:
    y, x, lv = q.popleft()
    res = max(lv, res)

    for dy, dx in dyx:
        if field[y+dy][x+dx] == '.':
            field[y+dy][x+dx] = '#'
            q.append((y+dy, x+dx, lv+1))

print(res)
### BUGGY CODE ###

h, n = map(int, input().split())
dp = [10**10]*(h+1)
dp[0] = 0
ab = []
for _ in range(n):
    a, b = map(int, input().split())
    ab.append((a, b))

for a, b in ab:
    for start in range(h):
        end = min(start+a, h)
        dp[end] = min(dp[end], dp[start]+b)
print(dp[h])


### FIXED CODE ###

h, n = map(int, input().split())
dp = [10**10]*(h+1)
dp[0] = 0
ab = []
for _ in range(n):
    a, b = map(int, input().split())
    ab.append((a, b))

for a, b in ab:
    for start in range(h):
        end = min(start+a, h)
        dp[end] = min(dp[end], dp[start]+b)
print(dp[h])
### BUGGY CODE ###

import math


def cf(x, y):
    table = [1]
    for i in range(2, min(x, y) + 1):
        if x % i == 0 and y % i == 0:
            table.append(i)
    return table


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]


def is_pn(x):
    if x == 2:
        return 1
    if x % 2 == 0:
        return 0
    m = math.floor(math.sqrt(x))
    for p in pn_list:
        if x % p == 0:
            return 0
        if p > m:
            break
    return 1


A, B = map(int, input().split())
table = cf(A, B)
pn_list = primes(table[-1])
ans = 0
for i in table:
    ans += is_pn(i)
print(ans)

### FIXED CODE ###

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


A, B = map(int, input().split())
a = set(prime_factorize(A))
b = set(prime_factorize(B))
ans = 0
for ap in a:
    if ap in b:
        ans += 1
print(ans)
### BUGGY CODE ###

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

d={}
for x in a:
  if x not in d:
    d[x]=0
  d[x]+=1
  
for _  in range(m):
  b,c=map(int,input().split())
  if c not in d:
    d[c]=0
  d[c]+=b
  
ch=0
ans=0
while ch<=n:
  if ch==n:
    ch+=1
  else:
    s=max(d)
    re_va=d.pop(s)

    if (ch+re_va)<=n:
      ans+=re_va*s
      ch+=re_va
    else:
      ans+=(n-ch)*s
      ch+=n
      
print(ans)

### FIXED CODE ###

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

d=[]
for x in a:
  s=[1,x]
  d.append(s)
  
for _  in range(m):
  b=list(map(int,input().split()))
  d.append(b)
  
d.sort(key=lambda x:x[1],reverse=True)
  
ch=0
ans=0
for f in d:
  p,q=f[0],f[1]
  if ch==n:
    break
  else:
    if ch+p>=n:
      ans+=q*(n-ch)
      break
    else:
      ans+=p*q
      ch+=p
      
print(ans)
### BUGGY CODE ###

x = list(map(int, input().split()))
y = list(map(int, input().split()))
y = [i/2+0.5 for i in y]
max_value = 0
for i in range(0, x[0]-x[1]+1):
  value = sum(y[i:i+x[1]])
  max_value = max(max_value, value)
print(max_value)

### FIXED CODE ###

x = list(map(int, input().split()))
y = list(map(int, input().split()))
y = [i/2+0.5 for i in y]
max_value = 0
value = sum(y[:x[1]])
for i in range(x[1], x[0]):
  max_value = max(max_value, value)
  value += y[i]
  value -= y[i-x[1]]
max_value = max(max_value, value)
print(max_value)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sun Feb 24 22:10:01 2019

@author: Yamazaki Kenichi
"""
import numpy as np

A,B,Q = map(int,input().split())
s = [int(input()) for i in range(A)]
t = [int(input()) for i in range(B)]
x = [int(input()) for i in range(Q)]

def lr(s,c,A):
    si = np.searchsorted(s,c)
    if si == A:
        return [c-s[si-1], 10**11]
    elif si == 0:
        return [10**11, s[0]-c]
    else:
        return [c-s[si-1], s[si]-c]
for c in x:
    ans = 0
    slr = lr(s,c,A)
    tlr = lr(t,c,B)
    ans = min(max(slr[0],tlr[0]),
              max(slr[1],tlr[1]),
              slr[0]*2+ tlr[1],
              slr[0]+ tlr[1]*2,
              slr[1]*2 + tlr[0],
              slr[1]+ tlr[0]*2
              )
    print(ans)
    

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sun Feb 24 22:10:01 2019

@author: Yamazaki Kenichi
"""
import numpy as np
import bisect

A,B,Q = map(int,input().split())
s = [int(input()) for i in range(A)]
t = [int(input()) for i in range(B)]
x = [int(input()) for i in range(Q)]

def lr(s,c,A):
    si = bisect.bisect(s,c)
    if si == A:
        return [c-s[si-1], 10**11]
    elif si == 0:
        return [10**11, s[0]-c]
    else:
        return [c-s[si-1], s[si]-c]
for c in x:
    ans = 0
    slr = lr(s,c,A)
    tlr = lr(t,c,B)
    ans = min(max(slr[0],tlr[0]),
              max(slr[1],tlr[1]),
              slr[0]*2+ tlr[1],
              slr[0]+ tlr[1]*2,
              slr[1]*2 + tlr[0],
              slr[1]+ tlr[0]*2
              )
    print(ans)
### BUGGY CODE ###

n = int(input())
s = set(['7', '5', '3'])
print(sum((1 for i in range(1, n+1) if set(str(i)) == s)))

### FIXED CODE ###

n = int(input())
def dfs(s):
  if int(s) > n:
    return 0
  ret = 1 if all([s.count(c) > 0 for c in '753']) else 0
  for c in '753':
    ret += dfs(s+c)
  return ret
print(dfs('0'))
### BUGGY CODE ###

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

while True:
    if 2**(k-1) <= B < 2**k:
        break
    k += 1


def sum_xor(n):
    res = []
    for i in range(k):
        if i == 0:
            res.append(1) if n % 4 == 1 or n % 4 == 2 else res.append(0)
        else:
            nmod = n % 2 ** (i + 1)
            if (2**(i+1))/2 <= nmod < 2**(i+1) and nmod % 2 == 0:
                res.append(1)
            else:
                res.append(0)
    res.reverse()
    return res


ax = sum_xor(A-1)
bx = sum_xor(B)

ans = []
for i in range(k):
    ans.append(1) if (ax[i] + bx[i]) % 2 == 1 else ans.append(0)

ans = "".join(map(str, ans))
print(int(ans, 2))


### FIXED CODE ###

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

while True:
    if B == 0:
        break
    if 2**(k-1) <= B < 2**k:
        break
    k += 1


def sum_xor(n):
    res = []
    for i in range(k):
        if i == 0:
            res.append(1) if n % 4 == 1 or n % 4 == 2 else res.append(0)
        else:
            nmod = n % (2 ** (i + 1))
            if (2**(i+1))/2 <= nmod < 2**(i+1) and nmod % 2 == 0:
                res.append(1)
            else:
                res.append(0)
            # odd = [2**i+2*j for j in range(2**(i-1))]
            # tmp = n % 2**(i+1)
            # res.append(1) if tmp in odd else res.append(0)
    res.reverse()
    return res


ax = sum_xor(A-1)
bx = sum_xor(B)

ans = []
for j in range(k):
    ans.append(1) if (ax[j] + bx[j]) % 2 == 1 else ans.append(0)

ans = "".join(map(str, ans))
print(int(ans, 2))
### BUGGY CODE ###

from bisect import*
n,*t=map(int,open(0).read().split())
a,b=t[:n],t[n:]
c=0
for k in range(28,-1,-1):
    l,h=2**k,2**-~k
    a=[i%h for i in a]
    b=sorted(i%h for i in b)
    m=0
    for t in a:
        i,j=bisect_left(b,l-t),bisect_left(b,h-t)
        if l-t<0:
            i=bisect_left(b,(l-t)%h)-n
        m+=j-i
    c+=m%2*2**k
print(c)

### FIXED CODE ###

def main():
    from numpy import array,searchsorted,sum,hstack
    n,*t=map(int,open(0).read().split())
    a,b=array(t[:n],'i4'),array(t[n:],'i4')
    c=0
    for k in range(28,-1,-1):
        l,h=pow(2,k),pow(2,k+1)
        a%=h
        b%=h
        b.sort()
        y=hstack((b-h,b))
        i=searchsorted(y,l-a)
        j=searchsorted(y,h-a)
        m=sum(j-i)
        c+=m%2*l
    print(c)
if __name__=='__main__':
    main()
### BUGGY CODE ###

import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():    
    mod=10**9+7
    N,M=MI()
    adj=[[]for _ in range(N)]
    A=[0]*M
    B=[0]*M
    
    for i in range(M):
        A[i],B[i]=MI()
        A[i]-=1
        B[i]-=1
        adj[A[i]].append(B[i])
    
    def loop(n, X, i0,p0):
        # i0が根
        ans=[]
        
        st = [(~i0,p0), (i0,~p0)]

        while st:
            #頂点 i を見る
            
            (i,p) = st.pop()
            #print(i,ans,usedf,st)
            
            #帰り際の処理，ここを入れる場合，
            if i < 0:
                ans.pop()
                continue
            
            #行きがけの処理
            if i >= 0:
                if i==p0:
                    ans.append(p0)
                    break
                
                ans.append(i)
                
            for a in X[i][::-1]:
                if a!=p and a!=~p:
                    st.append((~a,(abs(i))))
                    st.append((a,abs(i)))
                    
        return ans

    ans=[1]*(N+1)
    la=N+1
    for i in range(M):
        temp=loop(N,adj,B[i],A[i])
        if temp!=[]:
            lt=len(temp)
            if lt<la:
                ans=[]
                la=lt
                for i in range(lt):
                    ans.append(temp[i])

    
    if la==(N+1):
        print(-1)
    else:
        print(la)
        for i in ans:
            print(i+1)
        
        

main()


### FIXED CODE ###

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

ret = [0] * (n + 1)
for start in range(n):
    parent = [-1] * n
    q = [start]
    while len(q) > 0:
        i = q.pop(0)
        for j in edges[i]:
            if j == start:
                loop = [i]
                while i != start:
                    i = parent[i]
                    loop.append(i)
                if len(ret) > len(loop):
                    ret = loop
                break
            if parent[j] == -1:
                parent[j] = i
                q.append(j)

if len(ret) > n:
    print(-1)
else:
    print(len(ret))
    for i in reversed(ret):
        print(i + 1)
### BUGGY CODE ###

from sys import stdin

input = stdin.readline

m, *t = map(int, open(0).read().split())

from functools import lru_cache


@lru_cache(None)
def cal(d, c):
    if c == 1:
        return [0, d]
    t = 1 + (d + d >= 10)
    a = (d + d >= 10) + (d + d) % 10

    ca = cal(a, c // 2)

    if c % 2:
        return [(c // 2) * t + ca[0] + 1 + (ca[1] + d >= 10), (ca[1] + d >= 10) + (ca[1] + d) % 10]
    else:
        return [(c // 2) * t + ca[0], ca[1]]


ans = 0
now = []
for d, c in zip(*[iter(t)] * 2):
    ca = cal(d, c)
    ans += ca[0]
    now.append(ca[1])

pre = 0
for i in now:
    pre = pre + i
    ans += 1
    if pre >= 10:
        ans += 1
        pre = pre % 10 + 1

print(ans - 1)


### FIXED CODE ###

from sys import stdin

input = stdin.readline

m = int(input())
dc = []
for _ in range(m):
    d, c = map(int,input().split())
    dc.append((d, c))

def cal(d, c):
    if c == 1:
        return [0, d]
    t = 1 + (d + d >= 10)
    a = (d + d >= 10) + (d + d) % 10

    ca = cal(a, c // 2)

    if c % 2:
        return [(c // 2) * t + ca[0] + 1 + (ca[1] + d >= 10), (ca[1] + d >= 10) + (ca[1] + d) % 10]
    else:
        return [(c // 2) * t + ca[0], ca[1]]


ans = 0
now = []
for d, c in dc:
    ca = cal(d, c)
    ans += ca[0]
    now.append(ca[1])

pre = 0
for i in now:
    pre = pre + i
    ans += 1
    if pre >= 10:
        ans += 1
        pre = pre % 10 + 1

print(ans - 1)
### BUGGY CODE ###

# 入力値
s = input()

# 手番管理
# 先行: 1, 後攻: -1
turn = 1

# 終了条件は、残り2文字になった時
while len(s) != 2:
    # 両サイド以外のどの文字が抜けるか調べる
    success = False
    for i in range(1,len(s)-1):
        if s[i-1] != s[i+1]:
            #print(s, s[i])
            s = s[0:i]+s[i+1:]
            #print(s)
            turn *= -1
            success = True
            break
    if success == False:
        break
    
# 手番の人が負け
if turn == 1:
    print("Second")
else:
    print("First")

### FIXED CODE ###

# 入力値
s = input()

if (len(s)%2==0) ^ (s[0]==s[len(s)-1]):
    print("Second")
else:
    print("First")
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sun Jan 19 21:01:18 2020

@author: over-
"""

N=int(input())
P=input().split()

c=1
for i in range(1,N):
    bool=True
    for j in range(i):
        if int(P[i])>int(P[j]): 
            bool=False
            break
    if bool: c+=1

print(c)

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sun Jan 19 21:01:18 2020

@author: over-
"""

N=int(input())
P=input().split()

c=1
m=int(P[0])
for i in range(1,N):
    if m>int(P[i]):
        c+=1
        m=int(P[i])


print(c)
### BUGGY CODE ###

N, K = map(int, input().split())
p = list(map(int, input().split()))
SUM_P = [sum(p[i:i+K]) for i in range(N-K+1)]
print((max(SUM_P)+K)/2)

### FIXED CODE ###

N, K = map(int, input().split())
p = list(map(int, input().split()))
SUM_P=sum(p[0:K])
all_sum_p=[SUM_P]
for i in range(N-K):
    SUM_P=SUM_P-p[i]+p[i+K]
    all_sum_p.append(SUM_P)
print((max(all_sum_p)+K)/2)
### BUGGY CODE ###

from math import gcd
from functools import reduce

N = int(input())
A = [int(i) for i in input().split()]
mod = 10**9 + 7

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

num = lcm_list(A)
ans = 0
for a in A:
    ans += num//a%mod
ans %= mod
print(ans)


### FIXED CODE ###

from math import gcd
from functools import reduce

N = int(input())
A = [int(i) for i in input().split()]
mod = 10**9 + 7

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

num = lcm_list(A)
ans = 0
for a in A:
    ans += (num * pow(a, mod-2, mod))%mod
ans %= mod

print(ans)
### BUGGY CODE ###

n=int(input())
t=[int(input()) for _ in range(n)]  
mt=max(t)
for i in range(mt,10**18+1):
  for j in t:
    if i%j:
      break
  else:
    print(i)
    break

  

### FIXED CODE ###

import fractions
from functools import reduce

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

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n=int(input())
print(lcm_list([int(input()) for _ in range(n)]))
### BUGGY CODE ###

N = int(input())
A = input().split()
i = 0
S = 1
for i in range(N):
    S *= int(A[i])
if S > 10**18:
    print(-1)
else:
    print(S)


### FIXED CODE ###

N = int(input())
A = input().split()
S = 1
if "0" in A:
    print(0)
else:
    for i in range(N):
        S *= int(A[i])
        if S > 10**18:
            break
    if S > 10**18:
        print(-1)
    else:
        print(S)
### BUGGY CODE ###

_ = input()
a = map(int, input().split())
cnt = 0
 
while(1):
  flg = 0
  for i in a:
    if(i%2 == 1):
      flg = 1
      break
      
  if(flg == 0):
    a = map(lambda x:x/2, a)
    cnt += 1
  else:
    break
 
print(cnt)

### FIXED CODE ###

import sys

def main():
    N = int(input())
    A = [int(_) for _ in input().split()]

    t = 0
    while True:
        for i in range(N):
            if A[i] % 2 == 0:
                A[i] //= 2
            else:
                print(t)
                sys.exit()
        t += 1

main()
### BUGGY CODE ###

n = int(input())
 
ans = 0
for i in range(1, n+1):
  for x in range(100 * i, 105 * i + 1):
    if n == x:
      ans = 1
print(ans)

### FIXED CODE ###

x = int(input())

flag = False
for c in range(1,x+1):
  if c * 100 <= x and x <= c * 105:
    flag = True
    break
print(1 if flag else 0)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys

import math


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

def solve(N: int):
    from functools import reduce
    from operator import mul

    a = prime_factorize(N)
    a.sort(reverse=True)
    if(len(a)==1):
        print(len(str(a[0])))
        exit()

    # bit all search
    ans = 100000000
    for i in range(1<<len(a)):
        x = 1
        y = 1
        for j in range(len(a)):
            if((i >> j)&1):
                x *= a[j]
            else:
                y *= a[j]

        ans = min(ans, max(len(str(x)), len(str(y))))


    print(ans)
    


    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys

import math


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

def solve(N: int):
    from functools import reduce
    from operator import mul

    a = prime_factorize(N)
    a.sort(reverse=True)
    if(len(a)==1):
        print(len(str(a[0])))
        exit()

    # bit all search
    ans = 100000000
    for i in range(1<<len(a)):
        x = 1
        y = 1
        for j in range(len(a)):
            if((i >> j)&1):
                x *= a[j]
            else:
                y *= a[j]

        ans = min(ans, max(len(str(x)), len(str(y))))


    print(ans)
    


    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()