problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03827
s109821835
Accepted
# -*- coding: utf-8 -*- N = int(input().strip()) S = input().strip() #----- x=0 x_max=0 for w in S: if w == "I": x += 1 elif w == "D": x -= 1 x_max = max(x_max, x) print(x_max)
p03417
s442959115
Accepted
n, m = map(int, input().split()) if n == 1 and m == 1: ans = 1 elif n == 1 or m == 1: ans = max(n, m) - 2 else: ans = (n - 2)*(m - 2) print(ans)
p03565
s683140938
Accepted
Sd = input() T = input() def check(A, B): for a, b in zip(A, B): if a != '?' and a != b: return False return True for i in range(len(Sd) - len(T) + 1)[::-1]: if check(Sd[i:i + len(T)], T): print((Sd[:i] + T + Sd[i + len(T):]).replace('?', 'a')) break else: print...
p02697
s662483358
Wrong Answer
n, m = map(int, input().split()) od = (m + 1) // 2 x = 2 * od + 1 for i in range(1, od + 1): print(i, x - i) for i in range(m - od - 1): print(x + i, 2 * m + 1 - i)
p03611
s238519648
Accepted
from collections import defaultdict N = int(input()) d = defaultdict(int) for a in map(int, input().split()): d[a] += 1 d[a - 1] += 1 d[a + 1] += 1 print(max(d.values()))
p03804
s429620609
Accepted
N, M = map(int, input().split()) A = [input() for _ in range(N)] B = [input() for _ in range(M)] def f(i, j): for k in range(M): for l in range(M): if A[i+k][j+l] != B[k][l]: return False return True def slv(): for i in range(N-M+1): for j in range(N-M+1): if f(i, j): retur...
p02756
s180373318
Accepted
s = input() q = int(input()) qs = [input().split() for i in range(q)] n = False left= right = "" for operation in qs: if operation[0] == '1': n = not n if operation[0] == '2': t , f, c = operation f = int(f) if n: f = 1 if f != 1 else 2 if f == 1: ...
p02714
s830958962
Accepted
N = int(input()) S = list(input()) k = [0] * N for i in range(N): if S[i] == "R": k[i] = 2 elif S[i] == "G": k[i] = 3 else: k[i] = 5 a = k.count(2) b = k.count(3) c = N - a - b ans = a*b*c for i in range (1,(N + 1)//2): for j in range (N - 2 * i): if k[j] * k[j + i] * k[j...
p02687
s214668442
Wrong Answer
print('A%sC'%'BR'[id(id)%9%2])
p03644
s837334989
Wrong Answer
n=int(input()) x=0 for i in range(n): if 2**i<=n: x=2**i print(x)
p03360
s987127783
Accepted
ABC = sorted(list(map(int, input().split()))) K = int(input()) for _ in range(K): ABC[2] = ABC[2] * 2 print(sum(ABC))
p03971
s447940147
Accepted
n,nai,out=map(int,input().split()) b=input() kokunai=0 kaigai=0 for i in range(n): if(b[i]=='c'): print('No') elif(b[i]=='a'): if(kokunai+kaigai>=nai+out): print('No') else: kokunai=kokunai+1 print('Yes') else: if(kokunai+kaigai>=nai+out or kaigai>=out): print('No') els...
p02922
s451750800
Accepted
# -*- coding: utf-8 -*- a, b = [int(i) for i in input().split()] if b == 1: ans = 0 else: ans = 1 count = a while True: if count >= b: break else: #count = count - 1 + a count += (a - 1) ans += 1 print(ans)
p03252
s669178645
Accepted
s = input() t = input() memo = {} ans = 'Yes' for i in range(len(s)): if s[i] in memo: if t[i] != memo[s[i]]: ans = 'No' break else: memo[s[i]] = t[i] a = list(memo.values()) b = list(set(a)) if len(b) != len(a): ans = 'No' print(ans)
p02972
s771716233
Accepted
n =int(input()) A = list(map(int,input().split())) ans = [0]*n for i in range(n)[::-1]: if i >= n//2: ans[i] = A[i] else: tmp = 0 j = i+1 while j<=n: tmp += ans[j-1] j += i+1 if A[i] == 1: if tmp % 2 != A[i]: ans[i] = A[i] else: if tmp % ...
p02572
s537349574
Wrong Answer
import numpy as np n = int(input()) s = 0 a = np.array(list(map(int, input().split()))) for i in range(len(a)-1): s_tmp = np.sum(a[i+1:len(a)]) s += a[i] * s_tmp print(s % 1000000007)
p03285
s713260122
Accepted
n = int(input()) for i in range(100): #2重ループでケーキ,ドーナツの数を1個ずつ変えていってnドルになった時に終了させる for j in range(100): if i * 4 + j * 7 == n: print("Yes") exit() print("No")
p02771
s522305119
Accepted
A, B, C = list(map(int, input().split())) if (A==B or B==C or C==A) and not (A==B==C): print('Yes') else: print('No')
p02973
s876272335
Accepted
from bisect import bisect_left N = int(input()) A = [int(input()) for i in range(N)] X = [A[0]] for i in range(1, N): if X[0] >= A[i]: X.insert(0, A[i]) else: idx = bisect_left(X, A[i]) X[idx-1] = A[i] print(len(X))
p02909
s503242446
Wrong Answer
s=input() l=['Sunny', 'Cloudy', 'Rainy'] print(3-l.index(s))
p03127
s527662073
Wrong Answer
N=int(input()) *A,=map(int,input().split()) A.sort() ans=A[0] count=[0]*N i=0 while i<N: count[i]=A[i]%ans i+=1 for c in count: if c>0: ans=min(ans,c) for a in A: if a%ans>0: ans=min(ans,a%ans) print(ans)
p02582
s288524719
Wrong Answer
S = input() count = 0 for i in range(3): if S[i] == "R": count += 1 elif count == 1: count = 0 print(count)
p03211
s536465975
Accepted
# ABC 114: B – 754 s = input() min_length = 9999999999 for i in range(len(s) - 2): min_length = min(min_length, abs(int(s[i] + s[i + 1] + s[i + 2]) - 753)) print(min_length)
p03814
s878352615
Accepted
s = list(input()) A = s.index("A") S = list(reversed(s)) Z = S.index("Z") print(len(s) - Z - A)
p02627
s294139659
Accepted
import re a=input() if re.sub(r'[A-Z]',"",a)=="": print('A') else: print('a')
p02989
s296495147
Wrong Answer
n=int(input()) a=sorted(list(map(int, input().split()))) l=min(a);h=max(a) res=0 for i in range(l+1,h): ans=0 for j in a: ans+=j>=i if ans == n//2:res+=1 print(res)
p03944
s195623044
Wrong Answer
w,h,n = list(map(int, input().split())) xya = [list(map(int, input().split())) for _ in range(n)] left = 0 right = w down = 0 up = h for i in xya: if i[2]==1: left = i[0] elif i[2]==2: right = i[0] elif i[2]==3: down = i[1] else: up = i[1] print(max(up-down, 0) * max(rig...
p02583
s105310194
Accepted
import itertools N = int(input()) L = list(map(int, input().split())) def has_duplicates(seq): return len(seq) != len(set(seq)) sides = list(itertools.combinations(L, 3)) count = 0 for side in sides: if has_duplicates(side): continue else: temp = sorted(side) if temp[1]-temp[0] < ...
p03479
s070444967
Accepted
# -*- coding: utf-8 -*- # import math X,Y = list(map(int, input().rstrip().split())) #----- calc = X cnt = 0 while calc <= Y: calc *= 2 cnt += 1 print(cnt) # エラーになる・・・ # calc = math.log( (Y / X) , 2) + 1 # print( int(calc) )
p02760
s406905302
Accepted
a = list(map(int,input().split())) a.extend(list(map(int,input().split()))) a.extend(list(map(int,input().split()))) n = int(input()) ins = [] for i in range(n): b = int(input()) if b in a: ins.append(a.index(b)) okp = [(0,1,2), (3,4,5), (6,7,8) ,(0,3,6), (1,4,7), (2,5 ,8), (0,4,8), (2,4,6)] f = "No" ...
p02768
s343633569
Accepted
M = 10**9 + 7 n, a, b = map(int, input().split()) r = pow(2, n, M) - 1 f = c = 1 for i in range(b): f = f * (i + 1) % M c = c * (n - i) % M if i + 1 == a: a = b r -= c * pow(f, M - 2, M) print(r % M)
p03331
s311737229
Accepted
N = int(input()) ans = 10**5+1 for i in range(1,N//2 + 1): A = i B = N - i tmp = 0 while(A > 0): tmp += A % 10 A //= 10 while(B > 0): tmp += B % 10 B //= 10 ans = min(ans,tmp) print(str(ans))
p02594
s662267820
Wrong Answer
a=int(input()) if -40 <= a <= 40: print("Yes") else: print("No")
p02714
s411622252
Accepted
n = int(input()) s = str(input()) r = 0 g = 0 b = 0 for i in range(n): if s[i] == 'R': r += 1 elif s[i] == 'G': g += 1 else: b += 1 ans = r * g * b for i in range(n): for j in range(n): if 2 * j + i < n and s[i] != s[i + j] and s[i] != s[2 * j + i] and s[i + j] != s[2 * j + i]: ans -= 1 pr...
p02900
s770327402
Wrong Answer
m, n = map(int, input().split()) while True: if m < n: m, n = n, m if m%n: m, n = n, m%n else: break def divisors(m): divisors = [1] for i in range(2, int(m**0.5)+1): if m % i == 0: divisors.append(i) while m % i == 0: m //= i if m == 1: ...
p03419
s976219239
Wrong Answer
N,M=map(int,input().split()) if N==1: print(M-2) elif M==1: print(N-2) else: print((N-2)*(M-2))
p03261
s003280791
Accepted
def mi(): return map(int, input().split()) def main(): N = int(input()) W = [input() for _ in range(N)] if len(set(W)) != N: print('No') return for i in range(N-1): if W[i][-1] != W[i+1][0]: print('No') return print('Yes') if __name__ == '__main_...
p02775
s012591759
Accepted
n="0"+input() A,b,c=0,0,0 for i in n[::-1]: a=int(i)+b if a==5 and c==0: A+=5 b=0 c=1 elif a<5: A+=a b=0 c=0 else: A+=10-a-c b=1 c=0 print(A)
p02718
s060190789
Accepted
import numpy as np n, m = list(map(int,(input().split()))) a = np.array(list(map(int,(input().split())))) all_b = sum(a) t = 1/(4*m)*all_b #all_t =a*t ans = np.where(a>=t) #print(ans) #print(all_b[all_b >t]) #print(all_b,t) #print(len(ans[0])) if len(ans[0]) >= m: print('Yes') else: print('No')
p03000
s520644884
Accepted
n, x = map(int, input().split()) a = list(map(int, input().split())) l = [0] * (n+1) for i in range(n): l[i+1] = l[i] + a[i] ans = 0 for i in l: if i <= x: ans += 1 print(ans)
p03319
s734652579
Accepted
import math N,K = map(int,input().split()) print(math.ceil((N - 1)/(K - 1)))
p03359
s245328336
Accepted
a, b = map(int,input().split()) if a <= b: print(a) else: print(a-1)
p03835
s709411162
Accepted
k,s = map(int,input().split()) cnt=0 for i in range(k+1): for j in range(k+1): if s-k<=i+j<=s: cnt+=1 print(cnt)
p03943
s830960626
Wrong Answer
a = list(map(int, input().split())) a.sort() print(a) print("Yes" if a[0]+a[1] == a[2] else "No")
p02947
s296701642
Wrong Answer
n = int(input()) s = [] for i in range(n): s.append("".join(sorted(input()))) s.sort() ans = 0 for i in range(n-1): if s[i] == s[i+1]: ans += 1 print(ans)
p02819
s432136424
Accepted
#!/usr/bin/env python3 import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def is_prime(n): for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def main(): X = int(readline()) while not is_pr...
p02615
s047454017
Accepted
n,*a = map(int,open(0).read().split()) a.sort(reverse=True) print(a[0]+sum(a[1:n//2])+sum(a[1:n-n//2]))
p02684
s960540746
Accepted
n,k =map(int,input().split()) a=list(map(int,input().split())) a = [1] + a def next(i): return a[i] z = [0] * (n+1) place = 1 T = 0 interval = 0 if k < n: for i in range(k): place = next(place) print(place);exit() place = 0 k += 1 for i in range(n): place = next(place) if z[place] != 0: ...
p03137
s004065980
Wrong Answer
n, m = map(int, input().split()) lis = list(map(int, input().split())) lis.sort() res = [] for i in range(m - 1): res.append(lis[i + 1] - lis[i]) res.sort() k = n - 1 print(sum(res[:-k]))
p02598
s058342305
Accepted
import math n,k = (int(x) for x in input().split()) An = [int(i) for i in input().split()] left = 0 right = max(An) def check(x): chk = 0 for i in range(n): chk += math.ceil(An[i]/x)-1 return chk while right-left!=1: x = (left+right)//2 if check(x)<=k: right = x else: ...
p03556
s414818961
Accepted
import math N = int(input()) ans = 1 for i in range(10**5): if i**2 <= N: ans = i**2 if i**2 > N: break print(ans)
p03041
s459020028
Accepted
n,k = map(int,input().split()) s = list(input()) s[k-1] = s[k-1].lower() print("".join(s))
p03799
s774307363
Accepted
n,m = map(int, input().split()) if n*2 < m: c = n*2 + m print(c//4) else: print(m//2)
p02556
s135347332
Accepted
n = int(input()) A = [] B = [] for i in range(n): a, b = map(int, input().split()) z = a + b w = a - b A.append(z) B.append(w) P = abs(max(A) - min(A)) Q = abs(max(B) - min(B)) print(max(P, Q))
p02633
s920182060
Accepted
x = int(input()) for k in range(1, 10000): if x*k % 360 == 0: print(k) break
p02602
s061640500
Accepted
n,k= map(int,input().split()) a = list(map(int,input().split())) for i in range(n-k): if a[i] < a[i + k]: print("Yes") else: print("No")
p03309
s795812646
Accepted
def main(): N, *A = map(int, open(0).read().split()) for i in range(N): A[i] -= i + 1 A.sort() ans = 0 b = A[N // 2] for i in range(N): ans += abs(A[i] - b) print(ans) return main()
p02664
s178365846
Accepted
T = input() print(T.replace('?', 'D'))
p03351
s424564256
Accepted
a,b,c,d=map(int,input().split()) ab=abs(a-b) bc=abs(b-c) if abs(a-c) <= d: print("Yes") elif ab <= d and bc <= d: print("Yes") else: print("No")
p03281
s265970099
Accepted
N = int(input()) if N < 105: print(0) exit() ans = 0 for i in range(1, N+1, 2): count = 0 for j in range(1, i+1): if i % j == 0: count += 1 if count == 8: ans += 1 print(ans)
p03329
s935829182
Accepted
N = int(input()) array = [] cnt6 = 0 while 6**cnt6 <= N: array.append(6**cnt6) cnt6 += 1 cnt9 = 0 while 9**cnt9 <= N: array.append(9**cnt9) cnt9 += 1 a = sorted(list(set(array))) # 最小 dp = [i for i in range(N+1)] # print(a) n = 6 for n in a: for i in range(N+1): if i+n <= N: ...
p02732
s743761686
Accepted
N=int(input()) A=list(map(int,input().split())) import collections as col sa=set(A) ca=col.Counter(A) num=0 for i in sa: if ca[i]==1: continue else: num += (ca[i]*(ca[i]-1))//2 for i in A: ans = num - (ca[i]-1) print(ans)
p02711
s210606553
Accepted
a, b, c = input() a=int(a) b=int(b) c=int(c) if a == 7: print('Yes') else: if b == 7: print('Yes') else: if c == 7: print('Yes') else: print('No')
p02811
s867803718
Accepted
k, x = map(int, input().split()) print("YNeos"[k*500<x::2])
p03723
s215386586
Accepted
a,b,c = map(int, input().split()) original = [a,b,c] flag = 0 i = 0 while a%2 == b%2 == c%2 == 0: a_ = (b+c)//2 b_ = (c+a)//2 c_ = (a+b)//2 a = a_ b = b_ c = c_ if [a,b,c] == original: flag = 1 break i += 1 if flag: print(-1) else: print(i)
p03324
s705157667
Accepted
d,n = map(int, input().split()) if n == 100: print(100**d*101) else: print(100**d*n)
p02694
s029786838
Accepted
X = int(input()) money = 100 cnt = 0 while money < X: money = int(money * 1.01) cnt += 1 print(cnt)
p03433
s169157735
Wrong Answer
import sys if (int(input()) % 500) <= int(input()): print('YES') else: print('NO')
p02973
s459655545
Accepted
from bisect import bisect_right def main(): N = int(input()) min_a = 10**9 + 1 values = [] ans = 0 for i in range(N): tmp = -int(input()) idx = bisect_right(values, tmp) if idx != len(values): values[idx] = tmp else: values.append(tmp) ...
p02771
s580229355
Accepted
A = map(int, input().split()) if len(set(A) ) == 2: print("Yes") else: print("No")
p02947
s658294791
Wrong Answer
def countPairs(str_arr): count = 0 for i in range(N): for j in range(i+1,N): if str_arr[i] == str_arr[j]: count += 1 return count N = int(input()) str_arr = [] for i in range(N): str = input() str_arr.append(str) print(countPairs(str_arr))
p02678
s980018607
Accepted
from collections import deque n,m=map(int,input().split()) neighbor=[[] for i in range(n)] for i in range(m): a,b=map(int,input().split()) a,b=a-1,b-1 neighbor[a].append(b) neighbor[b].append(a) def bfs(start,arrcnt): queue=deque([start]) d=[None]*arrcnt d[start]=0 while queue: l=queue.popleft() ...
p02607
s518250751
Wrong Answer
N=int(input()) a=[int(i) for i in input().split(" ")] retval=0 for i,ai in enumerate(a): if i%2==0: continue if ai%2==1: retval+=1 print(retval)
p02646
s861406202
Accepted
A,V = map(int,input().split()) B,W = map(int,input().split()) T = int(input()) w = abs(A-B) s = V-W if s * T >= w: print("YES") else: print("NO")
p03208
s029479562
Accepted
N,K = map(int,(input().split())) h = [0]*N for i in range(N): h[i] = int(input()) h.sort() s = [] for i in range(N-K+1): s.append(h[i+K-1] - h[i]) print(min(s))
p02707
s507382108
Accepted
n=int(input()) l=list(map(int,input().split())) d=[0]*(n+1) for i in l: d[i]+=1 for i in range(1,n+1): print(d[i])
p03417
s704348532
Accepted
n, m = map(int, input().split()) if n*m == 1: print(1) elif m*n == 4: print(0) else: print(abs((n-2)*(m-2)))
p02832
s600811149
Wrong Answer
n = int(input()) a = list(map(int, input().split())) b = sorted(set(a)) len_a = len(a) len_b = len(b) ans = len_a - len_b for i in range(len_b - 2): if b[i+1] - b[1] != 1: print(-1) break else: print(ans)
p03323
s015154264
Accepted
a, b = map(int, input().split()) if a <= 8 and b <= 8: print("Yay!") else: print(":(")
p02958
s484796532
Accepted
n = int(input()) p = list(map(int, input().split())) t = sorted(p) l = 0 for i in range(n): if p[i] != t[i]: l += 1 if l > 2: print('NO') break else: print('YES')
p03160
s222136737
Accepted
import math def better(l, ans): for i in range(2, n): ans[i] = min(ans[i - 1] + abs(l[i]-l[i - 1]), ans[i - 2] + abs(l[i]-l[i - 2])) return ans n = int(input()) l = list(map(int, input().split())) ans = [0] * n ans[1] = abs(l[1]-l[0]) print(better(l, ans)[len(ans)-1])
p03592
s084193880
Wrong Answer
N, M, K = map(int, input().split()) ans = "No" for i in range(M+1): for j in range(N+1): sum = 0 sum += N*i+M*j if sum == K: ans = "Yes" break if ans == "Yes": break print(ans)
p03380
s385061552
Accepted
def resolve(): N = int(input()) A = sorted(list(map(int, input().split()))) n = A[-1] import bisect idx = bisect.bisect_left(A, n//2) candidates = [] if idx < N: candidates.append(A[idx]) if idx > 0: candidates.append(A[idx-1]) if abs(n/2 - candidates[0]) < abs(n/2 -...
p03487
s043878314
Accepted
from collections import Counter from itertools import starmap def main(): N = input() A = list(map(int, input().split())) count = Counter(A) remove = lambda x,y: y-x if y >= x else y ans = sum(starmap(remove, count.items())) print(ans) main()
p03448
s432773669
Wrong Answer
A = int(input()) #500円玉 B = int(input()) #100円玉 C = int(input()) #50円玉 X = int(input()) #この値にする合計を求める count = 0 a = -1 b = -1 c = -1 while a <= A: a += 1 while b <= B: b +=1 while c <= C: c +=1 total = 500 * a + 100 * b + 50 * c if total == X: ...
p02742
s907499485
Accepted
h,w = map(int, input().split()) if h == 1 or w == 1: print(1) elif h*w%2 == 1: print(1+h*w//2) else: print(h*w//2)
p02630
s080676881
Accepted
n=int(input()) a=list(map(int,input().split())) s=sum(a) lis=[0]*(10**5+1) for i in range(n): lis[a[i]]+=1 q=int(input()) for _ in range(q): b,c=map(int,input().split()) s+=c*lis[b]-b*lis[b] lis[c]+=lis[b] lis[b]=0 print(s)
p03779
s281739895
Accepted
n = int(input()) tmp = 0 for i in range(1, n + 1): tmp += i if tmp >= n: print(i) break
p02582
s498425073
Accepted
s=input() if "RRR" in s: print(3) elif "RR" in s: print(2) elif "R" in s: print(1) else: print(0)
p02627
s502192886
Accepted
a=input() if a.islower(): print("a") else: print("A")
p03220
s987702393
Accepted
n=int(input()) t,a=map(int,input().split()) h=list(map(int,input().split())) k=0 m=100000000000000 for i in range(1,n+1): b=a-t+h[i-1]*0.006 if m>abs(b): m=abs(b) k=i print(k)
p02597
s022000069
Accepted
N=int(input()) c=list(input()) cnt=0 res=10**30 rcum=[0]*(N+1) wcum=[0]*(N+1) for i in range(N): rcum[i+1]=rcum[i]+(c[i]=='R') wcum[i+1]=wcum[i]+(c[i]=='W') for i in range(N+1): a=wcum[i]+(rcum[N]-rcum[i]) res=min(res,a) for i in range(N+1): b=max(wcum[i],(rcum[N]-rcum[i])) res=min(res,b) ...
p03962
s411796080
Wrong Answer
sample = input() sample_list = sample.split(" ") count = 0 flag = 0 for i in range(len(sample_list)): for j in range(1, i): if sample_list[i] == sample_list[j]: flag = 1 if flag == 0: count += 1 flag = 0 print(count)
p03076
s582808187
Wrong Answer
x = [] x.append(int(input())) x.append(int(input())) x.append(int(input())) x.append(int(input())) x.append(int(input())) tmp = 9 ans = 0 def a(b): c = str(b) if c[-1] == "0": return b else: return b - int(c[-1]) + 10 for i in x: ans += a(i) d = str(i) if int(d[-1]) != 0: ...
p03243
s298780813
Accepted
#111_B N=int(input()) print(-(-N//111)*111)
p02836
s616656433
Accepted
S = input() a = len(S) A = a // 2 T = S[::-1] B = S[0:A] C = T[0:A] x = 0 count = 0 for b in B: if b != C[x]: count += 1 x += 1 print(count)
p02660
s833784381
Wrong Answer
N = int(input()) ans = 0 for i in range(2, int(N**0.5)+1): cnt = 0 while N%i == 0: N /= i cnt += 1 a = 0 b = 0 for j in range(1, cnt+1): a += j if a > cnt: break b += 1 ans += b print(1 if ans==0 else ans)
p03998
s204039255
Wrong Answer
S=[input() for i in range(3)] flag=1 i=0 while flag==1: t=S[i][0] if t=='a': ni=0 elif t=='b': ni=1 elif t=='c': ni=2 S[i]=S[i][1:] #print(i,S[i]) if S[ni]=='': print('A' if i==0 else 'B' if i==1 else 'C') flag=0 else: i=ni
p02879
s116087739
Accepted
A,B = map(int,input().split()) if A < 10 and B < 10: answer = A * B print(answer) else: print('-1')
p03126
s424546683
Wrong Answer
n,m=map(int,input().split()) ans={i for i in range(1,m)} for i in range(n): a=[int(i) for i in input().split()] a=a[1:] ans=ans&set(a) print(len(list(ans)))