Harryxun/stf_run huggingface dataset:
S = input()
count = 0

if len(S)<=200000:
    for i in range(len(S)-4):
        for j in range(i+5, len(S)+1):
            tmp = int(S[i:j])
            if tmp%2019==0:
                count += 1

print(count)

### FIXED CODE ###

S, W = map(int, input().split())

if S>W:
    print('safe')
else:
    print('unsafe')
N, M = map(int, input().split())

S, C = [], []
for i in range(M):
  s, c = map(int, input().split())
  S += [s-1]
  C += [str(c)]
  
for i in range(10**(N-1), 10**N):
  flag = 1
  i_str = str(i)
  for m in range(M):
    if i_str[S[m]] != C[m]:
      flag = 0
      break
  if flag:
    print(i)
    break
else:
  print(-1)

### FIXED CODE ###

print(((int(input()))+1)//2)
N,P=[input().split()]
i=2
ans = 1
c=0
while P>1:
  if P%i==0:
    P//=i
    c+=1
    if c==N:
      ans*=i
      c=0
  else:
    c=0
    i+=1

print(ans)

### FIXED CODE ###

import sys

N,P=[int(i) for i in input().split()]
i=2
ans = 1
c=0
if N == 1:
  print(P)
  sys.exit()
while P>i*i-4:
  if P%i==0:
    P//=i
    c+=1
    if c==N:
      ans*=i
      c=0
  else:
    c=0
    i+=1
if P==i and c+1 ==N:
  ans*=i
print(ans)
a, b = map(int, input().split())
d = a // b
r = a % b
f = a / b
print('{0} {1} [2:0.5f}').format(d, r, f)

### FIXED CODE ###

a, b = map(int, input().split())
d = a // b
r = a % b
f = float(a / b)
print('{0} {1} {2:0.5f}'.format(d, r, f))
def fill0(s,x,y):
	A[y][x] = 0
	if x < W-1 and A[y][x+1] == s: fill0(s,x+1,y)
	if y < H-1 and A[y+1][x] == s: fill0(s,x,y+1)
	if x > 0   and A[y][x-1] == s: fill0(s,x-1,y)
	if y > 0   and A[y-1][x] == s: fill0(s,x,y-1)

while 1:
	H,W = map(int,raw_input().split())
	if H == 0: break
	A = [list(raw_input()) for i in range(H)]
	i = 0
	for y in range(H):
		for x in range(W):
			if A[y][x] in ["#","@","*"]:
				fill0(A[y][x],x,y)
				i += 1
	print i

### FIXED CODE ###

import sys
sys.setrecursionlimit(20000)
def solve(h,w,count,c):
    if 0 <= h < H and 0 <= w < W and A[h][w] == c:
        A[h][w] = count
        for dh,dw in zip([1,0,-1,0],[0,1,0,-1]):
            solve(h+dh,w+dw,count,c)
while 1:
    H,W = map(int,raw_input().split())
    if H == W == 0: break
    A = [list(raw_input()) for _ in range(H)]
    count = 0
    for h in range(H):
        for w in range(W):
            if type(A[h][w]) is not int:
                solve(h,w,count,A[h][w])
                count += 1
    print count
n, k = input().split()
lists = list(input().split())
for i in range(int(n)):
    lists[i] = int(lists[i])
lists.sort()
for i in range(int(k)):
  sum_fruit = sum_fruit + int(lists.pop(0))
print(str(sum_fruit))

### FIXED CODE ###

n, k = input().split()
lists = list(input().split())
for i in range(int(n)):
    lists[i] = int(lists[i])
lists.sort()
sum_fruit = 0
for i in range(int(k)):
  sum_fruit = sum_fruit + int(lists.pop(0))
print(str(sum_fruit))
n = raw_input()
  a = n.split(" ")
  b = int(a[0])
  c = int(a[1])
  print b*c, (b+c)*2

### FIXED CODE ###

n = raw_input()
a = n.split(" ")
b = int(a[0])
c = int(a[1])
print str(b*c)+" "+str((b+c)*2)
def solve():
    a, b, c, d = read()
    result = think(a, b, c, d)
    write(result)


def read():
    return read_int(4)


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def think(a, b, c, d):
    if b <= c or d <= a:
        return 0
    elif a <= c and d <= b:
        return d - c
    elif c <= a and b <= d:
        return b - a
    else:
        if a == c:
            return min(b, d) - a
        elif a < c:
            return abs(c - b)
        else:  # a > c
            return abs(d - a)


def write(result):
    print(result)


if __name__ == '__main__':
    solve()

### FIXED CODE ###

def solve():
    a, b, c, d = read()
    result = think(a, b, c, d)
    write(result)


def read():
    return read_int(4)


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(a, b, c, d):
    if b <= c or d <= a:
        return 0
    elif a <= c and d <= b:
        return d - c
    elif c <= a and b <= d:
        return b - a
    else:
        if a == c:
            return min(b, d) - a
        elif a < c:
            return abs(c - b)
        else:  # a > c
            return abs(d - a)


def write(result):
    print(result)


if __name__ == '__main__':
    solve()
S=input()
K=int(input())

def f(s):
  i=0
  c=0
  n=len(s)
  if n==1:
    return 0
  else:
    while i<n:
      if s[i]==s[i+1]:
        c+=1
        i+=2
      else:
        i+=1
    return c

a=0
while S[0]==S[a+1]:
  a+=1
  
b=-1
while S[0]==S[b]:
  b-=1
  
if b==-1:
  ans=f(S)*K
elif a==0 and b!=-1:
  ans=(K-1)*(-b-1)//2+K*f(S[1:b+1])
elif a!=0 and b!=-1:
  ans=(a+1)//2+f(S[a+1:b+1])*K+((a-b)//2)*(K-1)+(-b-1)//2
  
print(ans)

### FIXED CODE ###

S=input()
K=int(input())

def f(s):
  i=0
  c=0
  n=len(s)
  if n==1:
    return 0
  else:
    while i<n-1:
      if s[i]==s[i+1]:
        c+=1
        i+=2
      else:
        i+=1
    return c

a=0
n=len(S)
while a<n-1 and S[0]==S[a+1]:
  a+=1
  
b=-1
while a<n-1 and S[0]==S[b]:
  b-=1
  
if a==n-1:
  ans=n*K//2
elif b==-1:
  ans=f(S)*K
elif a==0 and b!=-1:
  ans=(K-1)*((-b-1)//2)+K*f(S[1:b+1])+(-b-1)//2
elif a!=0 and b!=-1:
  ans=(a+1)//2+f(S[a+1:b+1])*K+((a-b)//2)*(K-1)+(-b-1)//2
  
print(ans)
a,b = map(int,input().split('/'))
if b%a ==0:
    print(a+b)
else:
    print(b-a)
    

### FIXED CODE ###

a,b = map(int,input().split())
if b%a ==0:
    print(a+b)
else:
    print(b-a)
n = int(input())

a = []
b = []

for i in range(n):
    k = int(input())
    if k % 10 == 0:
        a.append(k)
    else:
        b.append(k)

su = sum(a)

b.sort()

su += sum(b) - b[0]
print(su)

### FIXED CODE ###

n = int(input())

a = []
b = []

for i in range(n):
    k = int(input())
    if k % 10 == 0:
        a.append(k)
    else:
        b.append(k)

if len(b) == 0:
    print(0)
else:
    b.sort()
    su = sum(a) + sum(b)
    if su % 10 == 0:
        su -= b[0]
    print(su)
"""
問題文

N個の整数 A1,A2,...,ANが黒板に書かれています。
あなたはこの中から整数を 1つ選んで、1 以上 109以下の好きな整数に書き換えます。
元の整数と同じ整数に書き換えても構いません。書き換えた後のN個の整数の最大公約数の最大値を求めてください。

制約
入力は全て整数である。
2≤N≤105
1≤Ai≤109
"""

"""
3 5 7
最大公約数: 1
最大の最大公約数: 1

8 4 6
最大公約数: 2
最大の最大公約数: 4
『aとbとcの最大公約数』　＝　『aとbの最大公約数』と『c』　の最大公約数

A1 , A2 , A3 ... An

gcd(A1 , A2 , A3 ... An-1) * N
= gcd * N * N
= gcd * N^2

gcd(A1 , A2 , A3 ... An-1)
gcd(A1 , A2 , A3 ... An-2 , An) = gcd(A1 , A2 , A3 ... An-2) , An
"""
import math
from fractions import gcd  # for Ver.3.4 or lower.
from functools import reduce
gcd_map = {}
def GCD(numbers):
    if len(numbers) == 0 : return 0
    if len(numbers) == 1 : return numbers[0]
    if len(numbers) == 2 : return gcd_sub(numbers[0] , numbers[1])
    else : 
        set_index = set(numbers[1:])
        if set_index in gcd_map : return gcd_map[set_index]
        value = GCD(numbers[1:])
        gcd_map[set_index] = value
        return value

def gcd_sub(a , b) : 
    if (a , b) in gcd_map : return gcd_map[(a,b)]
    else : 
        rst = gcd(a , b)
        gcd_map[(a,b)] = rst
        return rst

def main() : 
    N = int(input())
    a_list = input().split(" ")
    a_list = [int(i) for i in a_list]
    maxValue = 0
    for i in reversed(range(N)) : 
        if i == 0 : 
            prev_list = a_list[1:]
            after_list = []
        elif i == N - 1 : 
            prev_list = []
            after_list = a_list[:N-1]
        else : 
            prev_list = a_list[0 : i ]
            after_list = a_list[i + 1 :] 
        rst = gcd(GCD(prev_list) , GCD(after_list))
        if maxValue < rst : maxValue = rst
    print(maxValue)
main()


### FIXED CODE ###

"""
問題文

N個の整数 A1,A2,...,ANが黒板に書かれています。
あなたはこの中から整数を 1つ選んで、1 以上 109以下の好きな整数に書き換えます。
元の整数と同じ整数に書き換えても構いません。書き換えた後のN個の整数の最大公約数の最大値を求めてください。

制約
入力は全て整数である。
2≤N≤105
1≤Ai≤109
"""

"""
3 5 7
最大公約数: 1
最大の最大公約数: 1

8 4 6
最大公約数: 2
最大の最大公約数: 4
『aとbとcの最大公約数』　＝　『aとbの最大公約数』と『c』　の最大公約数

A1 , A2 , A3 ... An

gcd(A1 , A2 , A3 ... An-1) * N
= gcd * N * N
= gcd * N^2

gcd(A1 , A2 , A3 ... An-1)
gcd(A1 , A2 , A3 ... An-2 , An) = gcd(A1 , A2 , A3 ... An-2) , An
"""
def gcd(a, b):  # a>b
    a, b = max(a, b), min(a, b)
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

from functools import reduce
def GCD(numbers):
    if len(numbers) == 0 : return 0
    if len(numbers) == 1 : return numbers[0]
    if len(numbers) == 2 : 
        return gcd(numbers[0] , numbers[1])
    else : 
        value = GCD(numbers[:len(numbers)-1])
        result = gcd(value , numbers[len(numbers) - 1])
        return result

def main() : 
    N = int(input())
    a_list = input().split(" ")
    a_list = [int(i) for i in a_list]
    R = [0 for i in range(N - 1)]
    L = [0 for i in range(N - 1)]
    R[0] = a_list[0]
    L[0] = a_list[-1]

    for i in range(1 , N-1) : 
        R[i] = gcd(R[i - 1] , a_list[i])
    
    for j in range(1 , N-1) : 
        L[j] = gcd(L[j - 1] , a_list[- j - 1])
    
    maxValue = 0
    for i in range(N - 2) : 
        value = gcd(R[i] , L[N - i - 3])
        if value > maxValue : maxValue = value
    print(max(maxValue , R[-1] , L[-1]))
main()
def read_line(*types): return [f(a) for a, f in zip(input().split(), types)]

n, q = read_line(int, int)
s, = read_line(str)

p = []
i = 0
while i < len(s) - 1:
    if s[i:i+2] == 'AC':
        p.append(i)
        i += 2
    else:
        i += 1

for i in range(q):
    l, r = read_line(int, int)
    l, r = l - 1, r - 1

    c = 0
    for j in range(len(p)):
        pp = p[j]
        if l <= pp:
            break
        c += 1

    for jj in reversed(range(j, len(p))):
        pp = p[jj]
        if pp + 1 <= r:
            break
        c += 1

    print(len(p) - c)


### FIXED CODE ###

def read_line(*types): return [f(a) for a, f in zip(input().split(), types)]

n, q = read_line(int, int)
s, = read_line(str)

m = [0 for _ in range(len(s) + 1)]

c = 0
for i in range(len(s)):
    if s[i:i+2] == 'AC':
        c += 1
    m[i + 1] = c

for i in range(q):
    l, r = read_line(int, int)

    if c == 0:
        print(0)
        continue
    print(m[r - 1] - m[l - 1])
S=input()
S=s[:3]+"8"+s[:6]
print(S)

### FIXED CODE ###

s=input()
s=s[:3]+"8"+s[4:]
print(s)
D, G = map(int, input().split())
PC = [0]+[list(map(int,input().split())) for _ in range(D)]

def dfs(d, g):
    if(d == 0):
        return 1e9

    c = min(g//(100*d), PC[d][0])
    s = 100*d*c
    if c == PC[d][0]:
        s += PC[d][1]
    if s<g:
        c += f(d-1, g-s)
    return min(c, f(d-1,g))

print(dfs(D, G))

### FIXED CODE ###

D, G = map(int, input().split())
PC = [0]+[list(map(int,input().split())) for _ in range(D)]

def dfs(d, g):
    if(d == 0):
        return 1e9

    c = min(g//(100*d), PC[d][0])
    s = 100*d*c
    if c == PC[d][0]:
        s += PC[d][1]
    if s<g:
        c += dfs(d-1, g-s)
    return min(c, dfs(d-1,g))

print(dfs(D, G))
from collections import OrderedDict

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

for _ in range(N):
    s=input()
    S.append(s)

c=OrderedDict(sorted(S))

max_s_list= [kv[0] for kv in c.items() if kv[1]==max(c.values())]

for a in max_s_list:
    print(a)

### FIXED CODE ###

from collections import Counter

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

for _ in range(N):
    s=input()
    S.append(s)

c=Counter(S)
arr=c.most_common()

maxnum=arr[0][1]
ans=[]

for i in range(len(arr)):
    if arr[i][1]==maxnum:
        ans.append(arr[i][0])        
    else:
        break
FA=sorted(ans)
for j in FA:
    print(j)
# encoding:utf-8
import copy
import numpy as np
import random
import bisect #bisect_left　これで二部探索の大小検索が行える

N,Q = map(int, input().split())
s = str(input())
T = []
D = []
for i in range(Q):
    t,d = map(str,input().split())
    T.append(t)
    D.append(d)

T.reverse()
D.reverse()

nl = 0
nr = N-1
L = []#回収できた分
R = []
for i in range(Q):
    if D[i]=="R":
        if s[nr] == T[i]:
            L.append(s[nr])
            nr -= 1
        elif len(R)>0:
            if R[-1] == T[i]:
                R.pop()
                nl += 1

    else:
        if s[nl] == T[i]:
            R.append(s[nl])
            nl += 1
        elif len(L)>0:
            if L[-1] == T[i]:
                L.pop()
                nr -= 1

print(N-len(R)-len(L))



#
# print(N-len(L)-len(R))


### FIXED CODE ###

# encoding:utf-8
import copy
import numpy as np
import random
import bisect #bisect_left　これで二部探索の大小検索が行える

N,Q = map(int, input().split())
s = input()
td = [input().split() for i in range(Q)]

td.reverse()

nl = 0
nr = N-1
L = []
R = []
for i in td:#全ての指示
    # print(L,R)
    if i[1]=="L":
        if nl < N:
            if s[nl] == i[0]:
                L.append(i[0])
                nl += 1
            if len(R) != 0:
                if R[-1]==i[0]:
                    R.pop()
                    nr += 1
    else:
        if nr >= 0:
          if s[nr] == i[0]:
            R.append(i[0])
            nr -= 1
        if len(L) != 0:
          if L[-1] == i[0]:
            L.pop()
            nl -= 1

print(N-len(L)-len(R))
a = input()
b = input()
max([a+b, a-b, a*b])

### FIXED CODE ###

a, b = map(int, input().split())
print(max(a+b, a-b, a*b))
r=int(input())
print(3*a*a)


### FIXED CODE ###

r=int(input())
print(3*r*r)
# D
N = map(int, input().split())
L = list(map(int, input().split()))

value = 0
for i in itertools.combinations(L, 3):
    a, b, c = i
    
    if a<b+c:
        if b<c+a:
            if c<a+b:
                value+=1
print(value)

### FIXED CODE ###

n = int(input())
l = list(map(int, input().split()))
l.sort()
 
from bisect import bisect_left
ans = 0
for i in range(n):
  for j in range(i+1, n):
    t = l[i]+l[j]
    idx = bisect_left(l, t)
    ans += max(0, idx-j-1)
print(ans)
import sys, math
N, K = map(int, input().split())
A = sorted(list(map(int, input().split())), key=lambda x: abs(x))[::-1]
P = int(1e9+7)

ans = 1
hu = None
sei = None
flg = False
for a in A:
    flg = a > 0
    if flg:
        break
if not flg:
    for i in range(1, K+1):
        ans = (ans * A[-i]) % P
    print(ans)
    sys.exit()
if K == N:
    for a in A:
        ans = (ans * a) % P
    print(ans)
    sys.exit()

for i, a in zip(range(K), A):
    if a > 0:
        if not sei:
            ans = (ans * sei) % P
        sei = a
    else:
        if not hu:
            hu = a
        else:
            ans = (ans * a * hu) % P
            hu = None

ptn1, ptn2 = -math.inf, -math.inf
if hu:
    if sei:
        for i in range(K, N):
            if A[i] > 0:
                ptn1 = sei * A[i]
                break
        for i in range(K, N):
            if A[i] <= 0:
                ptn2 = hu * A[i]
                break
        ans = (ans * max(ptn1, ptn2)) % P
    else:
        for i in range(K, N):
            if A[i] > 0:
                ans = (ans*A[i])%P
                break
else:
    ans = (ans * sei) % P
print(ans % P)


### FIXED CODE ###

import sys, math
N, K = map(int, input().split())
A = sorted(list(map(int, input().split())), key=lambda x: abs(x))[::-1]
P = int(1e9+7)
ans = 1
hu = None
sei = None
flg = False
for a in A:
    flg = a > 0
    if flg:
        break
if not flg:
    if K%2==1:
        for i in range(1, K+1):
            ans = (ans * A[-i]) % P
    else:
        for i in range(K):
            ans = (ans * A[i]) % P
    print(ans)
    sys.exit()
if K == N:
    for a in A:
        ans = (ans * a) % P
    print(ans)
    sys.exit()

for i, a in zip(range(K), A):
    if a > 0:
        if sei:
            ans = (ans * sei) % P
        sei = a
    else:
        if hu is None:
            hu = a
        else:
            ans = (ans * a * hu) % P
            hu = None

ptn1, ptn2 = -math.inf, -math.inf
if hu:
    if sei:
        for i in range(K, N):
            if A[i] > 0:
                ptn1 = sei * A[i]
                break
        for i in range(K, N):
            if A[i] <= 0:
                ptn2 = hu * A[i]
                break
        ans = (ans * max(ptn1, ptn2)) % P
    else:
        for i in range(K, N):
            if A[i] > 0:
                ans = (ans * A[i]) % P
                break
else:
    if sei:
        ans = (ans * sei) % P
print(ans % P)
a1=input()
a2=input()
a3=input()
a=[a1,a2,a3]
a.sort()
flag=0
for i in range(2):
    if a[i]!='5':
        flag=flag+1
if a[2]!='7':
    flag=flag+1
 
if flag==0:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

arr = list(map(int,input().split()))

b = [0]*10

for i in arr:
    b[i-1] += 1

if (b[4]==2 and b[6]==1):
    print("YES")
else:
    print("NO")
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

class InverseTable:
    __slots__ = ['In', 'fac', 'Ifac']

    def __init__(self, mod, maxnum):
        self.In = [0, 1]; self.fac = [1, 1]; self.Ifac = [1, 1]
        for i in range( 2, maxnum + 1 ):
            self.In.append( ( -self.In[mod % i] * (mod//i) ) % mod )
            self.fac.append( ( self.fac[-1] * i ) % mod )
            self.Ifac.append( (self.Ifac[-1] * self.In[-1]) % mod )
        
    def cmb(self, n, r):
        if ( r<0 or r>n ): return 0
        r = min(r, n-r)
        return self.fac[n] * self.Ifac[r] * self.Ifac[n-r] % mod
    
    def per(self, n, r):
        if ( r<0 or r>n ): return 0
        return self.fac[n] * self.Ifac[n-r] % mod

invt = InverseTable(mod, 10**6)
# maxnum=10**6だとテーブル生成に200ms程かかるので（Pythonだと1000msほど）
# 最大生成領域は問題ごとに要検討

n,m,k=map(int,input().split())
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

class InverseTable:
    __slots__ = ['In', 'fac', 'Ifac']

    def __init__(self, mod, maxnum):
        self.In = [0, 1]; self.fac = [1, 1]; self.Ifac = [1, 1]
        for i in range( 2, maxnum + 1 ):
            self.In.append( ( -self.In[mod % i] * (mod//i) ) % mod )
            self.fac.append( ( self.fac[-1] * i ) % mod )
            self.Ifac.append( (self.Ifac[-1] * self.In[-1]) % mod )
        
    def cmb(self, n, r):
        if ( r<0 or r>n ): return 0
        r = min(r, n-r)
        return self.fac[n] * self.Ifac[r] * self.Ifac[n-r] % mod
    
    def per(self, n, r):
        if ( r<0 or r>n ): return 0
        return self.fac[n] * self.Ifac[n-r] % mod

invt = InverseTable(mod, 10**6)
# maxnum=10**6だとテーブル生成に200ms程かかるので（Pythonだと1000msほど）
# 最大生成領域は問題ごとに要検討

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


### FIXED CODE ###

#!/usr/bin/env python3
import sys, math, itertools, collections, bisect, heapq
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,q=map(int,input().split())
STX=[tuple(map(int,input().split())) for i in range(n)]
D=[int(input()) for i in range(q)]
event=[]
for si,ti,xi in STX:
  event.append((si-xi,0,xi))
  event.append((ti-xi,-1,xi))
for di in D:
  event.append((di,1,di))
event.sort()
hq=[]; S=set()
for time, query, number in event:
  if query == 0:
    heapq.heappush(hq,number)
    S.add(number)
  elif query == -1:
    S.remove(number)
  else:
    while hq and hq[0] not in S:
      heapq.heappop(hq)
    if not hq:
      print(-1)
    else:
      print(hq[0])
S=input()
S[3]="8"
print(S)

### FIXED CODE ###

S=input()
print(S.replace("2017","2018"))
x, y = map(int, input().split())

def f(x):
    return 10**10 if x < 0 else x

print(min(f(y-x), f(y+x)+1, f(-y-x)+1, f(-y+x2)))

### FIXED CODE ###

x, y = map(int, input().split())

f = lambda x: 10**10 if x < 0 else x

print(min(f(y-x), f(y+x)+1, f(-y-x)+1, f(-y+x)+2))
b = 100
x = int(input())
while(b<x) :
  b += b//100
  ans += 1
print(ans)

### FIXED CODE ###

x = int(input())
p = 100
ans = 0
while(p<x) :
	p += p//100
	ans += 1
print(ans)
k,s=map(int,input().split())
res=0
for x in range(k+1):
  for y in range(k+1):
    if s-x-y=>0:
      res+=1
print(res)

### FIXED CODE ###

k,s=map(int,input().split())
res=0
for x in range(k+1):
  for y in range(k+1):
    if s-x-y<=k and s-x-y>=0:
      res+=1
      #print(x,y,s-x-y)
print(res)
# -*- coding: utf-8 -*-
import math
from scipy.special import comb
from operator import mul
from functools import reduce

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

X,Y = (int(x) for x in input().split())
count = 0
if (X+Y)%3!=0 or 2*X<Y or 2*Y<X:
    print("0")
    exit()
else:
    N=(X+Y)/3 # 合計移動回数
    mov_x=(2*X-Y)/3 #(2,1)の移動回数 ]

    if (left<right):
        left=mov_y+1
        right=mov_x
    #print(combinations_count(N, mov_x)%(pow(10,9)+7))
    #print(comb(N, mov_x, exact=True)%(pow(10,9)+7))
    print(cmb(int(N), int(mov_x))%(pow(10,9)+7))


### FIXED CODE ###

# -*- coding: utf-8 -*-

mod = int(1e9+7)

def comb_mod(n, r, mod):
    if n < r:
        return 0
    elif n < 0 or r < 0:
        return 0
    else:
        fac = [1, 1]
        finv = [1, 1]
        inv = [0, 1]
        for i in range(2, n + 1):
            fac.append(fac[-1] * i % mod)
            inv.append(-inv[mod % i] * (mod // i) % mod)
            finv.append((finv[-1] * inv[-1]) % mod)
        return int(fac[n] * finv[r] * finv[n - r] % mod)

X,Y = (int(x) for x in input().split())
count = 0
if (X+Y)%3!=0 or 2*X<Y or 2*Y<X:
    print("0")
    exit()
else:
    N=(X+Y)/3 # 合計移動回数
    mov_x=(2*X-Y)/3 #(+2,+1)の移動回数
    print(comb_mod(int(N), int(mov_x), mod))
#入力:N,M(int:整数)
def input2():
	return map(int,input().split())
  
H,W,K=input2()
c=[list(input()) for _ in range(H)]

ans=0
print(c)

for row_line in product(range(2),repeat=H): #[行]0:そのまま，1:赤く塗る
	for col_line in product(range(2), repeat=W): #[列]0:そのまま，1:赤く塗る
		# 黒("#")の数え上げ
		cnt=0
		for row in range(H):
			for col in range(W):
				if c[row][col]=="#" and row_line[row]==0 and col_line[col]==0:
					cnt+=1

		if cnt==K:
			ans+=1
print(ans)

### FIXED CODE ###

from itertools import product

def input2():
	return map(int,input().split())
  
h,w,k=input2()
C=[list(input()) for _ in range(h)]





ans=0

for row_bit in product(range(2),repeat=h): #[行]0:赤なし，1:赤あり
	for col_bit in product(range(2),repeat=w): #[列]0:赤なし，1:赤あり
		count=0
		# 以下，黒("#")の個数判定
		for row in range(h):
			for col in range(w):
				if C[row][col]=="#" and (row_bit[row]==0 and col_bit[col]==0):
					count+=1
		if count==k:
			ans+=1
print(ans)
seconds = int(raw_input())
hour = seconds / 3600
minute = (seconds - (hour * 3600)) / 60
second = seconds - (hour * 3600) - (minute * 60)
print(str(hour) + ':' str(minute) + ':' str(second))

### FIXED CODE ###

seconds = int(raw_input())
hour = seconds / 3600
minute = seconds % 3600 / 60
second = seconds - (hour * 3600) - (minute * 60)
print('%d:%d:%d'%(hour, minute, second))
N = int(input())
A=(1,2,3,4,5,6,7,8,9)
B=(1,2,3,4,5,6,7,8,9)
count=0
for a in A:
  for b in B:
    if N/(a*b) == 1 and N%(a*b)==0:
      count=count+1
if count>=1:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

A, B = map(int, input().split())
if A >= 10 or B >=10:
  print(-1)
else:
  print(A*B)
O = input()
E = input()
dif_len = len(O) - len(E)
password = ''

if dif_len == 0:
    for i in range(max_len):
        password += O[i] + E[i]
elif dif_len > 0:
    for i in range(len(O)):
        if i != len(O) - 1:
            password += O[i] + E[i]
        else:
            password += O[i]

print(password)

### FIXED CODE ###

O = input()
E = input()
dif_len = len(O) - len(E)
password = ''

if dif_len == 0:
    for i in range(len(O)):
        password += O[i] + E[i]
elif dif_len > 0:
    for i in range(len(O)):
        if i != len(O) - 1:
            password += O[i] + E[i]
        else:
            password += O[i]

print(password)
# coding=utf-8
from math import pi
r = float(raw_input().split())
print "{0:f} {1:f}".format(pi * r * r, 2 * pi * r)

### FIXED CODE ###

# coding=utf-8
from math import pi
r = float(raw_input().strip())
print "{0:f} {1:f}".format(pi * r * r, 2 * pi * r)
import math
N = int(input())
s = 0
if N % 2 == 0:
  s = 2 + N // 2

for i in range(3, int(math.sqrt(N), 2):
  if N % i == 0 and s > i + N // i:
    s = i + N // i

print(s-2)

### FIXED CODE ###

import math
def main():
  N = int(input())
  s = 0
  if N % 2 == 0:
    s = 2 + N // 2

  for i in range(3, math.ceil(math.sqrt(N)) + 3):
    if N % i == 0 and (not s or s > i + N // i):
      s = i + N // i

  if not s:
    s = N + 1

  print(s-2)
  
main()