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

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,p = inpl()
s = input()[::-1]
res = 0
if p == 2 or p == 5:
    s = s[::-1]
    for i,t in enumerate(s):
        if int(t)%p == 0: 
            res += i+1
    print(res)
    quit()
now = 0
d = [0] * p
d[0] = 1
for i,t in enumerate(s):
    now += int(t) * pow(10,i)
    now %= p
    d[now] += 1
for i in range(p):
    v = d[i]
    res += v*(v-1)//2
print(res)

### FIXED CODE ###

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,p = inpl()
s = input()[::-1]
res = 0
if p == 2 or p == 5:
    s = s[::-1]
    for i,t in enumerate(s):
        if int(t)%p == 0: 
            res += i+1
    print(res)
    quit()
now = 0
d = [0] * p
d[0] = 1
for i,t in enumerate(s):
    now += int(t) * pow(10,i,p)
    now %= p
    d[now] += 1
for i in range(p):
    v = d[i]
    res += v*(v-1)//2
print(res)
### BUGGY CODE ###

import numpy as np

n, m = map(int, input().split())
A = np.array(list(map(int, input().split())))

ans = 0
for l in range(n):
    for r in range(l, n):
        if np.sum(A[l:r + 1]) % m == 0:
            ans += 1
print(ans)

### FIXED CODE ###

import numpy as np
from collections import Counter
import math

n, m = map(int, input().split())
A = np.array(list(map(int, input().split())))


def combinations(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

acc_sum = [0]
tmp = 0
for i in range(n):
    tmp += A[i]
    acc_sum.append(tmp % m)
acc_sum = Counter(acc_sum)
ans = 0
for k in acc_sum:
    if acc_sum[k] >= 2:
        ans += combinations(acc_sum[k], 2)
print(ans)
### BUGGY CODE ###

import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.read
from collections import deque
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N, K = map(int, readline().split())
    A = list(map(int, readline().split()))
    plus = False

    for a in A:
        if a>0:
            plus = True
            break

    A.sort(reverse=True)

    if K%2==1 and plus==False:
        ans = 1
        for i in A[:K]:
            ans *= i % MOD
        ans %= MOD
    else:
        A = deque(A)
        ans = 1
        left = 0
        right = N-1
        if K%2==1:
            ans *= A[left]
            left += 1
        for _ in range(K//2):
            if A[left]*A[left+1]>=A[right]*A[right-1]:
                ans *= A[left]*A[left+1]%MOD
                left += 2
            else:
                ans *= A[right]*A[right-1] % MOD
                right -= 2
        ans %= MOD

    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.read
from collections import deque
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    n, k = map(int, readline().split())
    A = list(map(int, readline().split()))
    MOD = int(1e9) + 7
    A.sort()
    ans = 1
    if A[n - 1] == 0 and (k & 1):
        ans = 0
    elif A[n - 1] <= 0 and (k & 1):
        for i in range(n - 1, n - k - 1, -1):
            ans = (ans * A[i]) % MOD
    else:
        i = 0
        j = n - 1
        if k & 1:
            ans = (ans * A[j]) % MOD
            j -= 1
            k -= 1
        k >>= 1
        for itr in range(k):
            left_product = A[i] * A[i + 1]
            right_product = A[j] * A[j - 1]
            if left_product > right_product:
                ans = (ans * left_product) % MOD
                i += 2
            else:
                ans = (ans * right_product) % MOD
                j -= 2

    print(ans % MOD)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

#!/usr/bin/env python3
#ABC138 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,q = LI()
g = [[] for _ in range(n)]
for _ in range(n-1):
    a,b = LI()
    g[a-1].append(b-1)
for i in range(n):
    g[i].append(i)
ans = [0]*n
que = deque()
for _ in range(q):
    p,x = LI()
    que.append(p-1)
    check = [True]*n
    while que:
        v = que.popleft()
        for i in g[v]:
            if check[i]:
                check[i] = False
                que.append(i)
                ans[i] += x
print(*ans)


### FIXED CODE ###

#!/usr/bin/env python3
#ABC138 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,q = LI()
g = [[] for _ in range(n)]
for _ in range(n-1):
    a,b = LI()
    g[a-1].append(b-1)

ans = [0]*n
for _ in range(q):
    p,x = LI()
    ans[p-1] += x

que = deque()
que.append(0)
check = [True]*n
while que:
    v = que.popleft()
    for i in g[v]:
        if check[i]:
            check[i] = False
            que.append(i)
            ans[i] += ans[v]
print(*ans)
### BUGGY CODE ###

#!/usr/bin/env python3

from bisect import insort_right

n, m, *a = map(int, open(0).read().split())

a.sort()
for _ in range(m):
    insort_right(a, a.pop() >> 1)
print(sum(a))


### FIXED CODE ###

#!/usr/bin/env python3

from bisect import insort_right

n, m, *a = map(int, open(0).read().split())
a.sort()
for _ in range(m):
    insort_right(a, a.pop() >> 1)
print(sum(a))
### BUGGY CODE ###

N = int(input())
a = [int(i) for i in input().split()]

ans = []
for n in range(N, 0, -1):
    a_i = a[n-1]
    cnt = 0
    n2 = n*2
    while n2 <= N:
        if n2 in ans:
            cnt += 1
        n2 += n
    if cnt % 2 != a_i:
        ans.append(n)

print(len(ans))
if len(ans) != 0:
    print(*ans)


### FIXED CODE ###



from collections import defaultdict
N = int(input())
a = [int(i) for i in input().split()]

d = defaultdict(int)
# balls = [0 for _ in range(N)]

ans = 0
for n in range(N, 0, -1):
    a_i = a[n-1]
    cnt = 0
    n2 = n*2
    while n2 <= N:
        cnt += d[n2]
        n2 += n
    if cnt % 2 != a_i:
        d[n] = 1
        ans += 1

print(ans)
if ans >= 1:
    for k, v in d.items():
        if v == 1:
            print(k)
### BUGGY CODE ###

n = int(input())
ls=[int(input()) for i in range(n)]
ans=[]
for i in range(n):
  ls2 = ls.copy()
  del ls2[i]
  ans.append(max(ls2))
a='\n'.join(map(str,ans))
print(a)


### FIXED CODE ###

n = int(input())
ls=[int(input()) for i in range(n)]
maxn = max(ls)
ans=[maxn]*n
nma = ls.index(maxn)
ls2=ls.copy()
ls2.remove(maxn) 
maxcel= max(ls2)
del ans[nma]
ans.insert(nma,maxcel)
a='\n'.join(map(str,ans))
print(a)
### BUGGY CODE ###

N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]

mod = 1000000007

dp = [0 for _ in range(N + 1)]
dp[0] = 1
if 1 not in A:
    dp[1] = 1

for n in range(2, N + 1):
    if n in A:
        dp[n] = 0
    else:
        dp[n] = (dp[n - 1] + dp[n - 2]) % mod

print(dp[N])


### FIXED CODE ###

N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]

mod = 1000000007

dp = [1 for _ in range(N + 1)]
for a in A:
    dp[a] = 0

for n in range(2, N + 1):
    dp[n] *= dp[n - 1] + dp[n - 2]

    if dp[n] >= mod:
        dp[n] -= mod

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

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 8)

from itertools import accumulate
from scipy.misc import comb


# def factorial(x):
#     if x <= 0:
#         return 1
#
#     return factorial(x - 1) * x
#
#
# def comb(n, r):
#     return factorial(n) / factorial(r) / factorial(n - r)


def main():
    n = int(input())
    l = list(map(int, input().split()))

    nums = [0] * 1001

    for e in l:
        nums[e] += 1

    acm = list(accumulate(nums))

    l.sort()
    ans = 0
    tmp = [0] * 1001
    tmp2 = [[0] * 1001 for _ in range(1001)]
    for i in range(n-2):
        for j in range(i+1, n-1):
            a = l[i]
            b = l[j]
            k = min(1000, a+b-1)

            # b < c のときの数
            cnt = acm[k] - acm[b]

            # b == c のときの補正
            if nums[b] >= 3 and a == b and tmp[b] == 0:
                cnt += int(comb(nums[b], 3))
                tmp[b] = 1

            if nums[b] >= 2 and a != b and tmp2[a][b] == 0:
                cnt += int(comb(nums[b], 2)) * nums[a]
                tmp2[a][b] = 1

            ans += cnt

    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline

from bisect import bisect_left


def main():
    n = int(input())
    l = list(map(int, input().split()))

    l.sort()

    ans = 0
    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            a = l[i]
            b = l[j]
            mx = bisect_left(l, a + b)
            ans += mx - j - 1

    print(ans)


if __name__ == "__main__":
    main()
### BUGGY CODE ###

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

ans = 1000
buy = -1
for bit in range(2 ** n):
    money = 1000
    stock = 0
    for i in range(n):
        if (bit >> i) & 1:
            buy = i
            stock += money // A[i]
            money -= A[i] * (money // A[i])
        else:
            if buy == -1:
                continue
            elif A[buy] < A[i]:
                money += stock * A[i]
                stock = 0
    money += stock * A[-1]
    if money > ans:
        ans = money

print(ans)


### FIXED CODE ###

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

money = 1000
stock = 0

for i in range(n-1):
    if A[i] < A[i+1]:
        tmp = money // A[i]
        stock += tmp
        money -= tmp * A[i]
    if A[i] > A[i+1]:
        money += stock * A[i]
        stock = 0
money += stock * A[-1]
print(money)
### BUGGY CODE ###

K, Q = map(int, input().split())
D = [int(a) for a in input().split()]
for _ in range(Q):
    N, X, M = map(int, input().split())
    t = X%M
    u = 0
    for i in range(K):
        t += ((D[i]-1) % M + 1) * ((N-i-2) // K + 1)
        u += t // M
        t %= M
    print(N - 1 - u)

### FIXED CODE ###

K, Q = map(int, input().split())
D = [int(a) for a in input().split()]
for _ in range(Q):
    N, X, M = map(int, input().split())
    if N <= K + 1:
        A = [0] * N
        A[0] = X % M
        ans = 0
        for i in range(N-1):
            A[i+1] = (A[i] + D[i]) % M
            if A[i+1] > A[i]:
                ans += 1
        print(ans)
        continue
    ans = N - 1
    t = X%M
    for i in range(K):
        d = (D[i]-1) % M + 1
        a = (N-i-2) // K + 1
        t += d * a
    ans -= t // M
    print(ans)
### BUGGY CODE ###

N, M = map(int, input().split())
A_list = sorted(list(map(int, input().split())))

D_list = []
len_D_list = 0
for i in range(M):
    B_i, C_i = map(int, input().split())
    D_list += [C_i] * B_i
    len_D_list += B_i

D_list = sorted(D_list, reverse=True)

# Operate Top N of BC_sorted
len_target = min(len_D_list, N)
for i in range(len_target):
    if A_list[i] < D_list[i]:
        A_list[i] = D_list[i]
    else:
        break

# Output sumed A_list
print(sum(A_list))


### FIXED CODE ###

N, M = map(int, input().split())
A_list = sorted(list(map(int, input().split())))

BC_list = [tuple(map(int, input().split())) for _ in range(M)]
BC_list.sort(key=lambda x: x[1], reverse=True)

n_replace = 0
sum_target = 0
is_broken = False
for B, C in BC_list:
    if n_replace + B <= N:
        for A in A_list[n_replace:n_replace+B]:
            if A < C:
                sum_target += C
                n_replace += 1
            else:
                is_broken = True
                break
    else:
        remaining = N - n_replace
        for A in A_list[n_replace:n_replace+remaining]:
            if A < C:
                sum_target += C
                n_replace += 1
            else:
                is_broken = True
                break
    if is_broken is True:
        break
if n_replace < N:
    sum_target += sum(A_list[n_replace:])

# Output sumed A_list
print(sum_target)
### BUGGY CODE ###

n = int(input())
d = list(map(int,input().split()))
 
ans = 1
if min(d) != 0:
  ans = 0
d.sort()
for i in range(1,max(d)+1):
  ans *= d.count(i-1)**d.count(i)
  if ans == 0:
    break
print(ans%998244353)

### FIXED CODE ###

from collections import Counter
mod=998244353
n=int(input())
d=list(map(int,input().split()))
q=Counter(d)
if q[0]!=1 or d[0]!=0:
	print(0)
	exit()
ans=1
for i in range(1,max(d)+1):
    ans*=pow(q[i-1],q[i],mod)
    ans%=mod
print(ans)
### BUGGY CODE ###

import math

N = int(input())
ans = 0

for i in range(N):
  j = i + 1
  Y = math.floor(N / j)
  ans += Y * (Y+1) * j / 2
  
print(int(ans))
  


### FIXED CODE ###

N = int(input())
ans = 0
 
for i in range(1, N+1):
  Y = N // i
  ans += Y * (Y+1) * i / 2
  
print(int(ans))
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

INF = 10**18+5


def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    a = sorted(a)
    l = -INF
    r = INF

    while(l+1 < r):
        x = (l+r)//2
        total = 0
        for i in range(n):
            if a[i] < 0:
                l2 = -1
                r2 = n
                while(l2+1 < r2):
                    x2 = (l2+r2)//2
                    if a[x2]*a[i] >= x:
                        l2 = x2
                    else:
                        r2 = x2
                total += n-r2
            else:
                l2 = -1
                r2 = n
                while(l2+1 < r2):
                    x2 = (l2+r2)//2
                    if a[x2]*a[i] < x:
                        l2 = x2
                    else:
                        r2 = x2
                total += r2
            if a[i]*a[i] < x:
                total -= 1
        total //= 2
        if total < k:
            l = x
        else:
            r = x

    print(l)


main()


### FIXED CODE ###

import sys
import numpy as np
INF = 10**18+5
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    a = np.sort(a)
    ap = a[a > 0]
    an = a[a < 0]
    zc = n * (n - ap.size - an.size)

    l = -INF
    r = INF
    while(l+1 < r):
        x = (l+r)//2

        total = (n-np.searchsorted(a, -(-x // an), side='left')).sum()
        if x >= 0:
            total += zc
        total += np.searchsorted(a, x // ap, side='right').sum()
        total -= a[a*a <= x].size
        total //= 2
        if total < k:
            l = x
        else:
            r = x

    print(r)


main()
### BUGGY CODE ###

from sys import stdin
from collections import defaultdict
readline = stdin.readline
def i_input(): return int(readline().rstrip())
def i_map(): return map(int, readline().rstrip().split())
def i_list(): return list(i_map())


def main():
    N = i_input()
    d = defaultdict(lambda: 0)
    ans = 0
    for i in range(1, N):
        for j in range(i, N, i):
            d[j] += 1
    for c in range(1, N):
        ab = N - c
        ans += d[ab]
    print(ans)

if __name__ == "__main__":
    main()


### FIXED CODE ###

from sys import stdin
from collections import defaultdict
readline = stdin.readline
def i_input(): return int(readline().rstrip())
def i_map(): return map(int, readline().rstrip().split())
def i_list(): return list(i_map())


def main():
    N = i_input()
    d = defaultdict(lambda: 1)
    ans = 0
    for i in range(2, N):
        for j in range(i, N, i):
            d[j] += 1
    for c in range(1, N):
        ans += d[c]
    print(ans)

if __name__ == "__main__":
    main()
### BUGGY CODE ###

n = int(input())
s = [''.join(sorted(input())) for _ in range(n)]
count = sum([sum([s[i] == si for si in s[i+1:]]) for i in range(n)])
print(count)

### FIXED CODE ###

n = int(input())
count = 0
ls = dict([])
for i in range(n):
    si = ''.join(sorted(input()))
    if si in ls.keys():
        count += ls[si]
        ls[si] += 1
    else:
        ls[si] = 1
print(count)
### BUGGY CODE ###

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

alphabet = "abcdefghijklmnopqrstuvwxyz"
a_len = len(alphabet)
table = {c: idx for idx, c in enumerate(alphabet)}

s = input()
k = int(input())

ans = ""
for i in range(len(s[:-1])):
    gap = a_len - table[s[i]]
    if gap <= k:
        ans += "a"
        k -= gap
    else:
        ans += s[i]

ans += alphabet[(table[s[-1]] + k) % a_len]
print(ans)


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    s = rl().rstrip()
    K = int(rl())
    
    ans = []
    for si in s:
        if si == 'a':
            ans.append('a')
            continue
        cnt = ord('z') - ord(si) + 1
        if cnt <= K:
            ans.append('a')
            K -= cnt
        else:
            ans.append(si)
    
    ans[-1] = chr(ord('a') + (ord(ans[-1]) - ord('a') + K % 26) % 26)
    print(''.join(ans))


if __name__ == '__main__':
    solve()
### BUGGY CODE ###

import math
from sys import stdin


def get_result(data):
    K = data[0]
    ans_list = []
    for i in range(K):
        for j in range(K):
            for k in range(K):
                ans = math.gcd(i+1, j+1)
                ans = math.gcd(ans, k+1)
                ans_list.append(ans)
    return sum(ans_list)


if __name__ == '__main__':
    data = list(map(int, stdin.readline().rstrip().split(' ')))
    result = get_result(data)
    print(result)


### FIXED CODE ###

import math
from sys import stdin


def get_result(data):
    K = data[0]
    ans_list = []
    for i in range(K):
        for j in range(K):
            for k in range(K):
                ans = math.gcd(i+1, j+1)
                ans = math.gcd(ans, k+1)
                ans_list.append(ans)
    return sum(ans_list)


if __name__ == '__main__':
    data = list(map(int, stdin.readline().rstrip().split(' ')))
    result = get_result(data)
    print(result)
### BUGGY CODE ###

N, K = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]

E = [0] * N
for i in range(N):
  E[i] = (1+p[i])/2

ans = 0
for i in range(N-K+1):
  e = 0
  for j in range(i, i+K):
    e += E[j]
  if ans < e:
    ans = e
    
print(ans)


### FIXED CODE ###

N, K = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]

E = [0] * N
for i in range(N):
  E[i] = (1+p[i])/2

e = sum(E[:K])
ans = e
for i in range(1, N-K+1):
  e = e - E[i-1] + E[i+K-1]
  if ans < e:
    ans = e
    
print(ans)
### BUGGY CODE ###

N = int(input()) + 1
NumberList = list()
for i in range(1,N):
    for j in range(1,N):
        for k in range(1,N):
            NumberList.append([i,j,k])

Answer = 0

def getGCD(abc):
    abc.sort(reverse=True)
    a = int(abc[0])
    b = int(abc[1])
    c = int(abc[2])
    surplus = a % b
    while surplus != 0:
        a = int(b)
        b = int(surplus)
        surplus = a % b
    if b > c:
        b,c = c,b
    surplus = c % b
    while surplus != 0:
        c = int(b)
        b = int(surplus)
        surplus = c % b
    return b

for abc in NumberList:
    Answer += getGCD(abc)
print(Answer)


### FIXED CODE ###

N = int(input()) + 1

Answer = 0

def getGCD(a,b,c):
    if a == b and b == c:
        d = 1
    elif a == b or b == c or c == a:
        d = 3
    else:
        d = 6
        
    surplus = a % c
    while surplus != 0:
        a = int(c)
        c = int(surplus)
        surplus = a % c
    surplus = b % c
    while surplus != 0:
        b = int(c)
        c = int(surplus)
        surplus = b % c
    return c * d


for i in range(1,N):
    for j in range(i,N):
        for k in range(j,N):
            Answer += getGCD(k,j,i)
            
print(Answer)
### BUGGY CODE ###

# B Count Balls

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

cnt = 0
ans = 0
while cnt < N - (A + B):
  cnt += A+B
  ans += A

if N - cnt < A:
  ans += N - cnt
else:
  ans += A
  
print(ans)

### FIXED CODE ###

# B Count Balls

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

set, mod = divmod(N, (A + B))
ans = set * A

if mod < A:
  ans += mod
else:
  ans += A

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

X, Y, Z, K = map(int, input().split(" "))

A = sorted(map(int, input().split(" ")),reverse=True)
B = sorted(map(int, input().split(" ")),reverse=True)
C = sorted(map(int, input().split(" ")),reverse=True)

AB = []
for a in A:
    for b in B:
        AB.append(a+b)
AB = sorted(AB, reverse=True)
ABC = []
for ab in AB[:K]:
    for c in C:
        abc = ab + c
        ABC.append(abc)
ABC = sorted(ABC, reverse=True)
for ans in ABC[:K]:
    print(ans)


### FIXED CODE ###

import heapq


class Delicious (object):
    def __init__(self, x, y, z):
        self.x = x
        self.y = y
        self.z = z

    def total(self):
        return(A[self.x] + B[self.y] + C[self.z])

    def __lt__(self, other):
        return self.total() > other.total()


X, Y, Z, K = map(int, input().split(" "))
A = sorted(map(int, input().split(" ")), reverse=True)
B = sorted(map(int, input().split(" ")), reverse=True)
C = sorted(map(int, input().split(" ")), reverse=True)

ds = []
heapq.heappush(ds, Delicious(0, 0, 0))

check = {}

for _ in range(K):
    d = heapq.heappop(ds)
    while (d.x, d.y, d.z) in check:
        d = heapq.heappop(ds)
    print(d.total())
    check[d.x, d.y, d.z] = True

    if d.x < X-1:
        heapq.heappush(ds, Delicious(d.x+1, d.y, d.z))
    if d.y < Y-1:
        heapq.heappush(ds, Delicious(d.x, d.y+1, d.z))
    if d.z < Z-1:
        heapq.heappush(ds, Delicious(d.x, d.y, d.z+1))
### BUGGY CODE ###

N = int(input())
a = list(map(int, input().split()))
cnt = 1
for i in range(N):
    cnt *= a[i]
an = 0
while cnt%2 == 0:
    cnt //= 2
    an += 1
print(an)

### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(N):
    while a[i]%2 == 0:
        a[i] //= 2
        ans += 1
print(ans)
### BUGGY CODE ###

# def makelist(n, m):
#     return [[0 for i in range(m)] for j in range(n)]

# n = int(input())
# a, b = map(int, input().split())
# s = input()


N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

D.sort()
T.sort()

i = 0
ans = "YES"
for e in T:
    while True:
        if i >= N:
            ans = "NO"
            break
        else:
            if D[i] != e:
                i += 1

    if ans == "NO":
        break
print(ans)


### FIXED CODE ###

N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

D.sort()
T.sort()

i = 0
ans = "YES"
for e in T:
    flag = True
    while flag:
        if i >= N:
            ans = "NO"
            break
        else:
            if D[i] == e:
                flag = False
            i += 1

    if ans == "NO":
        break
print(ans)
### BUGGY CODE ###

k,s = map(int,input().split())

cnt = 0

for x in range(k+1):
    for y in range(k+1):
        z = s-x-y
        if z>=0 and z <= k and x+y+z == s:
            cnt +=1
            
            
print(cnt)
    

### FIXED CODE ###

k,s = map(int,input().split())

cnt = 0

for x in range(k+1):
    for y in range(k+1):
        z = s-x-y
        if (z>=0) and (z <= k):
            cnt +=1
            
            
print(cnt)