Harryxun/stf_run huggingface dataset:
N, A, B, K = map(int, input().split())
mod = 998244353

# 階乗 & 逆元計算
factorial = [1]
inverse = [1]
for i in range(1, N+2):
    factorial.append(factorial[-1] * i % mod)
    inverse.append(pow(factorial[-1], mod-2, mod))


# 組み合わせ計算
def nCr(n, r):
    if n < r:
        return 0
    elif r == 0:
        return 1
    return factorial[n] * inverse[r] * inverse[n - r] % mod


ans = 0
for r in range(N+1):
    b = (K - A*r) / B
    # 青で塗る箇所が整数ならば
    if b == (K-A*r) // B:
        ans += nCr(N, r) * nCr(N, int(b)) % mod

print(ans % mod)


### FIXED CODE ###

N, A, B, K = map(int, input().split())
mod = 998244353

# 階乗 & 逆元計算
factorial = [1]
inverse = [1]
for i in range(1, N+2):
    factorial.append(factorial[-1] * i % mod)
    inverse.append(pow(factorial[-1], mod-2, mod))


# 組み合わせ計算
def nCr(n, r):
    if n < r:
        return 0
    elif r == 0:
        return 1
    return factorial[n] * inverse[r] * inverse[n - r] % mod


ans = 0
for r in range(N+1):
    b = (K - A*r) / B
    # 青で塗る箇所が整数ならば
    if b == (K-A*r) // B and 0 <= b <= N:
        ans += nCr(N, r) * nCr(N, int(b)) % mod

print(ans % mod)
def str_selection_sort(a,n):
    m=0
    for i in range(0,n):
        minj=i
        for j in range(i,n):
            if(int(a[minj][1:]) > int(a[j][1:])):
                minj=j
        if(minj!=i):
            m+=1
            a[minj],a[i] = a[i],a[minj]
        
    print(" ".join(a))
    return a

def bubble_sort(a,n):
    m=0
    flag=True
    while(flag):
        flag=False
        for i in range(n-1,0,-1):
            if(a[i-1][1:] > a[i][1:]):
                tmp=a[i-1]
                a[i-1]=a[i]
                m+=1
                a[i]=tmp
                flag=True
                
    b=list(map(str,a))
    print(" ".join(b))

def is_stable(a,b,n):
    for i in range(1,n):
        if(b[i-1][1:]!=b[i][1:]):
            continue
        flag=False
        for j in a:
            if(j[:1]==b[i-1][:1] and (not flag)):
                flag=True
                continue
            if(j[:1]==b[i][:1]):
                if(not flag):
                    return False
                else:
                    return True
        
        if(flag):
            return False

a=[]
n=int(input())
s=input()
a=s.split()
b=str_bubble_sort(list(a),n)
if(is_stable(a,b,n)):
    print("Stable")
else:
    print("Not stable")
b=str_selection_sort(list(a),n)
if(is_stable(a,b,n)):
    print("Stable")
else:
    print("Not stable")

### FIXED CODE ###

def str_selection_sort(a,n):
    m=0
    for i in range(0,n):
        minj=i
        for j in range(i,n):
            if(int(a[minj][1:]) > int(a[j][1:])):
                minj=j
        if(minj!=i):
            m+=1
            a[minj],a[i] = a[i],a[minj]
        
    print(" ".join(a))
    return a

def str_bubble_sort(a,n):
    m=0
    flag=True
    while(flag):
        flag=False
        for i in range(n-1,0,-1):
            if(a[i-1][1:] > a[i][1:]):
                tmp=a[i-1]
                a[i-1]=a[i]
                m+=1
                a[i]=tmp
                flag=True
                
    print(" ".join(a))
    return a

def is_stable(a,b,n):
    for i in range(1,n):
        if(b[i-1][1:]!=b[i][1:]):
            continue
        flag=False
        for j in a:
            if(j[:1]==b[i-1][:1] and (not flag)):
                flag=True
                continue
            if(j[:1]==b[i][:1]):
                if(not flag):
                    return False
                else:
                    return True
        
        if(flag):
            return False
    return True

a=[]
n=int(input())
s=input()
a=s.split()
b=str_bubble_sort(list(a),n)
print("Stable")
c=str_selection_sort(list(a),n)
if(b==c):
    print("Stable")
else:
    print("Not stable")
n=int(input())

for i in range(n)
    if i % 3 == 0 or i//10 == 3 :
        print(str(i) + " ")
    else : 



### FIXED CODE ###

n=int(input())
for i in range(n):
    if (i+1) % 3 == 0 or "3" in str(i+1) :
        print(" " + str(i+1), end="")
print()
i = 1
while 1:
  x,y = map( int , raw_input().split() )
  if (x,y) == (0,0)
    break
  change = x
  x = y
  y = change
  print "%d %d" %(x,y) 

### FIXED CODE ###

while 1:
  x,y = map( int , raw_input().split() )
  if x == 0 and y == 0:
    break
  elif x <= y:
    print "%d %d" %(x,y) 
  elif y < x : 
    print "%d %d" %(y,x)
import collections as c
# from fractions import gcd
from math import gcd
ip = lambda : map(int, input().split())
# ##############
mod = 1e9+7
S = input()
for i in range(3):
    if S[i] == S[i+1]:
        print('Bad')
        exit()
print('Good')

### FIXED CODE ###

import collections as c
ip = lambda : map(int, input().split())
# ##############
mod = 1e9+7
S = input()
for i in range(3):
    if S[i] == S[i+1]:
        print('Bad')
        exit()
print('Good')
N = int(input())

if N == 1:
	print('Hello World')
else:
	for i in range(2):
		A = int(input())
		B = int(input())
		print(A+B)

### FIXED CODE ###

N = int(input())

if N == 1:
	print('Hello World')
else:
	A = int(input())
	B = int(input())
	print(A+B)
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    m,d = LI()
    ans = 0
    for i in range(1,m+1):
        for j in range(1,d+1):
            d1 = j%10
            d2 = j//10
            if d1 >= 2 and d2 >= 2 and d1*d2 == i:
                ans += 1
    print(ans)
    return

#B
def B():
    def add(i):
        while i <= n:
            bit[i] += 1
            i += i&-i

    def sum(i):
        res = 0
        while i > 0:
            res += bit[i]
            i -= i&-i
        return res

    n,k = LI()
    a = LI()
    bit = [0]*(n+1)
    ans = 0
    for i in range(n):
        ans += (i-sum(a[i]))*k
        add(a[i])
    inv = pow(2,mod-2,mod)
    for i in range(n):
        ans += sum(a[i]-1)*k*(k-1)*inv%mod
    print(ans%mod)
    return

#C
def C():

    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    B()


### FIXED CODE ###

#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    m,d = LI()
    ans = 0
    for i in range(1,m+1):
        for j in range(1,d+1):
            d1 = j%10
            d2 = j//10
            if d1 >= 2 and d2 >= 2 and d1*d2 == i:
                ans += 1
    print(ans)
    return

#B
def B():
    def add(i):
        while i <= m:
            bit[i] += 1
            i += i&-i

    def sum(i):
        res = 0
        while i > 0:
            res += bit[i]
            i -= i&-i
        return res

    n,k = LI()
    m = 2000
    a = LI()
    bit = [0]*(m+1)
    ans = 0
    for i in range(n):
        ans += (i-sum(a[i]))*k
        add(a[i])
    inv = pow(2,mod-2,mod)
    for i in range(n):
        ans += sum(a[i]-1)*k*(k-1)*inv%mod
    print(ans%mod)
    return

#C
def C():
    n = I()

    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    B()
x,y=0,0
for s,t,u in a:
    if u==1:
        x=max(x,s)
    elif u==2:
        w=min(w,s)
    elif u==3:
        y=max(y,t)
    else:
        h=min(h,t)
height=max(0,h-y)
width=max(0,w-x)
print(height*width)

### FIXED CODE ###

w,h,n=map(int,input().split())
a=[[int(i) for i in input().split()] for i in range(n)]
nx=w
ny=h
x=0
y=0
for i in a:
    if i[2]==1:
        x=max(i[0],x)
    elif i[2]==2:
        nx=min(i[0],nx)
    elif i[2]==3:
        y=max(y,i[1])
    else :
        ny=min(ny,i[1])
xx=nx-x
yy=ny-y
print(xx*yy if xx>0 and yy>0 else 0)
N = input()
D = input()
count = 0
for i in range (N):
    x = input()
    y = input()
    if((D * D) >= ((x * x) + (y * y))):
        ++count
print(count)

### FIXED CODE ###

import math
n, d = list(map(int, input().split()))
count = 0
for _ in range(n):
  x, y = list(map(int, input().split()))
  if math.sqrt(x**2 + y**2) <= d:
    count += 1
print(count)
n, k = map(int, input().split())
a = list(map(int, input().split()))
now = 1
chk = [0] * n
flg = True
count = 0
chk[0] = 1
if k < 10 ** 5:
    for i in range(k):
        now = a[now - 1]
else:
    while flg:
        count += 1
        now = a[now - 1]
        if chk[now - 1] == 0:
            chk[now - 1] = count
        else:
            flg = False
            rem = (k - count) % (count - chk[now - 1])
    else:
        for i in range(rem):
            now = a[now - 1]
print(now)

### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
now = 1
chk = [0] * n
flg = True
count = 0
if k < 10 ** 7:
    for i in range(k):
        now = a[now - 1]
else:
    while flg:
        count += 1
        now = a[now - 1]
        if chk[now - 1] == 0 and now != 1:
            chk[now - 1] = count
        else:
            flg = False
            if (k - count) != 0 and (count - chk[now - 1]) != 0:
                rem = (k - count) % (count - chk[now - 1])
            else:
                rem = 0
    else:
        for i in range(rem):
            now = a[now - 1]
            count += 1
print(now)
import numpy as np

a, b = map(int, input().split(" "))
print(np.max(2*a-1, a+b, 2*b-1))


### FIXED CODE ###

a, b = map(int, input().split(" "))
print(max(2*a-1, a+b, 2*b-1))
L = []
L.append(input())

if L[0] == 'SSS':
	print(0)
elif L[0] == 'RRR':
	print(3)
elif L[0] == 'SSR' or L[0] == 'SRS' or L[0] == 'RSS':
	prinrt(1)
elif L[0] == 'SRR' or L[0] == 'RRS':
	print(2)
elif L[0] == 'RSR':
	print(1)


### FIXED CODE ###



L = []
L.append(input())

if L[0] == 'SSS':
	print(0)
elif L[0] == 'RRR':
	print(3)
elif L[0] == 'SSR' or L[0] == 'SRS':
	print(1)
elif L[0] =='RSS':
	print(1)
elif L[0] == 'SRR' or L[0] == 'RRS':
	print(2)
elif L[0] == 'RSR':
	print(1)
A=int(input()) % 3
B=int(input()) % 3
C=A + B
 
if  A==0 or B==0 or C==0: print("Possible")
else: print("Impossible")

### FIXED CODE ###

a,b=map(int,input().split())
c=a + b
 
if  a%3==0 or b%3==0 or c%3==0: print("Possible")
else: print("Impossible")
N,K=map(int,input().split())
A=sorted(list(map(int,input().split())))
if K in A:
    print("POSSIBLE")
    exit()
s=A[1]-A[0]
for i in range(1,N-1):
    if A[i+1]-A[i]!=s:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")


### FIXED CODE ###

import collections
import fractions
N,K=map(int,input().split())
A=sorted(list(map(int,input().split())))
if K in A:
    print("POSSIBLE")
    exit()
if max(A)<K or len(A)==1:
    print("IMPOSSIBLE")
    exit()
S=collections.Counter([A[i+1]-A[0] for i in range(N-1)])
gcd=S[0]
for s in S:
    gcd=fractions.gcd(gcd,s)


if K%gcd==A[0]%gcd:
    print("POSSIBLE")
    exit()
print("IMPOSSIBLE")
n = int(input())
A = list(map(int, input().split()))
nux = max(A)
B = set(A)
A.sort()
ans = 0
table = [True]*(nux+1)
for ii, s in enumerate(A):
    if table[s] == False:
        continue
    if A[ii+1] != s:
        ans += 1
    i = 1
    while i*s <= nux:
        table[i*s] = False
        i += 1

print(ans)


### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
nux = max(A)
B = set(A)
A.sort()
ans = 0
table = [True]*(nux+1)
for ii, s in enumerate(A):
    if table[s] == False:
        continue
    if ii == n-1:
        ans += 1
    elif A[ii+1] != s:
        ans += 1
    i = 1
    while i*s <= nux:
        table[i*s] = False
        i += 1

print(ans)
n, k, q = map(int, input().split())
points = []
minus = []
for i in range(n):
    points.append(k)
    minus.append(-1)
for i in range(q):
    a = int(input())
    points = np.array(points) + np.array(minus)
    points[a - 1] += 1
for point in points:
    if point > 0:
        print("Yes")
    else:
        print("No")


### FIXED CODE ###

s = input()
if s == "Sunny":
    print("Cloudy")
elif s == "Cloudy":
    print("Rainy")
else:
    print("Sunny")
n = list(map(int, input().split()))
if n[0] !== n[1]:
    print("Yes")
    return
if n[0] !== n[2]:
    print("Yes")
    return
print("No")

### FIXED CODE ###

n = list(map(int, input().split()))
if n[0] != n[1]:
    if n[1] == n[2]:
        print("Yes")
        exit()
    if n[0] == n[2]:
        print("Yes")
        exit()
    if n[0] != n[2]:
        print("No")
        exit()
if n[0] == n[1]:
    if n[0] != n[2]:
        print("Yes")
        exit()
print("No")
input();print("Four"if len(Set(input().split()))>3 else"Three")

### FIXED CODE ###

input();print("Four"if len(set(input().split()))>3 else"Three")
N,M=map(int,input())
t=M//N
#Mを因数分解する必要など無いか…？
#print(t)
for p in reversed(range(2,t+1)):
    if M%p==0:
        print(p)
        break


### FIXED CODE ###

#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    N,K=pin()
    t=K//N
    for i in range(t,0,-1):
        if K%i==0:
            print(i)
            return
        
#%%submit!
resolve()
#106a
a,b=map(int,input().split())
pritn((a-1)*(b-1))

### FIXED CODE ###

#106a
a,b=map(int,input().split())
print((a-1)*(b-1))
# coding: utf-8
 
n, m, x, y = map(int, input().split())
xn = list(map(int, input().split()))
ym = list(map(int, input().split()))
flag = 0

if x < y:
    for i in range(x+1, y+1):
        if max(xn) < i and min(ym)>=i:
            print("No War")
            flag = 1
        elif flag == 0 and i == y:
            print("War")
else:
    print("War")

### FIXED CODE ###

# coding: utf-8
 
a, b, c = map(int, input().split())
 
x = a*10 + b
y = b*10 + c
z = c*10 + a
 
if x >= y and x >= z:
    print(x + c)
elif y >= x and y >= z:
    print(y + a)
else:
    print(z + b)
a,b,c = map(input().split())
if a == b or a == c:
    if b != c:
        print('Yes')
    else:
        print('No')
elif b == c:
    print('Yes')



### FIXED CODE ###

a,b,c = map(int,input().split())
if a == b:
  if a != c and b !=c:
    print('Yes')
  else:
    print('No')
elif a == c:
  if a != b and c != b:
    print('Yes')
  else:
    print('No')
elif b == c:
  if b != a and c != a:
    print('Yes')
  else:
    print('No')
elif a == b == c:
  print('No')
else:
  print('No')
N, K = map(int, input().split())
prices = [int(i) for i in input().split()]
print(sum(prices.sort()[:K]))

### FIXED CODE ###

N, K = map(int, input().split())
prices = [int(i) for i in input().split()]
prices.sort()
print(sum(prices[:K]))
N = int(input())
A = list(map(int, input().split()))

ans = 10**8 
sum_A = sum(A)
hoge = 0


for i in range(N-1):
  CumSum = CumSum + A[i]
  ans = min(ans,(abs((sum_A - hoge)-(hoge))))

print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))

ans = float('inf')
sum_A = sum(A)
hoge = 0


for i in range(N-1):
  hoge = hoge + A[i]
  ans = min(ans,abs(sum_A - (hoge*2)))

print(ans)
s = list(input())
n = len(s)
ans = "No"

for i in range(1 - -(n//2)//2):
    if s[i] == s[n//2 - i - 1] == s[n//2 + i + 1] == s[n - i - 1]:
        ans = "Yes"
    else:
        print("No")
        exit()

print(ans)

### FIXED CODE ###

s = list(input())
n = len(s)
ans = "No"

if n == 3:
    if s[0] == s[2]:
        print("Yes")
        exit()
    else:
        print("No")
        exit()


for i in range(1 - -(n//2)//2):
    if s[i] == s[n//2 - i - 1] == s[n//2 + i + 1] == s[n - i - 1]:
        ans = "Yes"
    else:
        print("No")
        exit()

print(ans)
H,W,D = map(int,(input().split()))

A = [[] for _ in range(H)]
for i in range(H):
    A[i] = list(map(int,(input().split())))

d = {}
for i in range(H):
    for j in range(W):
        d[A[i][j]] = (i,j)

m = [0]*(H*W)
for i in range(1,H*W):
    if i+D <= H*W:
        m[i] = abs(d[i][0] - d[i+D][0]) + abs(d[i][1] - d[i+D][1])
s = [[] for _ in range(D+1)]
for i in range(1,D+1):
    cost = 0
    for j in range(i,H*W-D+1,D):
        cost += abs(d[j][0] - d[j+D][0]) + abs(d[j][1] - d[j+D][1])
        s[i].append(cost)

Q = int(input())
for i in range(Q):
    L,R = map(int,(input().split()))
    r = L%D
    if r == 0:
        r = D
    ans = s[r][(R-1)//D-1]-s[r][(L-1)//D-1]
    print(ans)

### FIXED CODE ###

H,W,D = map(int,(input().split()))

A = [[] for _ in range(H)]
for i in range(H):
    A[i] = list(map(int,(input().split())))

d = {}
for i in range(H):
    for j in range(W):
        d[A[i][j]] = (i,j)

s = [[] for _ in range(D+1)]
for i in range(1,D+1):
    cost = 0
    s[i].append(0)
    for j in range(i,H*W-D+1,D):
        cost += abs(d[j][0] - d[j+D][0]) + abs(d[j][1] - d[j+D][1])
        s[i].append(cost)

Q = int(input())
for i in range(Q):
    L,R = map(int,(input().split()))
    r = L%D
    if r == 0:
        r = D
    ans = s[r][(R-r)//D]-s[r][(L-r)//D]
    print(ans)
def findNextAnimal(oxList, swList, index):
    nextAns = oxList[index]
    before = swList[index-1]
    animal = swList[index]
    nextAnimal = ""
    if(nextAns == "o" and before == "S" and animal == "S"):
        nextAnimal = "S"
    elif(nextAns == "o" and before == "S" and animal == "W"):
        nextAnimal = "W"
    elif(nextAns == "o" and before == "W" and animal == "S"):
        nextAnimal = "W"
    elif(nextAns == "o" and before == "W" and animal == "W"):
        nextAnimal = "S"
    elif(nextAns == "x" and before == "S" and animal == "S"):
        nextAnimal = "W"
    elif(nextAns == "x" and before == "S" and animal == "W"):
        nextAnimal = "S"
    elif(nextAns == "x" and before == "W" and animal == "S"):
        nextAnimal = "S"
    elif(nextAns == "x" and before == "W" and animal == "W"):
        nextAnimal = "W"
    return nextAnimal

def checkList(oxList, swList):
    ans = 0
    if(swList[-1] == "S"):
        if(oxList[-1] == "x" and swList[-2] != swList[0]):
            ans = 1
        elif(oxList[-1] == "o" and swList[-2] == swList[0]):
            ans = 1
    elif(swList[-1] == "W"):
        if(oxList[-1] == "x" and swList[-2] == swList[0]):
            ans = 1
        elif(oxList[-1] == "o" and swList[-2] != swList[0]):
            ans = 1
            
    ans2 = 0    
    if(swList[0] == "S"):
        if(oxList[0] == "x" and swList[1] != swList[-1]):
            ans2 = 1
        elif(oxList[0] == "o" and swList[1] == swList[-1]):
            ans2 = 1
    elif(swList[0] == "W"):
        if(oxList[0] == "x" and swList[1] == swList[-1]):
            ans2 = 1
        elif(oxList[0] == "o" and swList[1] != swList[-1]):
            ans2 = 1
    
    return ans*ans2

n = raw_input().strip().upper()
oxList = raw_input().strip().lower()

ans = -1
for s0 in ["S", "W"]:
    for s1 in ["S","W"]:
        swList = [0]*int(n)
        swList[0] = s0
        swList[1] = s1
        for i in range(2, int(n)):
            nextAnimal = findNextAnimal(oxList, swList, i-1)
            swList[i] = nextAnimal
        flag = checkList(oxList, swList)
        if(flag == 1):
            ans = ""
            for s in swList:
                ans += s
print ans

### FIXED CODE ###

def countScc(s, c):
    res = 0
    if(2*s <= c):
        res = s
        c = c - 2*s
        res = res + c / 4
    else:
        res = c / 2
    return res

try:
    while True:  
        s, c = raw_input().strip().upper().split()
        print countScc(int(s), int(c))
except EOFError:
    pass
s=input()
list=[]
def roopR(l,n):
  if list[l]==-1:
    if n%2==0:
      return l
    else:
      return l-1
  else:
    return roopR(l+1,n+1)
  
def roopL(l,n):
  if list[l]==1:
    if n%2==0:
      return l
    else:
      return l+1
  else:
    return roopL(l-1,n+1)

a=len(s)
for i in range(a):
  if s[i]=='R':
    list.append(1)
  else:
    list.append(-1)
endlist=[]
for j in range(a):
  endlist.append(0)
for k in range(a):
  if list[k]==1:
    b=roopR(k,0)
    endlist[b] += 1
  else:
    b=roopL(k,0)
    endlist[b] += 1
print(*endlist)

### FIXED CODE ###

S=input()
dp=[0]*len(S)
a=0
for i in range(len(S)):
  if S[i]=='R':
    a+=1
  else:
    dp[i]+=a//2
    dp[i-1]+=a-a//2
    a=0
for i in range(len(S)-1,-1,-1):
  if S[i]=='L':
    a+=1
  else:
    dp[i]+=a//2
    dp[i+1]+=a-a//2
    a=0
print(*dp)
# coding: UTF-8
from collections import deque
visited = set()
d = {}
arrow = {}
raw = input().split()
N = int(raw[0])
M = int(raw[1])

for i in range(1,N+1):
  arrow[i] = deque()
  d[i] = 0

for i in range(M):
  raw = list(map(int,input().split()))
  L = raw[0]
  R = raw[1]
  D = raw[2]
  arrow[L].append((R,D))
  arrow[R].append((L,-D))

def dfsl(v):
  #矛盾が見つかればFalseを返す
  visited.add(v)
  while arrow[v]:
    w,cost = arrow[v].pop()
    
    if w not in visited:
      d[w] = d[v] + cost
      #print("not visited")
      #print([d[v],d[w],cost])
      return dfsl(w)
    else:
      if d[w] != d[v] + cost:
        #print("visited")
        #print([d[v],d[w],cost])
        return False
  return True

ans = True
for u in range(1,N+1):
  if u not in visited:
    d[u] = 0
    ans = dfsl(u)
    if not ans:
      break
  

if ans:
  print("Yes")
else:
  print("No")     
      

### FIXED CODE ###

# coding: UTF-8
from collections import deque
N,M = map(int,input().split())
link = [ [] for _ in range(N+1)]
value = [ -1 for _ in range(N+1)]

for _ in range(M):
  L,R,D = map(int,input().split())
  link[L].append((R,D))
  link[R].append((L,-D))

searched = set()
queue = deque()
for u in range(N+1):
  if u not in searched:
    queue.append(u)
    searched.add(u)
    value[u] = 0
    while queue:
      v = queue.popleft()
      for w,d in link[v]:
        if w not in searched:
          value[w] = value[v] + d
          queue.append(w)
          searched.add(w)

#verification
for v in range(N+1):
  for w,d in link[v]:
    if value[w] != value[v] + d:
      print("No")
      exit()
print("Yes")
from sys import stdin
 
r = int(stdin.readline().rstrip())
print(r*2*3.1415)

### FIXED CODE ###

from sys import stdin

holiday_count, task_count = stdin.readline().rstrip().split()
holiday_count = int(holiday_count)
tasks_days = sum([int(x) for x in stdin.readline().rstrip().split()])

remain = holiday_count - tasks_days
if remain < 0:
  print(-1)
else:
  print(remain)
str = input()

str[2] == str[3] and str[4] == str[5] ? 'Yes' : 'No'


### FIXED CODE ###

str = input()

if str[2] == str[3] and str[4] == str[5]:
  print('Yes')
else :
  print('No')
from math import pi

r = int(input())

print(r ** 2 * pi, 2 * r * pi) 

### FIXED CODE ###

from math import pi

r = float(input())

s = "{:.6f}".format(r ** 2 * pi) 
l = "{:.6f}".format(r * 2 * pi)

print(s, l)
# -*- coding:utf8 -*-

n = int(input())
l = list(map(int, input().split()))
c,p = 0,0
t = []
for i,n in enumerate(l):
    if p == 0:
        pass
    elif n <= p:
        c += 1
        if i == len(l) - 1:
            t.append(c)
    else:
        t.append(c)
        c = 0
    p = n
ans = max(t)
print(ans)



### FIXED CODE ###

# -*- coding:utf8 -*-

n = int(input())
l = list(map(int, input().split()))
c,p = 0,0
t = [0]
for i,n in enumerate(l):
    if p == 0:
        pass
    elif n <= p:
        c += 1
        if i == len(l) - 1:
            t.append(c)
    else:
        t.append(c)
        c = 0
    p = n
ans = max(t)
print(ans)
n, y = map(int, input().split())
for i in range(n + 1):
    for j in range(n - i + 1):
        if i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
            print(i, j, n - i - j)
            exit()
print("-1 -1 -1")


### FIXED CODE ###

n=int(input())
d=list(map(int, [input() for i in range(n)]))
print(len(set(d)))