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

import sys

input = sys.stdin.readline


def ii():
    return int(input())


def il():
    return list(map(int, input().split()))


K, S = il()
c = 0
for x in range(K + 1):
    for y in range(K + 1):
        for z in range(K + 1):
            if (x + y + z) == S:
                c += 1
print(c)


### FIXED CODE ###

import sys

input = sys.stdin.readline


def ii():
    return int(input())


def il():
    return list(map(int, input().split()))


K, S = il()
c = 0
for x in range(K + 1):
    for y in range(K + 1):
        if 0 <= (S - (x + y)) <= K:
            c += 1
print(c)
### BUGGY CODE ###

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

MOD = 10 ** 9 + 7

def comb(n, r):
    fn = 1
    finv_r = 1
    for i in range(r):
        fn *= n - i
        finv_r *= pow(i+1, MOD-2, MOD)

    return fn * finv_r % MOD
    

ans = pow(2, n, MOD) - 1 - comb(n, a) - comb(n, b)
ans %= MOD
print(ans)


### FIXED CODE ###

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

MOD = 10 ** 9 + 7

def comb(n, r):
    ret = 1
    for i in range(r):
        ret *= n - i
        ret %= MOD
    for i in range(r):
        ret *= pow(i+1, MOD-2, MOD)
        ret %= MOD

    return ret % MOD
    

ans = pow(2, n, MOD) - 1 - comb(n, a) - comb(n, b)
ans %= MOD
print(ans)
### BUGGY CODE ###

#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)

MOD = 998244353  # type: int

def calc_fraction_mod(numerator, denominator):
    '''
        returns numerator / denominator (mod MOD)
    '''
    inv = pow(denominator, MOD - 2, MOD)
    return numerator * inv % MOD


def solve(N: int, S: int, A: "List[int]"):
    dp = [0] * (S + 1)
    dp[0] = pow(2, N, MOD)
    for a in A:
        for s in range(S + 1)[::-1]:
            if dp[s] == 0:
                continue
            if s + a <= S:
                dp[s + a] += calc_fraction_mod(dp[s], 2)
                dp[s + a] %= MOD
    print(dp[S] % MOD)
    #ret = 0
    #print(ret)

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, S, A)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)

MOD = 998244353  # type: int
INV = pow(2, MOD - 2, MOD)

def calc_fraction_mod(numerator):
    '''
        returns numerator / denominator (mod MOD)
    '''
    #inv = pow(denominator, MOD - 2, MOD)
    return numerator * INV % MOD


def solve(N: int, S: int, A: "List[int]"):
    A.sort()
    dp = [0] * (S + 1)
    dp[0] = pow(2, N, MOD)
    for i, a in enumerate(A):
        for s in range(S + 1)[::-1]:
            if dp[s] == 0:
                continue
            if s + a <= S:
                dp[s + a] += calc_fraction_mod(dp[s])
                dp[s + a] %= MOD
    print(dp[S])

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, S, A)

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

s=input()
x,y=map(int,input().split())
xpossible=[0]
ypossible=[0]
j=0
while s[j]=='F':
  xpossible[0]+=1
  if j==len(s):
    break
counter=0
for i in range(j,len(s)):
  current=0
  while s[i]=='F':
    current+=1
    if i==len(s):
      break
  r=set()
  if counter==0:
    for j in xpossible:
      r.add(j+current)
      r.add(j-current)
    xpossible=[]
    for j in r:
      xpossible.append(j)
  else:
    for j in ypossible:
      r.add(j+current)
      r.add(j-current)
    ypossible=[]
    for j in r:
      ypossible.append(j)
  current=0
  while s[i]=='T':
    i+=1
    current+=1
    if i==len(s):
      break
  counter=(counter+current)%2
if x in xpossible and y in ypossible:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

s=input()
x,y=map(int,input().split())
xpossible=[0]
ypossible=[0]
j=0
while s[j]=='F':
  j+=1
  xpossible[0]+=1
  if j==len(s):
    break
counter=0
i=j
while i<len(s):
  current=0
  while s[i]=='F':
    i+=1
    current+=1
    if i==len(s):
      break
  r=set()
  if counter==0:
    for j in xpossible:
      r.add(j+current)
      r.add(j-current)
    xpossible=[]
    for j in r:
      xpossible.append(j)
  else:
    for j in ypossible:
      r.add(j+current)
      r.add(j-current)
    ypossible=[]
    for j in r:
      ypossible.append(j)
  if i==len(s):
    break
  current=0
  while s[i]=='T':
    i+=1
    current+=1
    if i==len(s):
      break
  counter=(counter+current)%2
if x in xpossible and y in ypossible:
  print('Yes')
else:
  print('No')
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
answer = 0
r = 0
flag = 0
gear = 0
for i in range(N) :
    A[i] = A[i]-(i+1)
    if A[i] <= 0 :
        r += 1
    answer += abs(A[i])
if r == N :
    gear += 1
while flag == 0 :
    p = 0
    q = 0
    if gear == 0 :
        for j in range(N) :
            A[j] = A[j]-1
            if A[j] <= 0 :
                q += 1
            p += abs(A[j])
    else :
        for j in range(N) :
            A[j] = A[j]+1
            if A[j] >= 0 :
                q += 1
            p += abs(A[j])
    if p < answer :
        answer = p
    if q == N :
        flag += 1
print(answer)


### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
answer = 0
for i in range(N) :
    A[i]-= i+1
A = sorted(A)
if N % 2 != 0 :
    a = A[N//2]
else :
    a = (A[N//2]+A[N//2-1])//2
for j in range(N) :
    A[j] -= a
    answer += abs(A[j])
print(answer)
### BUGGY CODE ###

import sys
n, K = map(int, sys.stdin.readline().split())
H = list(map(int, sys.stdin.readline().split()))

p = [float('inf') for _ in range(n)]
p[0] = 0
for i in range(1, n):
    for k in range(1, K+1):
        if i-k >=0:
            tmp = abs(H[i]-H[i-k]) + p[i-k]
            if p[i] > tmp:
                p[i] = tmp

print(p[-1])

### FIXED CODE ###

import sys
n, K = map(int, sys.stdin.readline().split())
H = list(map(int, sys.stdin.readline().split()))

p = [float('inf') for _ in range(n)]
p[0] = 0
for i in range(1, n):
    for k in range(1, K+1):
        if i-k >=0:
            tmp = abs(H[i]-H[i-k]) + p[i-k]
            if p[i] > tmp:
                p[i] = tmp

print(p[-1])
### BUGGY CODE ###

N = int(input())
S = input().rstrip()

ans = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            num = str(i) + str(j) + str(k)
            tmp = 0

            for s in S:
                if num[tmp] == s:
                    tmp += 1

                if tmp >= 3:
                    break

            if tmp == 3:
                ans += 1

print(ans)


### FIXED CODE ###

N = int(input())
S = input().rstrip()

ans = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            num = str(i) + str(j) + str(k)
            tmp = 0

            for s in S:
                if num[tmp] == s:
                    tmp += 1

                if tmp >= 3:
                    break

            if tmp == 3:
                ans += 1

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

N, M = input().split()
pS = [input().split() for i in range(int(M))]
ans = {}
ac = 0
wa = 0
for i in pS:
    if i[0] not in ans.keys():
        ans[i[0]] = [0, 0]
        if i[1] == "AC":
            ans[i[0]][0] += 1
            ac += 1
        elif i[1] == "WA":
            ans[i[0]][1] += 1
    else:
        if i[1] == "AC":
            if ans[i[0]][0] == 0:
                    ans[i[0]][0] += 1
                    ac += 1
                    wa += ans[i[0]][1]
        elif i[1] == "WA":
            if ans[i[0]][0] >= 1:
                pass
            else:
                ans[i[0]][1] += 1

"""
for i in ans.values():
    ac += i[0]
    if i[0] >= 1:
        wa += i[1]
"""
print(ac, wa)

### FIXED CODE ###

from sys import stdin
def main(pS):
    ans = {}
    ac = 0
    wa = 0
    for i in pS:
        if i[0] not in ans.keys():
            ans[i[0]] = [0, 0] 
        if i[1] == "AC":
            if ans[i[0]][0] == 0:
                    ans[i[0]][0] += 1
                    ac += 1
                    wa += ans[i[0]][1]
        elif i[1] == "WA":
            if ans[i[0]][0] == 0:
                ans[i[0]][1] += 1
    return [ac, wa]

"""
for i in ans.values():
    ac += i[0]
    if i[0] >= 1:
        wa += i[1]
"""
if __name__ == "__main__":
    N, M = input().split()
    pS = [stdin.readline().rstrip().split() for _ in range(int(M))]
    ac, wa = main(pS)
    print(ac, wa)
### BUGGY CODE ###

import sys
def main():
  N = int(input())
  
  print(0, flush = True)
  s = str(input())
  if s == "Vacant":sys.exit()
  l = [0, s]
  
  print((N-1), flush = True)
  r =  [N-1, str(input())]
  if r[1] == "Vacant":sys.exit()
  
  while True:
    print((l[0] + r[0])//2, flush = True)
    c = [(l[0] + r[0])//2, str(input())]
    if c[1] == "Vacant":sys.exit()
    if ((c[0]-l[0])%2 == 1 and nex[1] == bef[1]) or (c[0]-l[0])%2 == 0 and nex[1] != bef[1]:
      r = c
    else:
      l = c
          
if __name__ == "__main__":
  main()

### FIXED CODE ###

import sys
def main():
  N = int(input())
  
  print(0, flush = True)
  s = str(input())
  if s == "Vacant":sys.exit()
  l = [0, s]
  
  print((N-1), flush = True)
  r =  [N-1, str(input())]
  if r[1] == "Vacant":sys.exit()
  
  while True:
    print((l[0] + r[0])//2, flush = True)
    c = [(l[0] + r[0])//2, str(input())]
    if c[1] == "Vacant":sys.exit()
    if ((c[0]-l[0])%2 == 1 and c[1] == l[1]) or (c[0]-l[0])%2 == 0 and c[1] != l[1]:
      r = c
    else:
      l = c
          
if __name__ == "__main__":
  main()
### BUGGY CODE ###

from copy import deepcopy
H, W = map(int, input().split())
spots = []
dirs = [[0, 1], [1, 0], [0, -1], [-1, 0]]
maze = []
for h in range(H):
  line = list(input())
  maze.append(line)
res = 0

for h in range(H):
  for w in range(W):
    if maze[h][w] == '.':
      newMaze = deepcopy(maze)
      # print(j, i)
      # for line in newMaze:
      #   print(line)
      # print()
      newSpots = [[h, w]]
      count = 0
      while True:
        spots = newSpots
        newSpots = []
        # print(count)
        # for line in newMaze:
        #   print(line)
        # print()
        if 0 < len(spots):
          count += 1
        else:
          break
        for pos in spots:
          newMaze[pos[0]][pos[1]] = '#'
          if res < count:
            res = count
          # if j == 5 and i == 4:
          #   for line in newMaze:
          #     print(line)
          #   print()
          for d in dirs:
            x = d[1] + pos[1]
            y = d[0] + pos[0]
            if 0 <= x < W and 0 <= y < H and newMaze[y][x] == '.':
              nextPos = newMaze[y][x]
              newSpots.append([y, x])
      if res < count:
        res = count
print(res-1)

### FIXED CODE ###

from copy import deepcopy
H, W = map(int, input().split())
spots = []
dirs = [[0, 1], [1, 0], [0, -1], [-1, 0]]
maze = []
for h in range(H):
  line = list(input())
  maze.append(line)
res = 0
for h in range(H):
  for w in range(W):
    if maze[h][w] == '.':
      newMaze = deepcopy(maze)
      newMaze[h][w] = '#'
      # print(j, i)
      # for line in newMaze:
      #   print(line)
      # print()
      newSpots = [[h, w]]
      count = 0
      while True:
        spots = newSpots
        newSpots = []
        # print(count)
        # for line in newMaze:
        #   print(line)
        # print()
        if 0 < len(spots):
          count += 1
        else:
          break
        for pos in spots:
          # if j == 5 and i == 4:
          #   for line in newMaze:
          #     print(line)
          #   print()
          for d in dirs:
            x = d[1] + pos[1]
            y = d[0] + pos[0]
            if 0 <= x < W and 0 <= y < H and newMaze[y][x] == '.':
              newMaze[y][x] = '#'
              newSpots.append([y, x])
      if res < count:
        res = count
print(res-1)
### BUGGY CODE ###

one,zero,ng_one,card = map(int, input().split())

card_list = []
for i in range(one):
    card_list.append(1)
for i in range(zero):
    card_list.append(0)
for i in range(ng_one):
    card_list.append(-1)

print(sum(card_list[:card]))


### FIXED CODE ###

one,zero,ng_one,card = map(int, input().split())

if card < one:
    print(card)
elif card <= one+zero:
    print(one)
else:
    print(one - (card - one - zero))
### BUGGY CODE ###

import math

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

mod = 10**9 + 7
n, k = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
a_reverse = a.copy()[::-1]

plus = 0
minus = 0
cnt = 0
ind = 0
ceil = nCr(n, k)
while cnt < ceil:
    kaisu = nCr(n-(ind+1), k-1)
    cnt += kaisu
    plus = plus + kaisu * a_reverse[ind]
    minus = minus + kaisu * a[ind]
    ind += 1

print((plus-minus) % mod)

### FIXED CODE ###

n,k = map(int, input().split())
a = sorted(list(map(int, input().split())))
a_reverse = a[::-1]
mod = 10**9+7
 
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 comb(n, r, mod):
    if n < r or r < 0:
        return 0
    elif r == 0:
        return 1
    return factorial[n] * inverse[r] * inverse[n - r] % mod

plus = 0
minus = 0
cnt = 0
ind = 0
for i in range(n-k+1):
    kaisu = comb(n-i-1, k-1, mod)
    plus = (plus + (kaisu * a_reverse[ind]) % mod) % mod
    minus = (minus + (kaisu * a[ind]) % mod) % mod
    ind += 1

print((plus-minus) % mod)
### BUGGY CODE ###

import collections
n = int(input())
a = list(map(int,input().split()))

count = 0
c = collections.Counter(a)
c_value = c.values()
c_key = c.keys()


i = 1
flag = True
count = 0
while flag:
  if i in list(c_key):
    print(c[i])
    if count == n-1:
      flag = False
  else:
    print(0)
    if count == n-1:
      flag = False
  i += 1
  count += 1

### FIXED CODE ###

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

ans = [0] * n

for i in range(n-1):
  rem = a[i] - 1
  ans[rem] += 1

for i in range(n):
  print(ans[i])
### BUGGY CODE ###

h,n = map(int,input().split())
a = list(map(int,input().split()))
 
for i in range(len(a)):
  h -= max(a)
  a.remove(max(a))
  if h <= 0:
    print('Yes')
    exit()
    
print('No')


### FIXED CODE ###

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

if sum(a) >= h:
  print('Yes')
else:
  print('No')
### BUGGY CODE ###

N = int(input())
A = [0]*N
A = list(map(int,input().split()))
Q = int(input())
B = [0]*Q
C = [0]*Q
for i in range(Q):
    B[i],C[i] = map(int,input().split())


S = [0]*Q
for i in range(Q):
    for j in range(N):
        if A[j] == B[i]:
            A[j] = C[i]
    for k in range(N):
        S[i] += A[k] 

for i in range(Q):
    print(S[i])

### FIXED CODE ###

N = int(input())
A = [0]*N
A = list(map(int,input().split()))
Q = int(input())
B = [0]*Q
C = [0]*Q
for i in range(Q):
    B[i],C[i] = map(int,input().split())


S = [0]*Q
# for i in range(Q):
#     for j in range(N):
#         if A[j] == B[i]:
#             A[j] = C[i]
#     for k in range(N):
#         S[i] += A[k] 
# for i in range(Q):
#     print(S[i])

cnt = [0] * 100005 # Aの数字の数を格納する，カウント配列
for i in A:
    cnt[i]+=1 

tot = sum(A)
for i in range(Q):
    #合計値の変動
    tot -= B[i]*cnt[B[i]]
    tot -= C[i]*cnt[C[i]]
    #カウント配列の変動
    cnt[C[i]] += cnt[B[i]]
    cnt[B[i]] = 0
    #合計値の変動
    tot += B[i]*cnt[B[i]]
    tot += C[i]*cnt[C[i]]
    print(tot)
### BUGGY CODE ###

N = int(input())
A = []
for i in range(N):
  A.append(int(input())-1)
    
ans = -1
push = 0
count = []
 
for i in range(N+1):
 
    if A[push] == 1:
        ans = i+1
        break
        
    elif A[push] in count:
      break
      
    else:
      count.append(push)
      push = A[push]
        
print(ans)

### FIXED CODE ###

n = int(input())
al = []
for i in range(n):
    a = int(input())
    al.append(a)
 
al.insert(0, 0)
ans = -1
push = 1
for i in range(1, n+2):
    light = al[push]
    push = light
    if light == 2:
        ans = i
        break
print(ans)
### BUGGY CODE ###

import bisect

n = int(input())
s = input()
a_loc = []
b_loc = []
c_acc = [0] * (n + 1)
c_cnt = 0
for i, c in enumerate(s):
    if c == 'D':
        a_loc.append(i)
    elif c == 'M':
        b_loc.append(i)
    elif c == 'C':
        c_cnt += 1
    c_acc[i + 1] = c_cnt

b_rightest = b_loc[-1]
ri = bisect.bisect(a_loc, b_rightest)
q = int(input())
buf = []
for k in map(int, input().split()):
    ans = 0
    for a in a_loc[:ri]:
        i = bisect.bisect(b_loc, a)
        j = bisect.bisect(b_loc, a + k - 1, i)
        cn = c_acc[min(n, a + k)]
        for b in b_loc[i:j]:
            ans += cn - c_acc[b]
    buf.append(ans)
print('\n'.join(map(str, buf)))


### FIXED CODE ###

from itertools import accumulate

n = int(input())
s = input()
acc_cnt_a = [0] * (n + 1)
acc_cnt_b = [0] * (n + 1)
acc_cnt_ab = [0] * (n + 1)
c_loc = []
cnt_a = 0
for i, c in enumerate(s):
    if c == 'D':
        acc_cnt_a[i] += 1
        cnt_a += 1
    elif c == 'M':
        acc_cnt_b[i] += 1
        acc_cnt_ab[i] += cnt_a
    elif c == 'C':
        c_loc.append(i + 1)
acc_cnt_a = [0] + list(accumulate(acc_cnt_a))
acc_cnt_b = [0] + list(accumulate(acc_cnt_b))
acc_cnt_ab = [0] + list(accumulate(acc_cnt_ab))

q = int(input())
buf = []
for k in map(int, input().split()):
    ans = 0
    for r in c_loc:
        l = r - k
        if l > 0:
            rejected_a = acc_cnt_a[l]
            cnt_internal_b = acc_cnt_b[r] - acc_cnt_b[l]
            cnt_internal_ab = acc_cnt_ab[r] - acc_cnt_ab[l]
            ans += cnt_internal_ab - rejected_a * cnt_internal_b
        else:
            ans += acc_cnt_ab[r]
    buf.append(ans)
print('\n'.join(map(str, buf)))
### BUGGY CODE ###

import numpy as np
from collections import deque

h, w = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
base = ["#" *(w+4)]
base.append("#" * (w+4))
for n in range(h):
    base.append("##" + input() + "##")
base.append("#" * (w+4))
base.append("#" * (w+4))
ans = [[-1] * (w+4) for _ in range(h+4)]
for j in range(w+4):
    for i in range(h+4):
        if base[i][j] == "#":
            ans[i][j] = -2
ch+=1; cw+=1
dh+=1; dw+=1
ans[ch][cw] = 0
move = [[1, 0], [-1, 0], [0, 1], [0, -1]]
move2 = [
    [-2, -2], [-2, -1], [-2, 0], [-2, 1], [-2, 2], \
    [-1, -2], [-1, -1], [-1, 0], [-1, 1], [-1, 2], \
    [0, -2], [0, -1], [0, 0], [0, 1], [0, 2], \
    [1, -2], [1, -1], [1, 0], [1, 1], [1, 2], \
    [2, -2], [2, -1], [2, 0], [2, 1], [2, 2]]
q = deque([[ch, cw]])
one_time = deque()
while q:
    x, y = q.popleft()
    one_time.append([x, y])
    for i, j in move:
        v1, v2 = x+i, y+j
        if ans[v1][v2] == -1:
            ans[v1][v2] = ans[x][y]
            q.append([v1, v2])
    if len(q) == 0:
        while one_time:
            x2, y2 = one_time.popleft()
            for i, j in move2:
                v1, v2 = x2+i, y2+j
                if ans[v1][v2] == -1:
                    ans[v1][v2] = ans[x2][y2] + 1
                    q.append([v1, v2])
print(ans[dh][dw])

### FIXED CODE ###

from collections import deque
 
 
# In[30]:
 
 
def main():
    H,W = map(int, input().split())
    ch,cw = map(int, input().split())
    dh,dw = map(int, input().split())
    s = ["#"*(W+4)]
    s.append("#"*(W+4))
    for i in range(H):
        s.append("##"+input()+"##")
    s.append("#"*(W+4))
    s.append("#"*(W+4))
    
    ans = [[-1]*(W+4) for _ in range(H+4)]
    for i in range(H+4):
        for j in range(W+4):
            if s[i][j] == "#":
                ans[i][j] = -2
    ch += 1; cw += 1
    dh += 1; dw += 1
    ans[ch][cw] = 0
    
    move = [[-1,0],[1,0],[0,-1],[0,1]]
    magic = [
        [-2,-2],[-2,-1],[-2,0],[-2,1],[-2,2],\
        [-1,-2],[-1,-1],[-1,0],[-1,1],[-1,2],\
        [0,-2],[0,-1],[0,0],[0,1],[0,2],\
        [1,-2],[1,-1],[1,0],[1,1],[1,2],\
        [2,-2],[2,-1],[2,0],[2,1],[2,2]
        ]
    
    mylist = deque([[ch,cw]])
    mylist2 = deque([])
    while len(mylist) > 0:
        x,y = mylist.popleft()
        mylist2.append([x,y])
        for p,q in move:
            v1,v2 = x+p,y+q
            if ans[v1][v2] == -1:
                mylist.append([v1,v2])
                ans[v1][v2] = ans[x][y]
        if len(mylist) == 0:
            while len(mylist2) > 0:
                x2,y2 = mylist2.popleft()
                for v1,v2 in magic:
                    i,j = x2+v1,y2+v2
                    if ans[i][j] == -1:
                        ans[i][j] = ans[x2][y2]+1
                        mylist.append([i,j])
    print(ans[dh][dw])
 
if __name__ == "__main__":
    main()
### BUGGY CODE ###

N=int(input())
s=set()
for i in range(N):s^={input()}
print(len(s))

### FIXED CODE ###

import collections

n = int(input())
a = [int(input()) for _ in range(n)]
b = collections.Counter(a)

cnt = 0
for v in b.values():
    if v % 2 == 1:
        cnt += 1

print(cnt)
### BUGGY CODE ###

import sys

#+++++
		
def main():
	n, k = map(int, input().split())
	aal = list(map(int, input().split()))
	count=0
	for i in range(1, min(n, k)+1):
		#pa(i)
		aa=sum(aal[:i])
		if aa % k == i:
			count+=1
		for j in range(n-i):
			aa += aal[i+j]
			aa -= aal[j]
			count+=(aa % k == i)
	
	print(count)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)


### FIXED CODE ###

import sys
from collections import defaultdict

#+++++
		
def main():
	n, k = map(int, input().split())
	aal = list(map(int, input().split()))
	
	sss = [0]*(n+1)
	si=0
	for i, a in enumerate(aal):
		si+=a-1
		sss[i+1]=si%k
	
	count=0
	mkl_dict=defaultdict(lambda :0)
	for j in range(n+1):
		sj=sss[j]
		if j-k >= 0:
			mkl_dict[sss[j-k]]-=1
		count += mkl_dict[sj]
		mkl_dict[sj] += 1
			
	print(count)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

def main():
    n = int(input())
    alst = list(map(float, input().split()))
    dp = [[[0 for _ in range(n + 1)] for _ in range(n + 1)] for _ in range(n + 1)]
    one = alst.count(1)
    two = alst.count(2)
    three = alst.count(3)
    for k in range(n + 1):
        for j in range(n + 1):
            for i in range(n + 1):
                ijk = i + j + k
                if ijk == 0:
                    continue
                dp[i][j][k] = n / ijk
                if i != 0:
                    dp[i][j][k] += dp[i - 1][j][k] * i / ijk
                if j != 0 and i != n:
                    dp[i][j][k] += dp[i + 1][j - 1][k] * j / ijk
                if k != 0 and j != n:
                    dp[i][j][k] += dp[i][j + 1][k - 1] * k / ijk
    
    print(dp[one][two][three])


main()

### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
    n = int(input())
    alst = list(map(float, input().split()))
    dp = [[[0 for _ in range(n + 1)] for _ in range(n + 1)] for _ in range(n + 1)]
    one = alst.count(1)
    two = alst.count(2)
    three = alst.count(3)
    for k in range(three + 1):
        for j in range(two + three + 1):
            if k + j > n:
                continue
            for i in range(n + 1):
                if k + j + i > n:
                    continue
                ijk = i + j + k
                if ijk == 0:
                    continue
                tmp = n
                if i != 0:
                    tmp += dp[i - 1][j][k] * i
                if j != 0 and i != n:
                    tmp += dp[i + 1][j - 1][k] * j
                if k != 0 and j != n:
                    tmp += dp[i][j + 1][k - 1] * k
                dp[i][j][k] = tmp / ijk
    
    print(dp[one][two][three])


main()