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

s = list(input())
maxilen = len(s)
ans = 0
end = True
while maxilen != 0 and end:
    for i in range(maxilen):
        if i == maxilen-1:
            end = False
            break
        elif s[i] != s[i+1]:
            del s[i:i+2]
            maxilen = len(s)
            ans += 2
            break
print(ans)

### FIXED CODE ###

s = list(input())
print(min(s.count("0")*2,s.count("1")*2))
### BUGGY CODE ###

N = int(input())
S = []
for i in range(N):
    s = input()
    if s[0] in [ 'M','A','R','C','H' ]:
        S.append(s)

S = list(set(S))

N = len(S)
selected = [""] * 2
cnt = 0
for i in range(N):
    selected[0] = S[i][0]
    for k in range(i+1, N):
        if selected[0] == S[k][0]:
            continue
        selected[1] = S[k][0]
        for t in range(k+1, N):
            if selected[1] == S[t][0]:
                continue
            cnt += 1
print(cnt)

### FIXED CODE ###

import numpy as np
import itertools
cnt = 0
N = int(input())
S = {'M':0,'A':0,'R':0,'C':0,'H':0}
march = ['M','A','R','C','H']
for i in range(N):
    s = input()[0]
    if s in march:
        S[s] += 1
seq = S.values()
for i in list(itertools.combinations(seq, 3)):
    i = np.array(i)
    cnt += np.prod(i)

print(cnt)
### BUGGY CODE ###

N,mod=map(int,input().split())

DP=[[0]*(N+5) for i in range(3*N+5)]
DP[0][0]=1

for i in range(3*N):
    for j in range(N+1):
        DP[i+1][j]+=DP[i][j]
        DP[i+2][j+1]+=((3*N-i)-1)*DP[i][j]
        DP[i+3][j+1]+=((3*N-i)-1)*((3*N-i)-2)*DP[i][j]

ANS=0
for i in range(N+1):
    ANS+=DP[3*N][i]
print(ANS%mod)

### FIXED CODE ###

N,mod=map(int,input().split())

DP=[[0]*(N+5) for i in range(3*N+5)]
DP[0][0]=1

for i in range(3*N):
    for j in range(N+1):
        DP[i][j]%=mod
        DP[i+1][j]+=DP[i][j]
        DP[i+2][j+1]+=((3*N-i)-1)*DP[i][j]
        DP[i+3][j+1]+=((3*N-i)-1)*((3*N-i)-2)*DP[i][j]

ANS=0
for i in range(N+1):
    ANS+=DP[3*N][i]
print(ANS%mod)
### BUGGY CODE ###

S = input()
Q = int(input())

flag = True
lS = ''
for _ in range(Q):
    query = input()
    if query[0] == '1':
        lS, S = S, lS
    else:
        _, f, c = query.split()
        if f == '1':
            lS += c
        else:
            S += c

print(lS[::-1] + S)

### FIXED CODE ###

S = input()
Q = int(input())

lS = ''
for _ in range(Q):
    query = input().split()
    if query[0] == '1':
        lS, S = S, lS
    else:
        if query[1] == '1':
            lS += query[2]
        else:
            S += query[2]

print(lS[::-1] + S)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
n = int(input())
cs = input()
r_num = 0
w_num = 0
# RRR|WWWW にする

for c in cs:
    if c == 'R':
        r_num += 1
    elif c == 'W':
        w_num += 1

if r_num == 0 or w_num == 0:
    print(0)


else:
    temp_W = 0
    temp_R = 0
    ans = []
    for i in range(len(cs)+1):
        #print('i:', i, cs[i:])
        #print('i_r:', i, cs[:i])
        W = w_num - cs[i:].count("W")
        R = r_num - cs[:i].count("R")
        ans.append(max(W, R))

    print(min(ans))


### FIXED CODE ###

# -*- coding: utf-8 -*-
n = int(input())
cs = input()
r_num = 0
w_num = 0
# RRR|WWWW にする
r_num = cs.count('R')
w_num = cs.count('W')

if r_num == 0 or w_num == 0:
    print(0)
else:
    ans = []
    W = 0
    rl_num = 0
    for c in cs:
        if c == 'R':
            rl_num += 1
        elif c == 'W':
            W += 1
        R = r_num - rl_num
        ans.append(max(W, R))

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

from collections import Counter
s = input()

ans = 0
mods = []
x = int(s)
s = [int(a) for a in s]
for i in range(len(s)+1):
    if i != 0:
        x -= s[i-1] * 10**(len(s)-i)
    a = x%2019
    mods.append(a)

mods = Counter(mods)

for k in mods.keys():
    counts = mods[k]
    ans += counts // 2
print(ans)

### FIXED CODE ###

from collections import Counter
s = input()

ans = 0
mods = [0]
s = [int(a) for a in s[::-1]]
x = 0
for i in range(len(s)):
    x += s[i] * pow(10, i, 2019)
    mods.append(x%2019)

mods = Counter(mods)

for k in mods.keys():
    counts = mods[k]
    ans += counts * (counts-1) // 2
print(ans)
### BUGGY CODE ###

# D - Knapsack Queries on a tree

from sys import stdin

readline = stdin.readline

n = int(readline())

v = [0] * n
w = [0] * n
for i in range(n):
    v[i], w[i] = map(int, readline().split())

max_l = 10 ** 5

# dp table (for some amount)
dp = [None] * min(n, 2 ** 9)

# dp[vertex] = list of (weight, value)
dp[0] = [0 if i < w[0] else v[0] for i in range(max_l + 1)]

for u in range(1, len(dp)):
    parent = (u - 1) // 2
    dp[u] = [max(dp[parent][i], dp[parent][i - w[u]] + v[u])
                if i >= w[u] else dp[parent][i]
                for i in range(max_l + 1)]

def solve(u, l):
    if u < len(dp):
        return dp[u][l]

    parent = (u - 1) // 2
    s = solve(parent, l)
    if l >= w[u]:
        s = max(s, v[u] + solve(parent, l - w[u]))
    return s

q = int(readline())
for i in range(q):
    u, l = map(int, readline().split())
    print(solve(u - 1, l))


### FIXED CODE ###

# D - Knapsack Queries on a tree

from sys import stdin
import bisect

readline = stdin.readline
bisect_right = bisect.bisect_right

n = int(readline())

v = [0] * n
w = [0] * n
for i in range(n):
    v[i], w[i] = map(int, readline().split())

max_l = 10 ** 5
vshift = 21
mask = (1 << vshift) - 1

# dp table (for some amount)
dp = [None] * min(n, 2 ** 12)

# dp[vertex] = list of (weight, value)
dp[0] = [(0 << vshift) + 0, (w[0] << vshift) + v[0]]

for u in range(1, len(dp)):
    parent = (u - 1) // 2

    ls = dp[parent][:]
    ls.extend(x + (w[u] << vshift) + v[u] for x in dp[parent]
              if (x >> vshift) + w[u] <= max_l)
    ls.sort()

    # remove unnecessary entries
    tail = 0
    for i in range(1, len(ls)):
        if (ls[tail] >> vshift) == (ls[i] >> vshift):
            ls[tail] = ls[i]
        elif (ls[tail] & mask) < (ls[i] & mask):
            tail += 1
            ls[tail] = ls[i]
    del ls[tail + 1:]
    dp[u] = ls

def solve(u, l):
    if u < len(dp):
        x = bisect_right(dp[u], (l << vshift) + mask) - 1
        return dp[u][x] & mask

    parent = (u - 1) // 2
    s = solve(parent, l)
    if l >= w[u]:
        s = max(s, v[u] + solve(parent, l - w[u]))
    return s

q = int(readline())
for i in range(q):
    u, l = map(int, readline().split())
    print(solve(u - 1, l))
### BUGGY CODE ###

from collections import deque
"""
-1 -> not visited
else -> step count
"""
def bfs(maze, visited, sh, sw, gh, gw):
    stack = deque([[sh, sw]])
    visited[sh][sw] = 1
    while stack:
        h, w = stack.popleft()
        # ゴールの条件
        if h == gh and w == gw:
            break
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_h, new_w = h+j, w+k
            if new_h < 0 or new_h >= H or \
                new_w < 0 or new_w >= W:
                   continue
            elif maze[new_h][new_w] != "#" and \
                visited[new_h][new_w] == -1:
                    visited[new_h][new_w] = visited[h][w] + 1
                    stack.append([new_h, new_w])
    
    return visited[gh][gw]

if __name__ == "__main__":
    H, W = map(int, input().split())
    maze = [input() for _ in range(H)]

    vd = [[[[0 for _ in range(W)] for _ in range(H)] for _ in range(W)] for _ in range(H)]
    ans = 0
    for sh in range(H):
        for sw in range(W):
            for gh in range(H):
                for gw in range(W):
                    if maze[sh][sw] != "#" and maze[gh][gw] != "#" and vd[sh][sw][gh][gw] == 0 and vd[gh][gw][sh][sw] == 0 and not (gh == sh and gw == sw):
                        if ans >= 1 and (abs(sh - gh) + abs(sw - gw) <= 1):
                            vd[sh][sw][gh][gw] = 1
                            vd[gh][gw][sh][sw] = 1
                        else:
                            vd[sh][sw][gh][gw] = 1
                            vd[gh][gw][sh][sw] = 1
                            visited = [[-1] * W for _ in range(H)]
                            step_cnt = bfs(maze, visited, sh, sw, gh, gw)
                            ans = max(ans, step_cnt)
    print(ans - 1)


### FIXED CODE ###

from collections import deque
"""
-1 -> not visited
else -> step count
"""
def bfs(maze, visited, sh, sw):
    stack = deque([[sh, sw]])
    visited[sh][sw] = 1
    longest = 0
    while stack:
        h, w = stack.popleft()
        # # ゴールの条件
        # if h == gh and w == gw:
        #     break
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_h, new_w = h+j, w+k
            if new_h < 0 or new_h >= H or \
                new_w < 0 or new_w >= W:
                    continue
            elif maze[new_h][new_w] != "#" and \
                visited[new_h][new_w] == -1:
                    visited[new_h][new_w] = visited[h][w] + 1
                    longest = max(longest, visited[new_h][new_w])
                    stack.append([new_h, new_w])
    
    # return visited[gh][gw]
    return longest

if __name__ == "__main__":
    H, W = map(int, input().split())
    maze = [input() for _ in range(H)]

    vd = [[[[0 for _ in range(W)] for _ in range(H)] for _ in range(W)] for _ in range(H)]
    ans = 0
    for sh in range(H):
        for sw in range(W):
            if maze[sh][sw] != "#": 
                visited = [[-1] * W for _ in range(H)]
                step_cnt = bfs(maze, visited, sh, sw)
                ans = max(ans, step_cnt)
    print(ans - 1)
### BUGGY CODE ###

N, M, K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
Asum = []
Bsum = []
a = 0
b = 0
for i in range(N):
    a += A[i]
    Asum.append(a)
for i in range(M):
    b += B[i]
    Bsum.append(b)
Asum.append(0)
Bsum.append(0)
res = 0
for i in range(-1,N):
    if Asum[i] > K:
        break
    for j in range(-1,M):
        if Asum[i] + Bsum[j] > K:
           break
        else:
           res = max(res,(i+j+2))
print(res)

### FIXED CODE ###

N, M, K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
Asum = [0]
Bsum = [0]
a = 0
b = 0
for i in range(N):
    a += A[i]
    Asum.append(a)
for i in range(M):
    b += B[i]
    Bsum.append(b)
Asum.append(0)
Bsum.append(0)
res, j = 0, M
for i in range(N+1):
    if Asum[i] > K:
        break
    while Asum[i] + Bsum[j] > K:
            j -= 1
    res = max(res,i+j)
print(res)
### BUGGY CODE ###

N, x = map(int,input().split())
a = list(map(int,input().split()))

inf = float('inf')
ans = inf

time = [[inf] * N for _ in range(N)]

for i in range(N):
    tmp = inf
    for k in range(N):
        ni = i + k
        if ni > N - 1:
            ni %= N
        tmp = min(tmp, a[ni])
        time[i][k] = tmp

# k回魔法を唱える
for k in range(N):
    res = k*x
    for i in range(N):
        res += time[i][k]
    ans = min(ans, res)

print(ans)

### FIXED CODE ###

N, x = map(int,input().split())
a = list(map(int,input().split()))

inf = float('inf')
ans = inf

time = [[inf] * N for _ in range(N)]

for i in range(N):
    tmp = inf
    for k in range(N):
        ni = i + k
        if ni > N - 1:
            ni %= N
        tmp = min(tmp, a[ni])
        time[i][k] = tmp

# k回魔法を唱える
for k in range(N):
    res = k*x
    for i in range(N):
        res += time[i][k]
    ans = min(ans, res)

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

maxi=-10**99 
n=int(input())
l=[int(i) for i in input().split()]
k=n
for i in range(n-1,2*n):
    z1=l[:i+1]
    z2=l[i+1:]
    #print(z1,z2)
    z1.sort(reverse=1)
    z2.sort()
  #  print(i)
   # print(sum(z1[:k]))
   # print(sum(z2[:k]))
    maxi=max(maxi,sum(z1[:k])-sum(z2[:k]))
print(maxi)


### FIXED CODE ###

maxi=-10**99 
n=int(input())
import heapq 
l=[int(i) for i in input().split()]
k=n
sm=sum(l[0:n])
z1=[0]*(n+1)
z2=[0]*(n+1)
h=[]
z1[0]=sm 
j=1 
heapq.heapify(h)
for i in range(n):
    heapq.heappush(h,l[i])
for i in range(n,2*n):
    p=l[i]
    if p>h[0]: 
        sm+=p 
        sm-=h[0]
        heapq.heappop(h)
        heapq.heappush(h,p)
    else:
        pass 
    z1[j]=sm 
    j+=1 
sm=sum(l[2*n:3*n])
h=[]
heapq.heapify(h)
sm=0 
for i in range(2*n,3*n):
    heapq.heappush(h,-l[i])
    sm+=(l[i])
j=n 
z2[j]=sm  
j-=1 
#print(h[0])
#print(sm)
for i in range(2*n-1,n-1,-1): 
    p=-l[i]
    if p>h[0]:
        #print('jif')
        sm=sm+h[0]-p
        heapq.heappop(h)
        heapq.heappush(h,p)
        
    else:
        pass 
    z2[j]=sm 
    j-=1 
maxi=-(10**99)
#print(z1)
#print(z2)
for i in range(n+1):
    maxi=max(maxi,z1[i]-z2[i])
print(maxi)
### BUGGY CODE ###

#順番考えなくていいかとりあえず試す
m = int(input())
nm = []
for i in range(m):
    di,ci = map(int, input().split( ))
    nm.append([di,ci])
cnt = 0
tmp = 0
while nm:
    ci,di = nm.pop()
    while di:
        cnt += 1
        #print(di,cnt)
        tmp += ci
        di-=1
        if tmp>=10:
            tmp = str(tmp)
            tmp2 = int(tmp[0])+int(tmp[1])
            cnt += 1
            #print(di,cnt)
            tmp = tmp2
print(cnt-1)
    

### FIXED CODE ###

#繰り上がりごとに各桁の総和は9減る
#9*最初の桁数+最初の総和がそれで減る
#それは順番によらない

m = int(input())
sm=  0
d = []
c = []
for i in range(m):
    di,ci = map(int, input().split( ))
    d.append(di)
    c.append(ci)
    sm += di*ci

x = sum(c)*9 + sm
y =  x%9
if y==0:
    y = 9
    
print((x-y)//9-1)
### BUGGY CODE ###

n=int(input())
arr=list(map(int,input().strip().split()))
k=int(input())
for i in range(k):
    sumi=0
    a,b=[int(a) for a in input().split()]
    for j in range(n):
        if(arr[j]==a):
            arr[j]=b
    for i in range(n):
        sumi=sumi+arr[i]
    print(sumi)    
        
    

### FIXED CODE ###

n=int(input())
arr=list(map(int,input().strip().split()))
k=int(input())
d=dict()
for i in range(10**5+1):
    d[i]=0
for i in range(n):
    d[arr[i]]=d[arr[i]]+1
sumi=0
for i in range(n):
    sumi=sumi+arr[i]
for i in range(k):
    a,b=[int(a) for a in input().split()]
    e1=d[a]
    d[b]=d[b]+e1
    sumi=sumi+(e1)*(b-a)
    print(sumi)
    d[a]=0
### BUGGY CODE ###

N=int(input())
S=input()
#print(N,S)

count=0


for n1 in range(10):
 for n2 in range(10):
  for n3 in range(10):
   cond=0 
   for i in range(N):
     if cond==0:
       if n1==int(S[i]):
          cond+=1
     elif cond==1:
       if n2==int(S[i]):
          cond+=1
     else:
       if n3==int(S[i]):
        count+=1
        break
      
              
print(count)


### FIXED CODE ###

N=int(input())
S=input()
#print(N,S)

count=0


for n1 in range(10):
 cond=0
 for i in range(N-2):
   if n1==int(S[i]):
      p1=i
      cond=1
      break
 if cond==1:
  for n2 in range(10):
    for j in range(p1+1,N-1):
      if n2==int(S[j]):
        p2=j
        cond=2
        break
    if cond==2:
     for n3 in range(10):
       #print(n3,S[p2+1:],str(n3) in S[p2+1:] )
       if str(n3) in S[p2+1:]:
        #print(n1,n2,n3)
        count+=1
        cond=0
      
              
print(count)
### BUGGY CODE ###

from collections import deque

def main():
    h, w = map(int, input().split())
    s = [input() for i in range(h)]

    inf = h * w
    dp = [[inf for j in range(w)] for i in range(h)]

    q = deque()
    for i, si in enumerate(s):
        for j, sij in enumerate(si):
            if sij == '#':
                q.append((i, j))
                dp[i][j] = 0

    dijs = list(zip([-1, 0, 1, 0], [0, -1, 0, 1]))
    while q:
        i, j = q.popleft()
        for di, dj in dijs:
            ni = i + di
            nj = j + dj
            if not (0 <= ni < h and 0 <= nj < w): continue
            if dp[ni][nj] <= dp[i][j] + 1: continue
            q.append((ni, nj))
            dp[ni][nj] = dp[i][j] + 1

    print(max(max(dpi) for dpi in dp))

main()

### FIXED CODE ###

from collections import deque

def main():
    h, w = map(int, input().split())
    s = [input() for i in range(h)]

    inf = h * w
    dp = [[inf for j in range(w)] for i in range(h)]

    q = deque()
    for i, si in enumerate(s):
        for j, sij in enumerate(si):
            if sij == '#':
                q.append((i, j))
                dp[i][j] = 0

    dijs = list(zip([-1, 0, 1, 0], [0, -1, 0, 1]))
    while q:
        i, j = q.popleft()
        for di, dj in dijs:
            ni = i + di
            nj = j + dj
            if not (0 <= ni < h and 0 <= nj < w): continue
            if dp[ni][nj] <= dp[i][j] + 1: continue
            q.append((ni, nj))
            dp[ni][nj] = dp[i][j] + 1

    print(max(max(dpi) for dpi in dp))

main()
### BUGGY CODE ###

K = int(input())
i = 1

if K % 5 == 0 or K % 2 == 0:
    i = -1

while True:
    if i == -1:
        break
    N = "7" * i
    N = int(N)
    if N % K != 0:
        i += 1
        continue
    else:
        break
print(i)

### FIXED CODE ###

K = int(input())
i = 1

if K % 5 == 0 or K % 2 == 0:
    i = -1
N = 0
while True:
    if i == -1:
        break
    N = (N * 10 + 7)  %K 
    if N % K != 0:
        i += 1
    else:
        break
print(i)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1000000)

n, q = map(int, input().split())
v = [set() for _ in range(n+1)]
c = [0]*(n+1)

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

for _ in range(q):
  p, x = map(int, input().split())
  c[p] += x

def addcount(p, prev, prec):
  c[p] += prec
  for i in v[p]:
    if i == prev:
      continue
    addcount(i, p, c[p])
  return None
addcount(1, 0, 0)
  
print(*c[1:])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

def input():
  return sys.stdin.readline()[:-1]

n, q = map(int, input().split())
v = [[] for _ in range(n+1)]
c = [0]*(n+1)

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

for _ in range(q):
  p, x = map(int, input().split())
  c[p] += x

def addcount(p, prev):
  for i in v[p]:
    if i != prev:
      c[i] += c[p]
      addcount(i, p)
  return None
addcount(1, 0)
  
print(*c[1:])
### BUGGY CODE ###

#!/usr/bin/env python3
X, Y, A, B, C = [int(str) for str in input().strip().split()]
ps = [int(str) for str in input().strip().split()]
qs = [int(str) for str in input().strip().split()]
rs = [int(str) for str in input().strip().split()]

def f(n):
    if n == 0:
        return sum(red_and_green)
    if n > X + Y:
        return sum(rs)
    return sum(red_and_green[:-n] + rs[:n])

ps.sort(reverse=True)
qs.sort(reverse=True)
rs.sort(reverse=True)

red_and_green = ps[:X] + qs[:Y]
red_and_green.sort(reverse=True)

# print([f(i) for i in range(C)])
print(max([f(i) for i in range(C + 1)]))

### FIXED CODE ###

#!/usr/bin/env python3
X, Y, A, B, C = [int(str) for str in input().strip().split()]
ps = [int(str) for str in input().strip().split()]
qs = [int(str) for str in input().strip().split()]
rs = [int(str) for str in input().strip().split()]

def sums(li):
    ret = [0]
    for i in range(len(li)):
        ret.append(ret[-1] + li[i])
    return ret

def f(n):
    return red_and_green_sums[X + Y - n] + r_sums[n]

ps.sort(reverse=True)
qs.sort(reverse=True)
rs.sort(reverse=True)

r_sums = sums(rs)

red_and_green = ps[:X] + qs[:Y]
red_and_green.sort(reverse=True)
red_and_green_sums = sums(red_and_green)

# print([f(i) for i in range(C)])
print(max([f(i) for i in range(min(X + Y, C) + 1)]))
### BUGGY CODE ###

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

ans = 10 ** 6

for i in range(n-1):
    left = s[:i].count("W")
    right = s[i+1:].count("E")

    ans = min(ans, left+right)

print(ans)

### FIXED CODE ###

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

l = [0]
r = [0]

for i in s:
    if i == "W":
        l.append(l[-1] + 1)
    else:
        l.append(l[-1])

for i in s[::-1]:
    if i == "E":
        r.append(r[-1] + 1)
    else:
        r.append(r[-1])

l = l[1:]
r = r[1:][::-1]

ans = 10 ** 9

for i in zip(l, r):
    ans = min(sum(i), ans)

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

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

point = 1
for i in range(k):
    point *= a[i]

for i in range(k, n):
    now = point
    now //= a[i - k]
    now *= a[i]
    if now > point:
        print('Yes')
    else:
        print('No')
    point = now

### FIXED CODE ###

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

point = 0
for i in range(n):
    if k > i:
        point += a[i]
        continue
    now = point
    now -= a[i - k]
    now += a[i]
    if now > point:
        print('Yes')
    else:
        print('No')
    point = now
### BUGGY CODE ###

n = int(input())
ns = list(map(int, input().split()))

s = 1
for i in ns:
    s=s*i
if s > 10**18:
    print(-1)
else:
    print(s)

### FIXED CODE ###

n = int(input())
ns = list(map(int, input().split()))

if 0 in ns:
  print(0)
  exit()

s = 1
for i in ns:
  s=s*i
  if s > 10**18:
    print(-1)
    exit()

print(s)
### BUGGY CODE ###

n,m = map(int,input().split())
a_ls = [int(input()) for _ in range(m)]

dp = [0] * (n+1)
dp[0] = 1
for i in range(n):
    if i+1 not in a_ls and i not in a_ls:
        if dp[i + 1] == 0:
            dp[i+1] = dp[i]
        else:
            dp[i+1] = dp[i+1] + dp[i]
    if i+2 <= n and i+2 not in a_ls and i not in a_ls:
        if dp[i + 2] == 0:
            dp[i+2] = dp[i]
        else:
            dp[i+2] = dp[i+2] + dp[i]
print(dp[-1] % 1000000007)

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

mod = 1000000007

n,m = map(int,input().split())
good = [True] * (n+1)
for _ in range(m):
    x = int(input())
    good[x] = False

dp = [0] * (n+1)
dp[0] = 1

for i in range(n):
    # 出発点になれるなら、のみでOK
        # Falseの部分が更新されることはあっても、出発点になれないから
    if good[i]:
        if i+1 <= n:
            dp[i+1] += dp[i]
            dp[i+1]%= mod
        if i+2 <= n:
            dp[i+2] += dp[i]
            dp[i+2] %= mod

print(dp[n])
### BUGGY CODE ###

n = int(input())
A = [int(input()) for _ in range(n)]
sec = []
count, cur = 0, 1
while cur not in sec:
    sec.append(cur)
    if cur == 2:
        break
    cur = A[cur - 1]
    count += 1
print(count if 2 in sec else -1)

### FIXED CODE ###

n = int(input())
A = [int(input()) for _ in range(n)]
count, current = 0, 1
while current != 2:
    current = A[current - 1]
    count += 1
    if count > n:
        count = -1
        break
print(count)