Harryxun/stf_run huggingface dataset:
n, k = map(int, input().split())
dislikes = list(map(int, input().split())
m = n
while True:
    m = list(str(m))
    l = []
    for p in m:
        if int(p) not in dislikes:
            l.append(p)
            continue
        else:
            m = int(''.join(m))+1
            break
    if len(l) >= len(str(n)):
        if int(''.join(l))>=n:
            break
print(''.join(m))

### FIXED CODE ###

n, k = map(int, input().split())
dislikes = list(map(int, input().split()))
m = n
while True:
    m = list(str(m))
    l = []
    for p in m:
        if int(p) not in dislikes:
            l.append(p)
            continue
        else:
            m = int(''.join(m))+1
            break
    if len(l) >= len(str(n)):
        if int(''.join(l))>=n:
            break
print(''.join(m))
N=int(input())
A=list(map(int, input().split()))
S=sum(A)

A.sort(reverse=True)
if A[M-1] >= S/(4*M):
  print('Yes')
else:
  print('No')

### FIXED CODE ###

N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse=True)
S = sum(A)
if A[M-1] >= S / (4*M):
	print("Yes")
else:
	print("No")
import sys
a,b=map(int, input().split())
s=[a,b,a+b]
for si in s:
  if si%3==0:
  	print('Possible')
    sys.exit()    
print('Impossible')


### FIXED CODE ###

import sys
a,b=map(int, input().split())
s=[a,b,a+b]
for si in s:
  if si%3==0:
    print('Possible')
    sys.exit()

print('Impossible')
n=int(input())
if(n>=1000):
  print("ABD")
 else:
  print("ABC")

### FIXED CODE ###

n=int(input())
if(n>=1000):
  print("ABD")
else:
  print("ABC")
#入力
n,x=map(int,input().split())
line=list(map(int,input().split()))
#累積和を計算しておく
#はじめに0を入れておくと、右からi番目で計算できる(i-1としなくて良い)
Sum=[0]
sum=0
#lineの後ろから値を取って、sumに足してlistに入れる
for i in range(n):
  sum+=line.pop()
  Sum.append(sum)
#大きい数で初期化(今回は小さい数の方が選ばれるので、十分大きい数で)
Ans=10**18
#それぞれのkについてコストを計算
for k in range(1,n):
  #pは純粋な移動のみのコスト
  p=0
  #kで割り切れる時は、n//k -1個のグループが出来る(最初は2kでグループを作る)
  #kで割り切れない時は、n//k 個のグループが出来る
  #よってn-1しておけばkで割り切れる時だけ-1出来る
  for i in range((n-1)//k):
    #はじめだけ処理が異なる
    if i==0:
      if n>=2k:
        p+= (Sum[k])*5
      #2kの長さがなければ最初から最後まで足して終わり
      else:
        p+=(Sum[n])*5
        break
    else:
      if n> (k*i +2*k):
        #(i+1)*k+1から(i+2)*kまでの座標の和に移動コストをかける
        p+= (Sum[k*i +2*k]-Sum[k*(i-1) +2*k])*(2*i +5)
      else:
        p+= (Sum[n]-Sum[k*(i-1) +2*k])*(2*i +5)
        break
  #n*xが1)のコスト、k*xが2)のコスト
  ans=(n+k)*x + p
  #小さい方をAnsに代入
  Ans=min(Ans,ans)
#答え
print(Ans)

### FIXED CODE ###

n,x=map(int,input().split())
line=list(map(int,input().split()))
Sum=[0]
sum=0
for i in range(n):
  sum+=line.pop()
  Sum.append(sum)
Ans=10**18
for k in range(1,n):
  p=0
  for i in range(n+k-1//k):
    if i==0:
      if n>=k:
        p+= (Sum[k])*5
      else:
        p+=(Sum[n])*5
        break
    else:
      if n> (k*i +k):
        p+= (Sum[k*i +k]-Sum[k*(i-1) +k])*(2*i +3)
      else:
        p+= (Sum[n]-Sum[k*(i-1) +k])*(2*i +3)
        break
  ans=(n+k)*x + p
  Ans=min(Ans,ans)
print(Ans)
atcoderbeginnercontest
atcoderregularcontest

### FIXED CODE ###

o= input()
e= input()
P = ''

if len(o)==len(e):
    for i in range(len(o)):
        P += o[i]
        P += e[i]
else:
    for i in range(len(o)-1):
        P += o[i]
        P += e[i]
    P += o[len(o)-1]
print(P)
import sys
input=sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
nCr = {}
def cmb(n, r):
    if n == 0:
        return 0
    if r == 0 or r == n:
         return 1
    if r == 1:
         return n
    if (n,r) in nCr:
         return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]
mydict = {}
for i in range(N):
    a = A[i]
    if a in mydict.keys():
        mydict[a] += 1
    else:
        mydict[a] = 1
for i in range(N):
    s = 0
    a = A[i]
    mydict[a] -= 1
    for j in mydict.values():
        s += cmb(j,2)
    print(s)
    mydict[a] += 1

### FIXED CODE ###

import sys
input=sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
def cmb(n):
    if n == 1:
        return 0
    else:
        return n * (n-1) /2
mydict = {}
for i in range(N):
    a = A[i]
    if a in mydict.keys():
        mydict[a] += 1
    else:
        mydict[a] = 1
s = 0
for i in mydict.values():
	s += cmb(i)
for i in range(N):
    a = A[i]
    x = mydict[a] - 1
    print(int(s-x))
a, b = map(int, input().split())  

print(1)

### FIXED CODE ###

a = int(input())
b = int(input())
 
if (a != 1 and b != 1):
  print(1)
elif (a != 2 and b != 2):
  print(2)
else:
  print(3)
a, b = map(int, input().split())

if a>=13:
    print(b)
elif a >= 6:
    print(int(b / 2))
else:
    print(0)

### FIXED CODE ###

r ,d ,x = map(int, input().split())

new_x = r * x - d
print(new_x) #2011
for i in range(2002, 2011):
    new_x = r * new_x - d
    print(new_x)
import math
 
x = int(input())

if x == 2:
    print(2)
    exit()
 
while True:
    g = math.ceil(math.sqrt(x))
    for i in range(2,g+1):
        if x%i == 0:
            f = False
            break
    if f == True:
        print(x)
        exit()
    x += 1

### FIXED CODE ###

import math
 
x = int(input())

if x == 2:
    print(2)
    exit()
 
while True:
    f = True
    g = math.ceil(math.sqrt(x))
    for i in range(2,g+1):
        if x%i == 0:
            f = False
            break
    if f == True:
        print(x)
        exit()
    x += 1
import numpy as np

N, M, K = list(map(int, input().split()))
A = list(map(int, [0] + input().split()))
B = list(map(int, [0] + input().split()))
cost = 0
cumsum_a = np.cumsum(A)
cumsum_b = np.cumsum(B)

num_book = 0
dp = np.zeros((N + 2, M + 2)).astype(bool)

max_a = 0
ind_b = 0
max_b = 0
for i in range(1, N + 1):
    if cumsum_a[i] <= K:
        max_a = i
    else:
        break

for i in range(1, M + 1):
    if cumsum_b[i] <= K:
        max_b = i
    else:
        break

for i in range(max_a, -1, -1):
    for j in range(ind_b, max_b+1):
        if cumsum_b[j] + cumsum_a[i] <= K:
            # print("ok")
            num_book = max(i + j, num_book)
            ind_b = j
        else:
            break
print(num_book)

### FIXED CODE ###

import numpy as np

N, M, K = list(map(int, input().split()))
A = list(map(int, [0] + input().split()))
B = list(map(int, [0] + input().split()))
cost = 0
cumsum_a = np.cumsum(A)
cumsum_b = np.cumsum(B)

num_book = 0
max_a = 0
ind_b = 0
max_b = 0
for i in range(1, N + 1):
    if cumsum_a[i] <= K:
        max_a = i
    else:
        break

for i in range(1, M + 1):
    if cumsum_b[i] <= K:
        max_b = i
    else:
        break

for i in range(max_a, -1, -1):
    for j in range(ind_b, max_b+1):
        if cumsum_b[j] + cumsum_a[i] <= K:
            # print("ok")
            num_book = max(i + j, num_book)
            ind_b = j
        else:
            break
print(num_book)
A, B = map(int,input().split())
print(max[A + B, A - B, A * B])

### FIXED CODE ###

A, B = map(int,input().split())
print(max([A+B,A-B,A*B]))
A=input()
B=input()
C=input()
s=a
while len(A)!=0 and len(B)!=0 and len(C)!=0:
  if s==a:
    if A[0]==b:
      s=b
      continue
    if A[0]==c:
      s=c
      continue
  elif s==b:
    if B[0]==c:
      s=c
      continue
    if B[0]==a:
      s=a
      continue
  else:
    if C[0]==a:
      s=a
      continue
    if C[0]==b:
      s=b
      continue
if len(A)==0:
  print("A")
elif len(B)==0:
  print("B")
else:
  print("C")
    
  

### FIXED CODE ###

A=input()
B=input()
C=input()
s="a"
while (len(A)!=0 or s!="a") and (len(B)!=0 or s!="b") and (len(C)!=0 or s!="c"):
  if s=="a":
    s=A[0]
    A=A[1:]
  elif s=="b":
    s=B[0]
    B=B[1:]
  else:
    s=C[0]
    C=C[1:]
if len(A)==0 and s=="a":
    print("A")
elif len(B)==0 and s=="b":
    print("B")
else:
    print("C")
n, k = map(int, input().split())
a = list(map(int, input().split()))

if all(i<=0 for i in a) or n==k:
    a.sort(reverse=True)
    res = 1
    mod = 10**9 + 7
    for i in range(k):
        res = (res*a[i])%mod
    print(res)
else:
    mainas = []
    plus = []
    for i in range(n):
        if a[i] < 0: mainas.append(a[i])
        else: plus.append(a[i])
        
    mainas.sort()
    mainas.extend([0,0])
    plus.sort(reverse=True)
    plus.extend([0,0])

    m, p = 0,0
    r = []
    while k > 1:
        if mainas[p]*mainas[p+1] < plus[m]*plus[m+1]:
            r.extend(plus[m:m+2])
            m += 2
        else:
            r.extend(mainas[p:p+2])
            p += 2
        k -= 2

    if k == 1:
        r.append(plus[m])

    res = 1
    mod = 10**9 + 7
    for i in r:
        res = (res*i)%mod
    print(res)

### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = 10**9 + 7
res = 1
a.sort(reverse=True)
if a[0]<0 and k%2==1:
    for i in range(k):
        res = (res*a[i])%mod
else:
    right = n-1
    left = 0
    while k > 1:
        if a[right]*a[right-1] < a[left]*a[left+1]:
            res = (res*a[left])%mod
            left += 1
            k -= 1
        else:
            res = (res*a[right]*a[right-1])%mod
            right -= 2
            k -= 2
    if k == 1:
        res = (res*a[left])%mod

print(res)
D = input()

today = "Christmas"

x = 25 - D

today += x * " Eve"

print(today)
    



### FIXED CODE ###

D = int(input())
#かわむら

today = "Christmas"

x = 25 - D

today += x * " Eve"

print(today)
n=int(input())
a=[int(input()) for i in range(n)]
max = 0
max_ind = 0
max2 = 0
max2_ind = 0

for i in range(n):
  if max < a[i]:
    max = a[i]
    max_ind = i
    max2 = max
    max2_ind = max_ind
    
for i in range(n):
  if i = max_ind:
    print(max2)
  else:
    print(max)
  


### FIXED CODE ###

n=int(input())
a=[int(input()) for i in range(n)]

max1 = 0
max1_ind = 0
max2 = 0
max2_ind = 0
 
for i in range(n):
    if max2 <= a[i]:
        if max1 <= a[i]:
            max2 = max1
            max2_ind = max1_ind
            max1 = a[i]
            max1_ind = i
            
        else:
            max2 = a[i]
            max2_ind = i
    
for j in range(n):
    if j == max1_ind:
        print(max2)
    else:
        print(max1)
S = input()
if S[-1] == "s":
  print(S + "es")
  else:
    print(S + "s")

### FIXED CODE ###

S = input()
if S[-1] == "s":
	print(S + "es")
else:
  	print(S + "s")
x, y = int(input())
print(y/x)

### FIXED CODE ###

x,y = map(int,input().split())
print(x/y)
def f():
    import sys
    input=sys.stdin.readline
    n=int(input())
    a=[int(j) for j in input().split()]
    import numpy as np
    #dp=np.zeros((n,n,2),dtype=np.int64)
    dp=[[[0,0]for j in range(n)] for i in range(n)]

    for i in range(1,1+n):
        for j in range(n-i+1):
            #j~j+i-1
            if i==1:
                dp[j][j][1]=a[j]
                continue
            tmp=10**18
            for k in range(i-1):
                #j~j+k,j+k+1~j+i-1
                if sum(dp[j][j+k])+sum(dp[j+k+1][j+i-1])<tmp:
                    tmp=sum(dp[j][j+k])+sum(dp[j+k+1][j+i-1])
                    dp[j][j+i-1][0]=tmp
                    dp[j][j+i-1][1]=dp[j][j+k][1]+dp[j+k+1][j+i-1][1]
    print(dp[0][n-1][0])

f()

### FIXED CODE ###

def f():
    import sys
    import numpy as np
    input=sys.stdin.readline
    n=int(input())
    a=np.array([0]+[int(j) for j in input().split()])
    np.cumsum(a,out=a)
    dp=np.zeros((n,n+1),np.int64)

    for i in range(1,n):
        l=np.arange(n-i)
        r=np.arange(i+1,n+1)
        m=(np.arange(1,i+1)+l[:,np.newaxis]).T
        dp[l,r]=np.amin(dp[l,m]+dp[m,r],0)+a[r]-a[l]
    print(dp[0][n])
f()
x = input().split()
n = 0
for i in range(1,int(x[0])+1):
    l = 0
    for j in range(1,i+1):
               if int(x[i]) <= int(x[j]):
                    l += 1
    if l == i:
        n += 1
print(n)

### FIXED CODE ###

n = int(input())
m = list(map(int, input().split()))
l = 0
s = m[0]
for i in range(0,n):
    if s >= m[i]:
        s = m[i]
        l += 1
print(l)
paper = [0,0,0,0,0,0,0,0,0,0]
N = int(input())
for _ in range(N):
    number = int(input())
    paper[number] += 1
sum = 0
for x in range(10)
    if paper[x] % 2 == 1
        sum += 1
print(sum)

### FIXED CODE ###

N = int(input())
set = set([])
for _ in range(N):
    p = int(input())
    if p not in set:
        set.add(p)
    else:
        set.remove(p)
print(len(set))
S=input()
T=input()
s=len(S)
t=len(T)
max_count=0
count=0
for i in range(s-t+1):
  for j in range(t):
    if T[i]==S[j+i]:
      count += 1
  max_count=max(max_count,count)
  count=0  
print(t-max_count)

### FIXED CODE ###

S=input()
T=input()
s=len(S)
t=len(T)
max_count=0
count=0
for i in range(s-t+1):
  for j in range(t):
    if T[j]==S[i+j]:
      count += 1
  max_count=max(max_count,count)
  count=0  
print(t-max_count)
import sys
n, D, a = map(int, input().split())
tg = []
for _ in range(n):
    x, h = map(int, sys.stdin.readline().split())
    c = h // a
    if h % a > 0:
        c+=1
    tg.append([x, c])

class BIT:
    def __init__(self, n):
        self.n = n
        self.N = 1 << n.bit_length()
        self.data = [0] * (self.N +1)

    def add(self, i, x):
        while i <= self.N:
            self.data[i] += x
            i += i & -i

    def sum(self, i):
        total = 0
        while i > 0:
            total += self.data[i]
            i -= i&-i
        return total

    def search(self, w):
        if w <= 0:
            return 0
        x = 0
        k = self.N >> 1
        while k > 0:
            if x+k <= self.N and self.data[x+k] < w:
                w -= self.data[x+k]
                x += k
            k = k >> 1
        return x+1

    def len(self):
        return self.data[self.N]

tg = sorted(tg, key=lambda x:x[0])
bit = BIT(n+2)
result = 0
ind = 0
for i in range(n):
    c = tg[i][1] - bit.sum(i+1)
    d = tg[i][0]
    if c <= 0:
        continue
    result += c
    wd = d + 2*D
    if ind < c:
        ind = c
    for j in range(ind, n):
        if tg[j][0] <= wd:
            ind = j
        else:
            break
    bit.add(i+1, c)
    bit.add(ind+2, -c)
    for j in range(n+1):
print(result)

### FIXED CODE ###

import sys
n, D, a = map(int, input().split())
tg = []
for _ in range(n):
    x, h = map(int, sys.stdin.readline().split())
    c = h // a
    if h % a > 0:
        c+=1
    tg.append([x, c])

class BIT:
    def __init__(self, n):
        self.n = n
        self.N = 1 << n.bit_length()
        self.data = [0] * (self.N +1)

    def add(self, i, x):
        while i <= self.N:
            self.data[i] += x
            i += i & -i

    def sum(self, i):
        total = 0
        while i > 0:
            total += self.data[i]
            i -= i&-i
        return total

    def search(self, w):
        if w <= 0:
            return 0
        x = 0
        k = self.N >> 1
        while k > 0:
            if x+k <= self.N and self.data[x+k] < w:
                w -= self.data[x+k]
                x += k
            k = k >> 1
        return x+1

    def len(self):
        return self.data[self.N]

tg = sorted(tg, key=lambda x:x[0])
bit = BIT(n+2)
result = 0
ind = 0
for i in range(n):
    c = tg[i][1] - bit.sum(i+1)
    d = tg[i][0]
    if c <= 0:
        continue
    result += c
    wd = d + 2*D
    if ind < i:
        ind = i
    for j in range(ind, n):
        if tg[j][0] <= wd:
            ind = j
        else:
            break
    bit.add(i+1, c)
    bit.add(ind+2, -c)
print(result)
a = int(input())
b =list(input().split())

c = 0
for i in range(a):
  if i>0:
    if (int(b[i-1]) - int(b[i])>1):
      c=1
if c==1:
  print("No")
else:
  print("Yes")

### FIXED CODE ###

a,b,c=map(int, input().split())
if (a-b)>=c:
  print(0)
else:
  print(c-(a-b))
n = int(input())
tree = [[] for _ in range(n)]
dic = {}

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

max_color = 0

def dfs(pos, before_pos, before_color):
    global max_color
    color = 1
    for next_pos in tree[pos]:
        if color == before_color:
            color += 1
        if next_pos == before_pos:
            continue
        if pos < next_pos:
            dic[(pos, next_pos)] = color
        else:
            dic[(next_pos, pos)] = color
        max_color = max(color, max_color)
        dfs(next_pos, pos, color)
        color += 1
dfs(0, -1, -1)

print(max_color)
for _, i in dic.items():
    print(i)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 9)

n = int(input())
tree = [[] for _ in range(n)]
dic = {}

for i in range(n - 1):
    a, b = map(int, input().split())
    tree[a - 1].append(b - 1)
    tree[b - 1].append(a - 1)
    dic[(a - 1, b - 1)] = i
ans = [0 for _ in range(n - 1)]
max_color = 0

def dfs(pos, before_pos, before_color):
    global max_color
    color = 1
    for next_pos in tree[pos]:
        if color == before_color:
            color += 1
        if next_pos == before_pos:
            continue
        before = min(pos, next_pos)
        after = max(pos, next_pos)
        ans_ind = dic[(before, after)]
        if pos < next_pos:
            ans[ans_ind] = color
        else:
            ans[ans_ind] = color
        max_color = max(color, max_color)
        dfs(next_pos, pos, color)
        color += 1
dfs(0, -1, -1)

print(max_color)
for i in ans:
    print(i)
num = int(input())
array = list(map(int, input().split()))
sum = 0
 
for i in range(num):
	if i == 0:
		sum += array[i]
	else if i < (num-1):
		if array[i] > array[i-1]:
			sum += array[i-1]
		else:
			sum += array[i]
	else:
		sum += array[i-1]
        
print(sum)

### FIXED CODE ###

num = int(input())
array = list(map(int, input().split()))
sum = 0
 
for i in range(num):
	if i == 0:
		sum += array[i]
	elif i < (num-1):
		if array[i] > array[i-1]:
			sum += array[i-1]
		else:
			sum += array[i]
	else:
		sum += array[i-1]
        
print(sum)
#A
n, r = map(int, input().split())
if n >= 10:
    print(r)
else:
    print(r-100*(10-k))

### FIXED CODE ###

n,r=map(int,input().split())
if n>10:
  print(r)
else:
  print(r+(-n*100+1000))
a, b = map(int,input().split())

if a<b:
    a,b=b,a

if a%b == 0:
    print(0)
else:
    
    a=a%b
    
    while abs(a-b)<a:
        a=abs(a-b)
    print(a)


### FIXED CODE ###

a,b,c = map(int,input().split())
a,b = b,a
a,c = c,a
print("{} {} {}".format(a,b,c))
A, B = [int(i) for i in input().split()]

i = 1

while True:
    if i == 1:
        s = A*i
    else:
        s = A*i - (i - 1)
    
    if s >= B:
        break
    i += 1

if B == 1:
    print(0)
else
    print(i)

### FIXED CODE ###

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

i = 1

while True:
    if i == 1:
        s = A*i
    else:
        s = A*i - (i - 1)
    
    if s >= B:
        break
    i += 1

if B == 1:
    print(0)
else:
    print(i)
N,M=input().split()
N,M=int(N),int(M)

guess = [] #答えの候補を保管
for i in range(N):
    guess.append(-1)
exits=True #答えが存在するか
ans=-1

for i in range(M):
    s,c=input().split()
    #桁数sを直感に一致させるために-1
    s,c=int(s)-1,int(c)
    if guess[s]==-1 or guess[s]>c:
        guess[s]=c

if guess[0]==0 or guess[0]==-1 or M==0:
    exits=False 

if exits:
    ans=0
    for i in range(N):
        ans+= guess[i]*(10**(N-i-1)) if not guess[i]==-1 else 0
	#1桁の場合はcがそのまま答え
    if N==1:
        ans=c

print(ans)

### FIXED CODE ###

N = int(input())
if N%2 ==1:
    N += 1
print(int(N/2))
a = [False for i in range(31)]

for i in range(30):
    x = int(input())
    a[x] = True
for i in range(1, 30):
    if a[i] == False:
        print(i)

### FIXED CODE ###

a = [False for i in range(30)]
for i in range(28):
    a[int(input()) - 1] = True

for i in range(30):
    if a[i] is False:
        print(i + 1)
a,b=int(input.split())
if b*2>=a:
  print(0)
else: print(a-b*2)

### FIXED CODE ###

a=input().split()
b=int(a[0])
c=int(a[1])
if c*2>=b:
  print(0)
else: print(b-c*2)
def main():
	n = list(map(int, input().split()))
	ans = 0
	for i in range(n[0], n[1]+1):
		temp = str(i)
		if temp == temp[::-1]:
			an += 1
	print(ans)
main()

### FIXED CODE ###

def main():
	n = list(map(int, input().split()))
	ans = 0
	for i in range(n[0], n[1]+1):
		temp = str(i)
		if temp == temp[::-1]:
			ans += 1
	print(ans)
main()
def gcd(a, b):
    if a == 0: return b
    if b == 0: return a
    return gcd(a % b, b % a)

n, k = map(int, input().split())
arr = list(map(int, input().split()))
g = arr[0]
for e in arr[1:]:
        g = gcd(g, e)

if k <= max(arr) and k//g*g == k:
        print("POSSIBLE")
else:
        print("IMPOSSIBLE")

### FIXED CODE ###

def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b)

n, k = map(int, input().split())
arr = list(map(int, input().split()))
g = arr[0]
for e in arr[1:]:
    g = gcd(g, e)

if k <= max(arr) and k//g*g == k:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
N,M=map(int,input().split())
a=[0]*M
for i in range(M):
  a[i]=int(input())
dp=[1]*(N+1)
mod=10**9+7
if M !=0:
  j=0
  if a[j]==1:
    j=j+1
    dp[1]=0
  for i in range(2,N+1):
    if j==0:
      if i==a[j]:
        dp[i]=0
        if j < M-1:
          j=j+1
        else:
          a[j]=-1
      else:
        dp[i]=(dp[i-1]+dp[i-2])%mod
    else:
      if i==a[j] and i-1 !=a[j-1]:
        dp[i]=0
        if j < M-1:
          j=j+1
        else:
          a[j]=-1
      elif i==a[j] and i-1 ==a[j-1]:
        dp[N]=0
        break
      elif i-2 ==a[j-1]:
        dp[i]=dp[i-1]
      elif i-1 ==a[j-1]:
        dp[i]=dp[i-2]
      elif i-1 !=a[j-1] and i-2 !=a[j-1]:
        dp[i]=(dp[i-1]+dp[i-2])%mod
else:
  for i in range(2,N+1):
    dp[i]=(dp[i-1]+dp[i-2])%mod 
print(dp[N]%mod)

### FIXED CODE ###

N,M=map(int,input().split())
a=[0]*M
for i in range(M):
  a[i]=int(input())
dp=[1]*(N+1)
mod=10**9+7
if M >=2:
  j=0
  if a[j]==1:
    j=j+1
    dp[1]=0
  for i in range(2,N+1):
    if j==0:
      if i==a[j]:
        dp[i]=0
        if j < M-1:
          j=j+1
        else:
          a[j]=-1
      else:
        dp[i]=(dp[i-1]+dp[i-2])%mod
    else:
      if i==a[j] and i-1 !=a[j-1]:
        dp[i]=0
        if j < M-1:
          j=j+1
        else:
          a[j]=-1
      elif i==a[j] and i-1 ==a[j-1]:
        dp[N]=0
        break
      elif i-2 ==a[j-1]:
        dp[i]=dp[i-1]
      elif i-1 ==a[j-1]:
        dp[i]=dp[i-2]
      elif i-1 !=a[j-1] and i-2 !=a[j-1]:
        dp[i]=(dp[i-1]+dp[i-2])%mod
elif M==0:
  for i in range(2,N+1):
    dp[i]=(dp[i-1]+dp[i-2])%mod
else:
  for i in range(2,N+1):
    if i==a[0]:
      dp[i]=0
    elif i-2==a[0]:
      dp[i]=dp[i-1]
    elif i-1==a[0]:
      dp[i]=dp[i-2]
    else:
      dp[i]=(dp[i-1]+dp[i-2])%mod
print(dp[N]%mod)
n = int(input)
h = n//100
if 100*h <= n <= 105*h:
  print(1)
else:
  print(0)

### FIXED CODE ###

n = int(input())
h = n//100
if 100*h <= n <= 105*h:
  print(1)
else:
  print(0)
n = int(input())
s = list(input())

former = set(s[0])
latter = set(s[1:])
ans = len(former & latter)

for i in range(2, n):
	former = set(s[:i])
    latter = set(s[i:])
    if len(former & latter) > ans:
    	ans = len(former & latter)
        
print(ans)

### FIXED CODE ###

n = int(input())
s = list(input())

former = set(s[0])
latter = set(s[1:])
ans = len(former & latter)

for i in range(2, n):
	former = set(s[:i])
	latter = set(s[i:])
	if len(former & latter) > ans:
		ans = len(former & latter)
        
print(ans)
import time
import random
N = int(input())
s = str(input())
maxlen = N//2
start = time.time()
def solve(tgt):
    for i in range(N-tgt*2+1):
        if s[i:i+tgt] in s[i+tgt:]:
            return True
    return False

ng = maxlen + 1
ok = 0
if N>650:
    ok = 2
first = 1
while ng-ok > 1:
    end = time.time()
    if end-start > 1.5:
        if ok <= 50:
            assert()
        r = random.random.randint(ok,ng-1)
        print(r)
        exit()
    tgt = (ok+ng)//2
    if first == 1:
        tgt = 16
        first = 0
    if solve(tgt):
        ok = tgt
    else:
        ng = tgt
print(ok)


### FIXED CODE ###

from collections import defaultdict as dd
N = int(input())
s = str(input())
maxlen = N//2

def solve(tgt):
    dic = dd(int)
    st = s[tgt:2*tgt]
    dic[st] += 1
    ls = [st]
    for char in s[2*tgt:]:
        st = st[1:]+char
        dic[st] += 1
        ls.append(st)
    st = s[:tgt]
    if dic[st] > 0:
        return True
    dic[ls[0]] -= 1
    for i,char in enumerate(s[tgt:N-tgt]):
        st = st[1:]+char
        if dic[st] > 0:
            return True
        dic[ls[i+1]] -= 1
    return False

ng = maxlen + 1
ok = 0
while ng-ok > 1:
    tgt = (ok+ng)//2
    if solve(tgt):
        ok = tgt
    else:
        ng = tgt
print(ok)