Harryxun/stf_run huggingface dataset:
sys.setrecursionlimit(10000)
def func(x):

    if len(x) == 0:
        return True
    elif len(x) < 5:
        return False
    else:
        tmp = False
        if x[:5] == "dream":
            tmp = func(x[5:])

        if x[:7] == "dreamer" and not tmp:
            tmp = func(x[7:])

        if x[:5] == "erase" and not tmp:
            tmp = func(x[5:])

        if x[:6] == "eraser" and not tmp:
            tmp = func(x[6:])

    return tmp

def solve(n):

    ans = func(n)
    return "YES" if ans else "NO"

if __name__ == "__main__":
    n = input()
    print(solve(n))


### FIXED CODE ###

def solve(n):

    while len(n) > 4:
        if n[-5:] == "dream":
            n = n[:-5]
        elif n[-7:] == "dreamer":
            n = n[:-7]
        elif n[-5:] == "erase":
            n = n[:-5]
        elif n[-6:] == "eraser":
            n = n[:-6]
        else:
            break

    return "YES" if len(n) == 0 else "NO"

if __name__ == "__main__":
    n = input()
    print(solve(n))
import math

n = list(map(int, input().split()))
n = n[0]
a = list(map(int, input().split()))

left=[0 for i in range(n)]
right=[0 for i in range(n)]
left[0] = a[0]
right[-1] = a[-1]
for i in range(n-2):
    left[i+1] = math.gcd(left[i],a[i+1])
    right[-i-2] = math.gcd(right[-i-1],a[-i-1])

gcds=[left[n-2], right[1]]
for i in range(n-2):
    gcds.append(math.gcd(left[i], right[i+2]))
print(max(gcds))

### FIXED CODE ###

import fractions

n = list(map(int, input().split()))
n = n[0]
a = list(map(int, input().split()))

left=[0 for i in range(n)]
right=[0 for i in range(n)]
left[0] = a[0]
right[-1] = a[-1]
for i in range(n-2):
    left[i+1] = fractions.gcd(left[i],a[i+1])
    right[-i-2] = fractions.gcd(right[-i-1],a[-i-2])

gcds=[left[n-2], right[1]]
for i in range(n-2):
    gcds.append(fractions.gcd(left[i], right[i+2]))

print(max(gcds))
ans=[]
W=raw_input()
while True:
    i = raw_input()
    if i == 'END_OF_TEXT': break
    ans+=[j.lower() for j in i.split()]
print ans.count(W)


### FIXED CODE ###

W=input().lower()
cnt=0
while True:
    T=input()
    if T=='END_OF_TEXT': break
    cnt += T.lower().split().count(W)
print(cnt)
A, B, K = map(int, input().split())
l = []
for i in range(1, max(A, B)):
  if A % i == 0 and B % i == 0:
    l.append(i)
    
l.sort(reverse=True)
print(l[K-1])

### FIXED CODE ###

A, B, K = map(int, input().split())
l = []
for i in range(1, max(A, B)+1):
  if A % i == 0 and B % i == 0:
    l.append(i)
    
l.sort(reverse=True)
print(l[K-1])
n=int(input())
a=list(map(int,input().split()))
l=1
for i in range(n):
    l*=a[i]
    if j>10**18:
        break
if l>10**18:
    print(-1)
else:
    print(l)

### FIXED CODE ###

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

for i in range(n):
    l*=a[i]
    if l>10**18:
        break
if min(a)==0:
    print(0)
elif l>10**18:
    print(-1)
else:
    print(l)
a=map(str, input())
char=list(a)
b=set(char)
c=len(b)
if c=2:
	print("Yes")
else:
  print("No")
  
  

### FIXED CODE ###

a=map(str, input())
char=list(a)
b=set(char)
c=len(b)
if c==2:
	print("Yes")
else:
  print("No")
import math
A, B = map(int,input().split())
LA = []
LB = []
for i in range(int(math.log2(A))+1):
    P = A % (2**(i+1))
    Q = P % (2**i)
    R = (P-Q)//(2**i)
    LA.append(R)
for i in range(int(math.log2(B))+1):
    P = B % (2**(i+1))
    Q = P % (2**i)
    R = (P-Q)//(2**i)
    LB.append(R)
LS = []
def Q(a,b):
    return (a%2,b%2)
if Q(A,B) == (0,0):
    LS.append(((B-A)//2)%2)
    for i in range(1,len(LA)):
        LS.append(LB[i])
    if len(LB) > len(LA):
        for i in range(len(LA),len(LB)):
            LS.append(LB[i])
elif Q(A,B) == (0,1):
    LS.append(((B-A+1)//2)%2)
    for i in range(1,len(LA)):
        LS.append(0)
    if len(LB) > len(LA):
        for i in range(len(LA),len(LB)):
            LS.append(0)
elif Q(A,B) == (1,0):
    LS.append(((B-A+1)//2)%2)
    for i in range(1,len(LA)):
        LS.append((LA[i]+LB[i])%2)
    if len(LB) > len(LA):
        for i in range(len(LA),len(LB)):
            LS.append(LB[i])
else:
    LS.append(((B-A+2)//2)%2)
    for i in range(1,len(LA)):
        LS.append(LA[i])
    if len(LB) > len(LA):
        for i in range(len(LA),len(LB)):
            LS.append(0)
            
ANS = 0
for i in range(len(LS)):
    ANS += (2**i)*LS[i]
    
print(ANS)

### FIXED CODE ###

import math
A, B = map(int,input().split())
if A == 0:
    if B % 4 ==0:
        print(B)
    elif B % 4 == 1:
        print(1)
    elif B % 4 == 2:
        print(B+1)
    else:
        print(0)
elif A == B:
    print(A)
else:
    LA = []
    LB = []
    for i in range(int(math.log2(A))+1):
        P = A % (2**(i+1))
        Q = P % (2**i)
        R = (P-Q)//(2**i)
        LA.append(R)
    for i in range(int(math.log2(B))+1):
        P = B % (2**(i+1))
        Q = P % (2**i)
        R = (P-Q)//(2**i)
        LB.append(R)
    LS = []
    def Q(a,b):
        return (a%2,b%2)
    if A == B-1:
        if Q(A,B) == (0,1):
            print(1)
        else:
            LS.append(1)
            if len(LA) == len(LB):
                for i in range(1,len(LA)):
                    LS.append((LA[i]+LB[i])%2)
            else:
                for i in range(len(LA)):
                    LS.append(1)
            ANS = 0
            for i in range(len(LS)):
                ANS += (2**i)*LS[i]
            print(ANS)
    else:
        if Q(A,B) == (0,0):
            if (B-A+1)%4 ==1:
                print(B)
            else:
                print(B+1)
        elif Q(A,B) == (0,1):
            if (B-A+1)%4 == 0:
                print(0)
            else:
                print(1)
        elif Q(A,B) == (1,0):
            if (B-A+1)%4 == 0:
                LS.append(0)
            else:
                LS.append(1)
            if len(LA) > 1:
                for i in range(1,len(LA)):
                    LS.append((LA[i]+LB[i])%2)
            if len(LB) > len(LA):
                for i in range(len(LA),len(LB)):
                    LS.append(LB[i])
            ANS = 0
            for i in range(len(LS)):
                ANS += (2**i)*LS[i]
            print(ANS)
        else:
            if (B-A+1)%4 == 1:
                print(A)
            else:
                print(A-1)
n = int(input())
k = int(input())
x = list(map(int, input()))
d = 0
for i in x:
    d += min(i, k-i) * 2

print(d)

### FIXED CODE ###

n = int(input())
k = int(input())
x = list(map(int, input().split()))
d = 0
for i in x:
    d += min(i, k-i) * 2

print(d)
for i in range(1, n+1):
    if 0 != i%3 and 0 != i%5:
        ans += i
print(ans)

### FIXED CODE ###

n = int(input())
ans = 0
for i in range(1, n+1):
    if 0 != i%3 and 0 != i%5:
        ans += i
print(ans)
a=int(input())
b=int(input())

c=(a+b)/2
print(int(c))

### FIXED CODE ###

a, b=map(int,input().split())
print((a+b+1)//2)
import math
N = int(input())
aLst = list(map(int, input().split()))

ansLst = []
for i in range(len(aLst)):
    ans = 0
    for j in range(len(aLst)):
        if i != j:
            ans = math.gcd(ans, aLst[j])
    ansLst.append(ans)
ansLst.sort(reverse=True)
print(ansLst[0])

### FIXED CODE ###

import fractions
N = int(input())
aLst = list(map(int, input().split()))

lans = 0
llst = [0] * (N + 1)
rans = 0
rlst = [0] * (N + 1)

for i in range(N):
    lans = fractions.gcd(lans, aLst[i])
    llst[i + 1] = lans

for i in range(N - 1, -1, -1):
    rans = fractions.gcd(rans, aLst[i])
    rlst[i] = rans

ansMax = 0
for i in range(N):
    ansMax = max(ansMax, fractions.gcd(llst[i], rlst[i + 1]))

print(ansMax)
import numpy as np
n=int(input())
s=np.zeros(100001,dtype='int32')
a=[1,6,9,36,81,216,729,1296,6561,7776,46656,59049]

for i in range(n+1):
    s[i]=i
for i in range(1,12):
    if a[i]<=n :
        for j in range(a[i],n+1):
            if s[j]>s[j-a[i]]+1:
                s[j]=s[j-a[i]]+1
print(s[n])


### FIXED CODE ###

n=int(input())
s=[i for i in range(n+1)]
a=[1,6,9,36,81,216,729,1296,6561,7776,46656,59049]
for i in range(n+1):
    s[i]=i
for i in range(1,12):
    if a[i]<=n :
        k=a[i]
        for j in range(k,n+1):
            if s[j]>s[j-k]+1:
                s[j]=s[j-k]+1
print(s[n])
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math
import collections
import operator

# def check_cycle

N, = map(int, sys.stdin.readline().rstrip().split(" "))
As = list(map(int, sys.stdin.readline().rstrip().split(" ")))
Bs = list(map(int, sys.stdin.readline().rstrip().split(" ")))
AB_sorted = list(sorted(zip(As, Bs), key=operator.getitem(1)))
As_original = list(map(operator.getitem(0), AB_sorted))
As.sort()

A_reserve_dict = {}
last_reserve = None
for i in range(len(As)):
    if As[i] > Bs[i]:
        print("No")
        break
else:
    for i in range(len(As)):
        if As[i] == As_original[i]: # すでに一致してる = 1回減らせる
            print("Yes")
            break
    else:
        for i in range(len(As)-1):
            if As[i+1] <= Bs[i]: # i と i+1はどちらでもいい = 1回減らせる
                print("Yes")
                break
        else:
            print("No")
exit(0)

# Fails
# 1 2 3
# 2 3 1

# Fails
# 1 2 3 4
# 3 4 2 1


### FIXED CODE ###

#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math
import collections
import operator
import numpy

def check_cycle(i_pair):
    i_orig_sorted_dict = {i_orig: i_sort for i_orig, i_sort in i_pair}
    cycle_dict = {}
    for i_orig, i_sort in i_pair:
        i_current = i_orig
        while True:
            if not i_current in cycle_dict:
                cycle_dict[i_current] = i_orig
            else:
                break
            i_current = i_orig_sorted_dict[i_current]
    return len(numpy.unique(list(cycle_dict.values())))


N, = map(int, sys.stdin.readline().rstrip().split(" "))
As = list(map(int, sys.stdin.readline().rstrip().split(" ")))
Bs = list(map(int, sys.stdin.readline().rstrip().split(" ")))
AB_sorted = list(sorted(zip(As, Bs), key=operator.itemgetter(1)))
Bs = list(map(operator.itemgetter(1), AB_sorted))
As_original = list(map(operator.itemgetter(0), AB_sorted))
A_i_pair = [(i_orig, i_sort) for i_sort, (i_orig, value) in enumerate(sorted(enumerate(As_original), key=operator.itemgetter(1)))]
As.sort()

# print(Bs)
# print(As_original)
# print(As)

A_reserve_dict = {}
last_reserve = None
for i in range(len(As)):
    if As[i] > Bs[i]:
        print("No")
        break
else:
    # for i in range(len(As)):
    #     if As[i] == As_original[i]:  # すでに一致してる = 1回減らせる
    #         print("Yes")
    #         break
    if check_cycle(A_i_pair) >= 2:
        print("Yes")
    else:
        for i in range(len(As) - 1):
            if As[i + 1] <= Bs[i]:  # i と i+1はどちらでもいい = 1回減らせる
                print("Yes")
                break
        else:
            print("No")
exit(0)

# Fails
# 1 2 3
# 2 3 1

# Fails
# 1 2 3 4
# 3 4 2 1
from decimal import Decimal
X= int(input())

B=-X**(1/5)
while True:
    print(B)
    A= Decimal((X+B**5)**(1/5))
    
    if int(A)==A and A>B:
        print(A,B)
        break
    else:
        B=B+1

### FIXED CODE ###

#D
X=int(input())
for i in range(1000):
    for a in range(1000):
        if a**5-(a-i)**5==X:
            print(a,a-i)
            break
import sys
 
n,m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]
 
sc.sort()
ans = 0
d = 0
s = 0
 
if sc[0][1] == 0 and n != 1:
  print('-1')
  sys.exit()

if sc[0][0] != 1:
  ans += 10**(n-1)
 
for i in sc:
  if i[0] != d:
    d = i[0]
    s = i[1]
    ans += s * (10 ** (n-d))
  else:
    if i[1] != s:
      print('-1')
      sys.exit()
 
print(ans)

### FIXED CODE ###

import sys

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

num = ['-'] * n

for i in range (m):
  s,c = map(int, input().split())
  if num[s-1] != '-' and num[s-1] != c:
    print('-1')
    sys.exit()
  else:
    num[s-1] = c

if n > 1:
  if num[0] == 0:
    print('-1')
    sys.exit()
  elif num[0] == '-':
    num[0] = 1 
  
for i in range(n):
  if num[i] == '-':
    num[i] = '0'
  else:
    num[i] = str(num[i])

print(''.join(num))
n,m = map(int,input().split())
a = [list(map(int,input().split())) for raw in range(m)]
b = sorted(a)
ans = 0
if (b[0])[0] != 1:
  ans += 10**(n-1)
t = 0
u = -1
che = 0
for hoge in b:
  x = hoge[0]
  y = hoge[1]
  if x == 1 and y == 0:
    che += 1
  if x != t:
    ans += y*(10**(n-x))
  if x == t and y != u:
    che +=1
  t = x
  u = y
if che == 0 and ans !=0:
  print(ans)
elif che == 0 and n == 1:
  print(0)
else:
  print(-1)

### FIXED CODE ###

n,m = map(int,input().split())
if m != 0:
  a = [list(map(int,input().split())) for raw in range(m)]
  b = sorted(a)
  ans = 0
  if int((b[0])[0]) != 1:
    ans += 10**(n-1)
  t = 0
  u = -1
  che = 0
  for hoge in b:
    x = hoge[0]
    y = hoge[1]
    if x == 1 and y == 0:
      if n != 1:
        che += 1
    if x != t:
      ans += y*(10**(n-x))
    if x == t and y != u:
      che +=1
    t = x
    u = y
  if che == 0 and ans !=0:
    print(ans)
  elif che == 0 and n == 1:
    print(0)
  else:
    print(-1)
else:
  if n == 1:
    print(0)
  else:
    print(10**(n-1))
x, y, z = list(map(int, input().split()))

s = [x, y, z]

print(str(sorted(s))


### FIXED CODE ###

#print(*sorted(map(int, input().split())))

print(*sorted(map(int, input().split())))
n=int(input())
a=list(map(int,input().split()))
b=[0]*9 
for i in a:
  b[i//400]+=1
print(8-b[:8].count(0),min(8-b[:8].count(0)+b[8],8))

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=[0]*9
for i in a:
  b[min(i//400,8)]+=1
print(max(8-b[:8].count(0),1),8-b[:8].count(0)+b[8])
# coding: utf-8
# Your code here!
import fractions

n,x= list(map(int,input().split()))	
a= [int(i)-x for i in input().split()]

ans=a[1]
for i in range(n):
    ans = fractions.gcd(ans,a[i])

print(abs(ans))

### FIXED CODE ###

# coding: utf-8
# Your code here!
import fractions

n,x= list(map(int,input().split()))	
a= [abs(int(i)-x) for i in input().split()]

ans=a[0]
for i in range(n):
    ans = fractions.gcd(ans,a[i])

print(abs(ans))
n = int(input())
friendliness = [int(s) for s in input().split()]

res = friendliness[0] + 2 * sum(friendliness[1:n//2+1]) + (n%2) * friendliness[n//2+1]


### FIXED CODE ###

n = int(input())
friendliness = [int(s) for s in input().split()]

friendliness.sort(reverse=True)
print(friendliness[0] + 2 * sum(friendliness[1:n//2]) + (n%2) * friendliness[n//2])
A, B = map(int, input().split())

print(int(A*B))

### FIXED CODE ###

A, B = input().split()

A = int(A)
B = int(float(B) * 100 + 0.5)
ans = A * B // 100

print(ans)
def find(x):
  if P[x] < 0:
    return x
  else:
    return P[x]

N, M, *X = map(int,open(0).read().split())
P = [-1] * (N + 1)
S = N * (N - 1) // 2
r = [S]

while X:
  b, a = find(X.pop()), find(X.pop())
  if a != b:
    S -= P[a] * P[b]
    if P[a] > P[b]:
      a, b = b, a
    P[a] += P[b]
    P[b] = a
  r.append(S)

r.pop()
print(*reversed(r), sep='\n')

### FIXED CODE ###

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

u = [-1] * (n + 1)

def find(v):
    if u[v] < 0:
        return v
    else:
        return find(u[v])

total = n * (n - 1) // 2
ans = [total]

for a, b in reversed(ab[1:]):
    af = find(a)
    bf = find(b)
    af, bf =sorted([af, bf])
    if af != bf:
        total -= u[af] * u[bf]
        u[af] += u[bf]
        u[bf] = af
    ans.append(total)

for a in reversed(ans):
    print(a)
x = input()
a = x/3600
b = x%3600/60
c = x%3600%60/60
print a':'b':'c

### FIXED CODE ###

x = input()
a = x/3600
b = x%3600/60
c = x - a*3600 - b*60
print '%d:%d:%d'%(a, b, c)
# EDP F-LCS
import sys
input = sys.stdin.readline

ans = ""

def main():
    S = input()
    T = input()
    LS = len(S)
    LT = len(T)
    dp = [[0 for j in range(LT+1)] for i in range(LS+1)]

    for i, s in enumerate(S):
        for j, t in enumerate(T):
            if s == t:
                dp[i+1][j+1] = dp[i][j]+1
            else:
                if dp[i+1][j] >= dp[i][j+1]:
                    dp[i+1][j+1] = dp[i+1][j]
                else:
                    dp[i+1][j+1] = dp[i][j+1]

    def rec(i, j):
        if i == 0 or j == 0:
            return

        if S[i-1] == T[j-1]:
            global ans
            ans += S[i-1]
            rec(i-1, j-1)
        elif dp[i-1][j] > dp[i][j-1]:
            rec(i-1, j)
        else:
            rec(i, j-1)

    rec(LS, LT)
    print(ans[::-1])


if __name__ == "__main__":
    main()


### FIXED CODE ###

# EDP F-LCS
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

ans = ""


def main():
    S = input()
    T = input()
    LS = len(S)
    LT = len(T)
    dp = [[0 for j in range(LT+1)] for i in range(LS+1)]

    for i, s in enumerate(S):
        for j, t in enumerate(T):
            if s == t:
                dp[i+1][j+1] = dp[i][j]+1
            else:
                if dp[i+1][j] >= dp[i][j+1]:
                    dp[i+1][j+1] = dp[i+1][j]
                else:
                    dp[i+1][j+1] = dp[i][j+1]

    def rec(i, j):
        if i == 0 or j == 0:
            return

        if S[i-1] == T[j-1]:
            global ans
            ans += S[i-1]
            rec(i-1, j-1)
        elif dp[i-1][j] > dp[i][j-1]:
            rec(i-1, j)
        else:
            rec(i, j-1)

    rec(LS, LT)
    print(ans[::-1])


if __name__ == "__main__":
    main()
from math import gcd
from functools import reduce
N, X = map(int, input().split())
x = [abs(X-int(i)) for i in input().split()]

### FIXED CODE ###

from functools import reduce
from fractions import gcd
N, X = map(int, input().split())
x = [abs(X-int(i)) for i in input().split()]
print(reduce(gcd, x))
a, b, c, d = map(int, input().split())
 
cnt = 0
for i in range(a, b+1):
  if i % c != 0 and i % d != 0:
    cnt += 1
    
print(cnt)

### FIXED CODE ###

s_code = list(map(int, input()))

num_1 = s_code[0]
num_2 = s_code[1]
num_3 = s_code[2]
num_4 = s_code[3]

if num_1 == num_2:
  print('Bad')
elif num_2 == num_3:
  print('Bad')
elif num_3 == num_4:
  print('Bad')
else:
  print('Good')
N = int(input())
xyz = []

for _ in range(N):
    temp = list(map(int, input().split()))
    xyz.append(temp)

if N == 1:
    ans = [str(xyz[0][0]), str(xyz[0][1]), str(xyz[0][2])]
else:
    for i in range(101):
        for j in range(101):
            h = max(xyz[0][2] + abs(xyz[0][0] - i) + abs(xyz[0][1] - j),0)

            count = N
            for n in range(0,N):
                g = max(h - abs(i - xyz[n][0]) - abs(j - xyz[n][1]),0)
                if g == xyz[n][2]:
                    count -= 1
            
            if count == 0:
                ans = [str(i), str(j), str(h)]
                break

ans_s = ' '.join(ans)
print(ans_s)

### FIXED CODE ###

N = int(input())
xyz = []

for _ in range(N):
    temp = list(map(int, input().split()))
    xyz.append(temp)


if N == 1:
    ans = [str(xyz[0][0]), str(xyz[0][1]), str(xyz[0][2])]
else:
    for i in range(101):
        for j in range(101):
            for k in range(N):
                if xyz[k][2] >= 1:      
                    h = max(xyz[k][2] + abs(xyz[k][0] - i) + abs(xyz[k][1] - j),0)

                    count = N
                    for n in range(0,N):
                        g = max(h - abs(i - xyz[n][0]) - abs(j - xyz[n][1]),0)
                        if g == xyz[n][2]:
                            count -= 1
                    
                    if count == 0:
                        ans = [str(i), str(j), str(h)]
                        break
                    break

ans_s = ' '.join(ans)
print(ans_s)
import collections
n,k = map(int, raw_input().split(' '))
heigths = [int(raw_input()) for _ in range(n)]
heigths.sort()
q = collections.deque([])
r =  float('inf') 
for h in heights:
	q.append(h)
	if len(q) == k+1: q.popleft()
	if len(q) == k:
r =min(r, q[-1] - q[0])
print r

### FIXED CODE ###

import collections
n,k = map(int, raw_input().split(' '))
heights = [int(raw_input()) for _ in range(n)]
heights.sort()
q = collections.deque([])
r =  float('inf') 
for h in heights:
	q.append(h)
	if len(q) == k + 1: q.popleft()
	if k and len(q) == k:
		r =min(r, q[-1] - q[0])
print r if k else 0
import math 
A,B=input().split()
A,B=[int(A),float(B)]
B=B[:3]
if 0<=A<=10**15 and 0<=B<10:
    result=A*B
    result=int(math.floor(result))
    print(result)

### FIXED CODE ###

from decimal import Decimal
import math
a,b = map(Decimal,input().split())
ans = a*b
print(math.floor(ans))
N = int(input())
L=set()
for i in range(2,9):
  for j in range(2,9):
    L.add(i*j)
if N in L:
  print(Yes)
else:
  print(No)

### FIXED CODE ###

N = int(input())
L=set()
for i in range(1,10):
  for j in range(1,10):
    L.add(i*j)
if N in L:
  print("Yes")
else:
  print("No")
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

import math
nm=list(map(int,input().split()))
a=list(map(int,input().split()))
lcm1=a[0]
for i in range(nm[0]-1):
    lcm1=lcm(lcm1, a[i+1])
answer=((nm[1]/lcm1-0.5)+1)//1
print(int(answer))

### FIXED CODE ###

import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
nm=list(map(int, input().split()))
a=list(map(int, input().split()))
n=nm[0]
m=nm[1]
b=0
c=a[0]
dnum=0
while c%2==0:
    dnum+=1
    c=c//2
for i in range(len(a)):
    c=a[i]
    dnum1=0
    while c%2==0:
        dnum1+=1
        c=c//2
    #print(dnum)
    if dnum1!=dnum:
        b=1
        break

#print(a)
if b==1:
    print(0)
else:
    for i in range(len(a)):
        a[i]=a[i]//2
    #print(a)
    amc=lcm_list(a)
    #print(amc)
    # version3.5にてgcdがfractionsからmathに移動した
    print(int((m+amc)/(2*amc)))
import collections

from operator import mul
from functools import reduce


def cmb(n, r):
    r = min(n-r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


N = int(input())
s = [" ".join(sorted(list(input()))) for _ in range(N)]
c = collections.Counter(s)
ans = 0
for i in c.values():
    ans += cmb(i, 2)
print(ans)


### FIXED CODE ###

import collections

from operator import mul
from functools import reduce


def cmb(n, r):
    r = min(n-r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


N = int(input())
s = [" ".join(sorted(list(input()))) for _ in range(N)]
c = collections.Counter(s)
ans = 0
for i in c.values():
    if i > 1:
        ans += cmb(i, 2)
print(ans)