Harryxun/stf_run huggingface dataset:
N,K = map(int,input().split())
D = list(map(int,input().split()))
E = []
for i in range(10):
    if i not in D:
        E.append(i)
E = sorted(E)
N = str(N)
ind = len(N)
for i in range(len(N)):
    if int(N[i]) not in E:
        ind = i
        break
if ind==len(N):
    print(N)
else:
    flag = 0
    x = ""
    for i in range(ind-1,-1,-1):
        n = int(N[i])
        if n==E[-1]:continue
        else:
            for e in E:
                if e>n:
                    x = N[:i]+str(e)+str(E[0])*(len(N)-i-1)
                    flag = 1
                    break
            if flag==1:break
    if flag==0:
        for e in E:
            if e>int(N[0]):
                a = e
                flag = 1
                break
        x = str(a)+str(E[0])*(len(N)-1)
        if flag==0:
            if E[0]>0:
                a = E[0]
            else:
                a = E[1]
            x = str(a)+str(E[0])*len(N)
    print(x)

### FIXED CODE ###

import itertools
N,K = map(int,input().split())
D = list(map(int,input().split()))
A = []
for i in range(10):
    if i not in D:
        A.append(i)
cmin = 100000
k = len(str(N))
for i in range(k,6):
    for x in itertools.product(A,repeat=i):
        cnt = 0
        for j in range(i):
            cnt += x[j]*10**(i-1-j)
        if cnt>=N:
            cmin = min(cmin,cnt)
print(cmin)
def gcd(a,b):
	while(y):
		x,y = y,x%y
	return x
k = int(input())
ans=0
for a in range(1,k+1):
	for b in range(1,k+1):
		for c in range(1,k+1):
			ans+=gcd(a,gcd(b,c))

print(ans)

### FIXED CODE ###

def gcd(a,b):
	while(b):
		a,b = b,a%b
	return a
k = int(input())
ans=0
for a in range(1,k+1):
	for b in range(1,k+1):
		for c in range(1,k+1):
			ans+=gcd(a,gcd(b,c))

print(ans)
import sys

lines = []
for line in sys.stdin:
    lines.append(line.strip().split(','))

field = [[0 for i in range(10)] for j in range(10)]

def drop(x, y, z):
    if z==1:
        for i in range(-1,2):
            for j in range(-1,2):
                if abs(i)+abs(j)<2 and 0<=y+j<=10 and 0<=x+i<=10:
                    field[y+j][x+i] += 1
    elif z==2:
        for i in range(-1,2):
            for j in range(-1,2):
                if 0<=y+j<=10 and 0<=x+i<=10:
                    field[y+j][x+i] += 1
    elif z==3:
        for i in range(-2,3):
            for j in range(-2,3):
                if abs(i)+abs(j)<3 and 0<=y+j<=10 and 0<=x+i<=10:
                    field[y+j][x+i] += 1



for line in lines:
    x,y,z = map(int, line)
    drop(x,y,z)

n = 0
m = 0
for f in field:
    for e in f:
        if e > m:
            m = e
        if e==0:
            n+=1

print(n)
print(m)



### FIXED CODE ###

import sys

lines = []
for line in sys.stdin:
    lines.append(line.strip().split(','))

field = [[0 for i in range(10)] for j in range(10)]

def drop(x, y, z):
    if z==1:
        for i in range(-1,2):
            for j in range(-1,2):
                if abs(i)+abs(j)<2 and 0<=y+j<=9 and 0<=x+i<=9:
                    field[y+j][x+i] += 1
    elif z==2:
        for i in range(-1,2):
            for j in range(-1,2):
                if 0<=y+j<=9 and 0<=x+i<=9:
                    field[y+j][x+i] += 1
    else:
        for i in range(-2,3):
            for j in range(-2,3):
                if abs(i)+abs(j)<3 and 0<=y+j<=9 and 0<=x+i<=9:
                    field[y+j][x+i] += 1



for line in lines:
    x,y,z = map(int, line)
    drop(x,y,z)

n = 0
m = 0
for f in field:
    for e in f:
        if e > m:
            m = e
        if e==0:
            n+=1

print(n)
print(m)
x1, y1, x2, y2 = map(int, input().split())

a, b = abs(x2 - x1), abs(y1 - y2)

if (x1 <= x2)and(y1 <= y2):
    x3, y3 = x2 - b, y2 + a
    x4, y4 = x3 - a, y3 - b
elif (x1 > x2)and(y1 < y2):
    x3, y3 = x2 - b, y2 - a
    x4, y4 = x3 + a, y3 - b
elif (x1 > x2)and(y1 > y2):
    x3, y3 = x2 + b, y2 - a
    x4, y4 = x3 + a, y3 + b
elif (x1 < x2)and(y1 > y2):
    x3, y3 = x2 + b, y2 + a
    x4, y4 = x3 - a, y3 + b


print("{} {} {} {}".format(x3, y3, x4, y4))

### FIXED CODE ###

x1, y1, x2, y2 = map(int, input().split())

a, b = abs(x2 - x1), abs(y1 - y2)

if (x1 <= x2)and(y1 <= y2):
    x3, y3 = x2 - b, y2 + a
    x4, y4 = x3 - a, y3 - b
elif (x1 >= x2)and(y1 <= y2):
    x3, y3 = x2 - b, y2 - a
    x4, y4 = x3 + a, y3 - b
elif (x1 >= x2)and(y1 >= y2):
    x3, y3 = x2 + b, y2 - a
    x4, y4 = x3 + a, y3 + b
elif (x1 <= x2)and(y1 >= y2):
    x3, y3 = x2 + b, y2 + a
    x4, y4 = x3 - a, y3 + b

print(x3, y3, x4, y4)
from math import ceil, sqrr

n = int(input())
print(ceil(sqrt(n)) ** 2)

### FIXED CODE ###

n = int(input())
lo, hi = 1, n

while hi - lo > 1:
  x = (hi + lo) // 2
  if x * x > n:
    hi = x
  else:
    lo = x

print(lo * lo)
a=map(int,input().split())
print(max([2*a[0]-1,2*a[1]-1,a[0]+a[1]])

### FIXED CODE ###

a=list(map(int,input().split()))
print(max([2*a[0]-1,2*a[1]-1,a[0]+a[1]]))
import numpy as np

N = int(input())
a = np.fromstring(input(), sep=" ", dtype=np.int64)
b = np.bitwise_xor.reduce(a)
c = np.bitwise_xor(a, b)
print(*c, sep=" ")


### FIXED CODE ###

a = input()
if(a == a.upper()):
    print("A")
else:
    print("a")
S = str(input())
T = str(input())
alp = "abcdefghijklmnopqrstuvwxyz"
for i in range(0,10**7):
  if S[i] != T[i]:
    S = S.translate(str.maketrans({S[i]:T[i], T[i]:S[i]}))
  if S == T:
    print("Yes")
    exit()
print("No")

### FIXED CODE ###

S = str(input())
T = str(input())
alp = "abcdefghijklmnopqrstuvwxyz"
for i in range(0,min(len(S),len(alp)*2)):
  if S[i] != T[i]:
    S = S.translate(str.maketrans({S[i]:T[i], T[i]:S[i]}))
  else:
    pass
  if S == T:
    print("Yes")
    exit()
print("No")
import math

a, b = input().split()

a = int(a)
b = float(b)

print(math.fllor(a*b))

### FIXED CODE ###

from decimal import *

a, b = map(Decimal, input().split())

print(int(a*b))
a, b = int(input().split())

if a >= b:
    c = a - 1
    k = max(c,b)
    print(a+k)

else:
    c = b - 1
    k = max(a,c)
    print(b+k)

### FIXED CODE ###

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

if a >= b:
    print(a + max(a-1, b))

else:
    print(b + max(a, b-1))
n = int(input())
a = ""
b = 0
l = []

for i in range(1,n+1):
    a,b = map(str,input().split())
    b = int(b)
    l.append([a,b,i])
l.sort()

pprint.pprint(l)

for i in range(n):
    print(l[i][2])


### FIXED CODE ###


n = int(input())
sp = [list(input().split())+[i+1] for i in range(n)]
sp = [[s,-int(p),i] for s,p,i in sp]

sp.sort()

for s,p,i in sp:
    print(i)

"""
from operator import itemgetter

n = int(input())
l = []

for i in range(n):
    s,p = map(str,input().split())
    p = int(p)
    l.append([s,p,i+1])

l.sort(key = itemgetter(0))
l = sorted(l, key = lambda x:(x[1]),reverse = True)
print(l)
"""
from itertools import permutations

def f(n, m, uu, vv):
    a = [[0] * n for _ in range(n)]
    for u, v in zip(uu, vv):
        a[u][v] = 1
        a[v][u] = 1
    res = 0
    for p in permutations(range(n)):
        if p[0] != 0:
            break
        ok = True
        for i in range(n-1):。
            if a[p[i][p[i+1]] == 0:
                ok = False
                break
        if ok:
            res += 1
    return res


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

print(f(n, m, a, b))


### FIXED CODE ###

from itertools import permutations

def f(n, m, uu, vv):
    a = [[0] * n for _ in range(n)]
    for u, v in zip(uu, vv):
       
        a[u][v] = 1
        a[v][u] = 1
 
    res = 0
    for p in permutations(range(n)):
        if p[0] != 0:
            break
     
        ok = True
        for i in range(n-1):
            if a[p[i]][p[i+1]] == 0:
                ok = False
                break
        if ok:
            res += 1
    return res


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

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

print(f(n, m, a, b))
n=input()
m=n[::-1]
if n=m:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

n=input()
m=n[::-1]
if n==m:
  print("Yes")
else:
  print("No")
a,b=map(int,input().split())
import math
c=[]
b+=(a-1)
for i in range(math.abs(b-a)+1):
  
  c+=b
  b-=1
print(int(c))


### FIXED CODE ###

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

for i in range(b-(a-1),b+(a-1)+1):
  print(i,end=" ")
l = [int(input())for i in range(5)]
l1 = []*5
ans = 0
for i in range(5):
    l1[i] = l[i]%10
for i in range(5):
    ans += -(-l[i]//10)
print(ans*10 + min(l1))

### FIXED CODE ###

l = [int(input())for i in range(5)]
l1 = ['']*5
ans = 0
for i in range(5):
    l1[i] = l[i]%10
    if l1[i] == 0:
        l1[i] = 10
for i in range(5):
    ans += -(-l[i]//10)
print(ans*10 - 10 + min(l1))
import sys
# 再帰回数上弦を100000回に設定
sys.setrecursionlimit(100000)

n,k = map(int,input().split())
line = list(map(int,input().split()))
 
inf = float('inf')
line.extend([inf for i in range(k)])
box = [inf for i in range(n + k)]
#out of rangeを避けるため
  
def frog(x):
  box[0] = 0
  if x == n-1:
    return box[n-1]
  else:    
    for i in range(1,k+1):
      cost = abs(line[x] - line[x+i])
      if box[x+i] >= box[x] + cost:
        box[x+i] = box[x] + cost
    return frog(x+1)
print(frog(0))

### FIXED CODE ###

n,k = map(int,input().split())
line = list(map(int,input().split()))
 
inf = float('inf')
line.extend([inf for i in range(k)])
box = [inf for i in range(n + k)]
#out of rangeを避けるため

box[0] = 0
for x in range(n):   
  for i in range(1,k+1):
    cost = abs(line[x] - line[x+i])
    if box[x+i] >= box[x] + cost:
      box[x+i] = box[x] + cost
print(box[n-1])
n = int(input())
h = list(map(int,input().split()))

ans = 'Yes'
level = h[0]
for i in range(n-1):
  diff = h[i+1]-h[i]
  if diff <= -1:
    if flag:
      ans='No'
      break        
    
    if diff <= -3:
      ans = 'No'
      break
        
    flag = True      
    level = h[i+1] 
    
    if i == n-2 and diff <= -2:
      ans ='No'
    
  else:
    if diff >= 1:
      flag = False

print(ans)      

### FIXED CODE ###

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

ans = 'Yes'
flag = False
for i in range(n-1):
  diff = h[i+1]-h[i]
  if diff <= -1:
    if flag:
      ans='No'
      break        
    
    if diff <= -2:
      ans = 'No'
      break
        
    flag = True          
    
  else:
    if diff >= 1:
      flag = False

print(ans)
x, y = map(int, input().split("  "))
X, Y = map(int, input().split("  "))
print{(x-X)*(y-Y)}

### FIXED CODE ###

H,W = map(int, input().split(" "))
h,w = map(int, input().split(" "))
print((H-h)*(W-w))
N=int(input())
xy=list(sorted([list(map(int, input().split())) for _ in range(N)]))

diff={}
for i in range(N):
    for j in range(i+1, N):
        a=(xy[i][0]-xy[j][0], xy[i][1]-xy[j][1])
        diff[a]=diff.get(a,0)+1
# print(diff)
print(N-max(diff.values()))

### FIXED CODE ###

N=int(input())
xy=list(sorted([list(map(int, input().split())) for _ in range(N)]))

if N==1:
    print(1)
    exit(0)
diff={}
for i in range(N):
    for j in range(i+1, N):
        a=(xy[i][0]-xy[j][0], xy[i][1]-xy[j][1])
        diff[a]=diff.get(a,0)+1
print(N-max(diff.values()))
#ABC157 Guess the number
n,m = map(int,input().split())
sc = [input().split() for _ in range(m)]
ans = []
for i in range(0,10**n):
    cnt = 0
    seq = str(i)
    for j in range(m):
        if seq[int(sc[j][0])-1] == sc[j][1]:
            print(seq[int(sc[j][0])-1])
            cnt += 1
    if cnt == m:
        ans.append(i)
        
if len(ans) == 0:
    print('-1')
else:
    print(min(ans))

### FIXED CODE ###

#ABC157 Guess the number
n,m = map(int,input().split())
sc = [input().split() for _ in range(m)]
ans =[]

if n == 1:
    if len(sc)== 0:
        print('0')
    else:
        ans = []
        for i in range(m):
            ans.append(sc[i][1])
        if len(set(ans)) == 1:
            print(ans[0])
        else:
            print('-1')
    
else:
    for i in range(10**(n-1),10**n):
        cnt = 0
        seq = str(i)
        for j in range(m):
            if seq[int(sc[j][0])-1] == sc[j][1]:
                cnt += 1
        if cnt == m:
            ans.append(i)
        
    if len(ans) == 0:
        print('-1')
    else:
        print(min(ans))
n,m = map(int,input().split())
l = [0]*m
for i in range(n):
  a = list(map(int,input().split()))
  for i in range(1,a[0]+1):
    l[a[i-1]] += 1
count = 0
for i in l:
  if i == n:
    count += 1
print(count)

### FIXED CODE ###

n,m = map(int,input().split())
l = [0]*m
for i in range(n):
  a = list(map(int,input().split()))
  for i in range(1,a[0]+1):
    l[a[i]-1] += 1
count = 0
for i in l:
  if i == n:
    count += 1
print(count)
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

A,B,C,X,Y = LI()

# only = A*X+B*Y
# only_mix = C*max(X,Y)*2
# comp = 0
# if X > Y:
#     comp = C*Y*2+A*(X-Y)
# elif X < Y:
#     comp = C*X*2+B*(Y-X)
# else:
#     comp = C*Y*2

# print(min(only,only_mix,comp))

ans = float('INF')
for i in range(max(X,Y)+1):
    price = A+max(X-i,0)+B*max(Y-i,0)+C*2*ians 
    ans = min(ans,price)

price(ans)

### FIXED CODE ###

import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

A,B,C,X,Y = LI()

only = A*X+B*Y
only_mix = C*max(X,Y)*2
comp = 0
if X > Y:
    comp = C*Y*2+A*(X-Y)
elif X < Y:
    comp = C*X*2+B*(Y-X)
else:
    comp = C*Y*2

print(min(only,only_mix,comp))
from sys import stdin

input = stdin.readline

n, k = map(int, input().split())
a = [int(x) for x in input().split()]
vote = sum(a) / 4 / m

a.sort()
a.reverse()

print("Yes" if a[m - 1] >= vote else "No")

### FIXED CODE ###

from sys import stdin
 
input = stdin.readline
 
n, m = map(int, input().split())
a = [int(x) for x in input().split()]
vote = sum(a) / 4 / m
 
a.sort()
a.reverse()
 
print("Yes" if a[m - 1] >= vote else "No")
"""
[a,b]=list(map(float,input().split()))
import math
a=int(a)
b=int(b*100)
ans=a*b
ans=ans/100
ans=math.floor(ans)
print(ans)
"""
import decimal
[a,b]=list(input().split())
a10=decimal.Decimal(a)
b10=decimal.Decimal(b)
ans=int(a10*b10)
print(ans)


"""
[a,b]=list(input().split())
a=int(a)
b12=list(b.split('.'))
bkai=int(int(b12[0])*100+int(b12[1]))
ans=a*bkai
ans=ans//100
print(ans)

### FIXED CODE ###

"""
[a,b]=list(map(float,input().split()))
import math
a=int(a)
b=int(b*100)
ans=a*b
ans=ans/100
ans=math.floor(ans)
print(ans)
"""
[a,b]=list(input().split())
a=int(a)
b12=list(b.split('.'))
bkai=int(int(b12[0])*100+int(b12[1]))
ans=a*bkai
ans=ans//100
print(ans)
from collections import deque, defaultdict
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000000)
n = int(input())
edges = defaultdict(lambda : defaultdict(lambda: False))
for i in range(n-1):
    a, b = map(int, input().split())
    edges[a][b] = True
    edges[b][a] = True

nums = [deque() for _ in range(3)]
for i in range(1, n+1):
    nums[i%3].append(i)

ans = [0 for _ in range(n)]
def dfs(idx, pre_3, pre_2, pre_1):
    if pre_1 == -1:
        if pre_1 % 3 == 2 and len(edges[1]) > 0:
            out = edges[1].pop()
        elif pre_1 % 3 == 1 and len(edges[2]) > 0:
            out = edges[2].pop()
        else:
            out = edges[0].pop()
    else:
        if pre_1 % 3 != 0:
            if pre_1 % 3 == 2 and len(edges[1]) > 0:
                out = nums[1].pop()
            elif pre_1 % 3 == 1 and len(edges[2]) > 0:
                out = nums[2].pop()
            else:
                if len(edges[0]) > 0:
                    out = edges[0].pop()
                else:
                    print(-1)
                    exit()
        else:
            if len(edges[1]) > 0:
                out = nums[1].pop()
            elif len(edges[2]) > 0:
                out = nums[2].pop()
            else:
                if len(edges[0]) > 0:
                    out = edges[0].pop()
                else:
                    print(-1)
                    exit()
    ans[idx-1] = out
    for k in edges[idx].keys():
        if ans[k-1] == 0:
            dfs(step+1, k, pre_2, pre_1, out)

for i in range(1, n+1):
    if len(edges[i]) == 1:
        dfs(1, i, -1, -1, -1)
        break

print(" ".join(list(map(str, ans))))

### FIXED CODE ###

from collections import deque, defaultdict
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000000)

n = int(input())
edges = defaultdict(lambda : defaultdict(lambda: False))
for i in range(n-1):
    a, b = map(int, input().split())
    edges[a][b] = True
    edges[b][a] = True

nums = [deque() for _ in range(3)]
for i in range(1, n+1):
    nums[i%3].append(i)

color = [-1 for _ in range(n)]
cnts = [0 for _ in range(2)]
def coloring(num, pre_color):
    if pre_color:
        col = 0
    else:
        col = 1
    color[num-1] = col
    cnts[col] += 1
    for k in edges[num].keys():
        if color[k-1] == -1:
            coloring(k, col)

coloring(1, 1)

ans = [0 for _ in range(n)]
def solve(v):
    for i in range(n):
        if color[i] == v:
            ans[i] = nums[0].pop()
        else:
            for j in [1, 2, 0]:
                if len(nums[j]) > 0:
                    ans[i] = nums[j].pop()
                    break

if cnts[0] <= n // 3:
    # print("A")
    solve(0)
elif cnts[1] <= n // 3:
    # print("B")
    solve(1)
else:
    # print("C")
    for i in range(n):
        if color[i]:
            if len(nums[1]) > 0:
                ans[i] = nums[1].pop()
            else:
                ans[i] = nums[0].pop()
        else:
            if len(nums[2]) > 0:
                ans[i] = nums[2].pop()
            else:
                ans[i] = nums[0].pop()

print(" ".join(list(map(str, ans))))
import sys

letter="abcdefghijklmnopqrstuvwxyz"
table=[]*26
input_str=sys.stdin.read()

for A in input_str:
    index=0
    for B in letter:
        if A == B or A == B.upper():
            table[index] += 1
            break
        index += 1

for i in ragne(len(letter)):
    print("%s : %d"%(letter[i],table[i]))



### FIXED CODE ###

letter="abcdefghijklmnopqrstuvwxyz"
table=[0]*26
while True:
    try:
        input_str=input()
    except:
        break
    for A in input_str:
        index=0
        for B in letter:
            if A == B or A == B.upper():
                table[index] += 1
                break
            index += 1

for i in range(len(letter)):
    print("%s : %d"%(letter[i],table[i]))
s = list(input())
t = list(input())

st = list(zip(s, t))
st.sort(key=lambda x:x[1])
dic_ST = set()
ans = "Yes"

for i in range(len(s)-1):
    if st[i][1] == st[i+1][1]:
        if st[i][0] != st[i+1][0]:
            ans = "No"
        if st[i][0] in dic_ST:
            ans = " No"
    else:
        dic_ST.add(st[i][0])

if st[-2][1] == st[-1][1]:
    if st[-2][0] != st[-1][0]:
        ans = "No"
    if st[-1][0] in dic_ST:
        ans = " No"
else:
    dic_ST.add(st[-1][0])

print(ans)

### FIXED CODE ###

from collections import Counter
s=input()
t=input()
list_S=Counter(s)
list_T=Counter(t)

if sorted(list_S.values()) == sorted(list_T.values()):
    print("Yes")
else:
    print("No")
n = int(input())
memo = [{} for i in range(N+1)]
m = 10**9+7

def ppp(l):
    for i in range(4):
        t = list(l)
        if i >= 1:
            t[i-1],t[i] = t[i],t[i-1]
        if "".join(t).count("AGC") >= 1:
            return False
        return True
def dfs(c,l):
    if l in memo[c]:
        return memo[c][l]
    if c == n:
        return 1
    ret = 0
    for b in "AGCT":
        if ppp(l+b):
            ret = (ret + dfs(c + 1,l[1:] + c)) % m
    memo[c][l] = ret
    return ret
print(dfs(0,"TTT"))

### FIXED CODE ###

n = int(input())
memo = [{} for i in range(n+1)]
m = 10**9+7

def ppp(l):
    for i in range(4):
        t = list(l)
        if i >= 1:
            t[i-1],t[i] = t[i],t[i-1]
        if "".join(t).count("AGC") >= 1:
            return False
    return True
def dfs(c,l):
    if l in memo[c]:
        return memo[c][l]
    if c == n:
        return 1
    ret = 0
    for b in "AGCT":
        if ppp(l+b):
            ret = (ret + dfs(c + 1,l[1:] + b)) % m
    memo[c][l] = ret
    return ret
print(dfs(0,"TTT"))
S = input()
s = t = 0
for c in S:
    if c == 'S':
        s += 1
    else:
       if s > 0:
           s -= 1
       else:
           t += 1
print(s+t)
＃コピペです


### FIXED CODE ###

x = list(input())
c = 0
for i in x:
  if i == "S":
    c += 1
  elif c>0:
    c -= 1
print(2*c)
n,m = map(int, input().split())
listA = [int(input()) for i in range(m)]
listB = [0]*(n+1)
for k in range(m):
    listB[listA[k]] = 1
if(listB[1]==1 and listB[2]==1):
    a,b = 0,0
elif(listB[1]==1):
    a,b = 0,1
elif(listB[2]==1):
    a,b = 1,0
else:
    a,b = 1,2

for j in range(1, n-1):
    if(listB[j+2]!=0):
        a,b = b,0
    if(listB[j+2]==0):
        a,b = b,a+b

print(b%1000000007)

### FIXED CODE ###

n,m = map(int, input().split())
listA = [int(input()) for i in range(m)]
listB = [0]*(n+2)
for k in range(m):
    listB[listA[k]] = 1
if(n==1 and listB[1]==0):
    a,b = 1,1
elif(n==1 and listB[1]==1):
    a,b = 0,0
elif(listB[1]==1 and listB[2]==1):
    a,b = 0,0
elif(listB[1]==1):
    a,b = 0,1
elif(listB[2]==1):
    a,b = 1,0
else:
    a,b = 1,2

for j in range(1, n-1):
    if(listB[j+2]!=0):
        a,b = b,0
    if(listB[j+2]==0):
        a,b = b,a+b

print(b%1000000007)
import numpy as np
l = list(map(int, input().split()))
n = l[0]
A = np.array(l[1:])
for i in range(n):
  m = np.max(A)
  if A[i] == m:
    mask = A != A[i]
    print(np.max(A[mask]))
  else:
    print(m)

### FIXED CODE ###

import numpy as np
n = int(input())
A = np.array([int(input()) for i in range(n)])
idxs = np.argsort(A)
m1 = A[idxs[-1]]
m2 = A[idxs[-2]]
for i in range(n):
  if i != idxs[-1]:
    print(m1)
  else:
    print(m2)
def solve():
    S = input()
    # print(S, len(S))

    S = S[::-1]
    words = ("dream"[::-1], "dreamer"[::-1], "erase"[::-1], "eraser"[::-1])

    def recur(i):
        if i >= len(S):
            return True

        for word in words:
            if S[i:i + len(word)] == word:
                if recur(i + len(word)):
                    return True
        return False

    ans = recur(0)

    return ans


if __name__ == '__main__':
    res = solve()
    if res:
        print("YES")
    else:
        print("NO")


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)


def solve():
    S = input()
    # print(S, len(S))

    words = {0: "dream", 1: "dreamer", 2: "erase", 3: "eraser"}

    TABLE = [[-1 for x in range(len(S) + 1)] for y in range(len(words) + 1)]

    def recur(i, w):
        if not TABLE[w][i] == -1:
            return TABLE[w][i]

        if i >= len(S):
            # print("jey", log)
            return True

        r1, r2, r3, r4 = False, False, False, False
        if S[i:i + 5] == words[0]:
            r1 = recur(i + 5, 0)
        if S[i:i + 7] == words[1]:
            r2 = recur(i + 7, 1)
        if S[i:i + 5] == words[2]:
            r3 = recur(i + 5, 2)
        if S[i:i + 6] == words[3]:
            r4 = recur(i + 6, 3)

        TABLE[w][i] = r1 or r2 or r3 or r4 or False

        return TABLE[w][i]

    ans = recur(0, 0)

    return ans


if __name__ == '__main__':
    res = solve()
    if res:
        print("YES")
    else:
        print("NO")