Harryxun/stf_run huggingface dataset:
x, k, d = map(int, input().split())
  
if abs(x) > k * d:
  r = x - int(abs(x)/x) * k * d
else:
  n = int(abs(x) / d)
  r1 = x - int(abs(x)/x) * n * d
  if r1 == 0:
    r = 0
  else:
    r2 = r1 - int(abs(r1)/r1) * d
    r = min(abs(r1), abs(r2))

print(r)

### FIXED CODE ###

x, k, d = map(int, input().split())
  
x = abs(x)

if x > k * d:
  print(x - k * d)
else:
  f = int(x / d)
  x = x - f * d
  g = (k - f) % 2
  if g == 1:
    x = x - d
  print(abs(x))
n=int(input())
l=[]
for i in range(n):
    l.append(list(map(str,input().split())))
x=input()
ans=0
f=0
for i in l:
    if f==1:
        ans+=int(l[1])
    if i[0]==x:
        f=1
print(ans)

### FIXED CODE ###

n=int(input())
l=[]
for i in range(n):
    l.append(list(map(str,input().split())))
x=input()
ans=0
f=0
for i in l:
    if f==1:
        ans+=int(i[1])
    if i[0]==x:
        f=1
print(ans)
from collections import deque

def num_way(stair):
  memo = ["EMPTY"]*(stair+1)
  def _fib(stair):
    if stair == 1 or stair == 0:
      return 1
    elif stair == 2:
      return 2
    elif memo[stair] != "EMPTY":
      return memo[stair]
    else:
      memo[stair] = _fib(stair-1)+_fib(stair-2)
      return memo[stair]
  return _fib(stair)

N, M = map(int,input().split())
a = deque([0])
path_poss = 1
ans = 1
for m in range(M):
  start = a.popleft()
  buff = int(input())
  end = buff-1
  if (end-start) <= -1:
    path_poss = 0
    break
  a.append(buff+1)
  ans *= num_way(end-start)
  ans %= 1000000007

if path_poss == 0:
  print(0)
else:
  start = a.popleft()
  end = N
  if(end-start) <= -1:
    path_poss = 0
  if path_poss == 0:
    print(0)
  else:
    print(end,start)
    ans *= num_way(end-start)
    print(ans%1000000007)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
from collections import deque

def num_way(stair):
  memo = ["EMPTY"]*(stair+1)
  def _fib(stair):
    if stair == 1 or stair == 0:
      return 1
    elif stair == 2:
      return 2
    elif memo[stair] != "EMPTY":
      return memo[stair]
    else:
      memo[stair] = _fib(stair-1)+_fib(stair-2)
      return memo[stair]
  return _fib(stair)

N, M = map(int,input().split())
a = deque([0])
path_poss = 1
ans = 1
for m in range(M):
  start = a.popleft()
  buff = int(input())
  end = buff-1
  if (end-start) <= -1:
    path_poss = 0
    break
  a.append(buff+1)
  ans *= num_way(end-start)
  ans %= 1000000007

if path_poss == 0:
  print(0)
else:
  start = a.popleft()
  end = N
  if(end-start) <= -1:
    path_poss = 0
  if path_poss == 0:
    print(0)
  else:
    ans *= num_way(end-start)
    print(ans%1000000007)
n = int(input())
c = input()
cl = list(c)
wi = 0
wnum=0
ri = n-1
rnum=0
for i in range(n):
    br=0
    bw=0
    while(cl[wi] == "R" and br==0):
        wi+=1
        if(wi >= n-1):
            br=1
            break
    if(cl[wi] == "W"):
        wnum+=1
    wi+=1
    if(wi >= n-1):
        wi=0
        br=1
    while(cl[ri] == "W" and bw==0):
        ri-=1
        if(ri <= 0):
            bw=1
            break
    if(cl[ri] == "R"):
        rnum+=1
    ri-=1
    if(ri <= 0):
        ri=n-1
        bw=1
    #print(wi, ri)
    if(ri < wi):
        res1 = i+1
    if(br*bw==1):
        break
print(min(res1, rnum, wnum))

### FIXED CODE ###

n = int(input())
c = input()
cl = list(c)
wi = 0
wnum=0
ri = n-1
rnum=0
br=0
bw=0
res1 = n
break1 = 0
for i in range(n):
    while(cl[wi] == "R" and bw==0):
        wi+=1
        if(wi >= n-1):
            bw=1
            break
    if(cl[wi] == "W"):
        wnum+=1
    while(cl[ri] == "W" and br==0):
        ri-=1
        if(ri <= 0):
            br=1
            break
    if(cl[ri] == "R"):
        rnum+=1
    if(ri < wi and break1 == 0):
        res1 = i
        break1 = 1
    wi+=1
    if(wi >= n-1):
        wi=0
        bw=1
    ri-=1
    if(ri <= 0):
        ri=n-1
        br=1

    if(br*bw==1):
        break
print(min(res1, rnum, wnum))
import numpy as np
import math
 
N, K = map(int, input().split())
 
 
prob = []
if N >= K:
    p_e = (1 / N) * (N - K + 1)
    for i in range(1, K):
        p_i = (1 / N) * ((1 / 2) ** (math.ceil((np.log2(K / i))))
        prob.append(p_i)
else:
    p_e = 0
    for i in range(1, N+1):
        p_i = (1 / N) * ((1 / 2) ** (math.ceil((np.log2(K / i))))
        prob.append(p_i)
 
summer = sum(prob) + p_e
 
print("{:.12f}".format(summer))

### FIXED CODE ###

import numpy as np
import math

N, K = map(int, input().split())


prob = []
if N >= K:
    p_e = (1 / N) * (N - K + 1)
    for i in range(1, K):
        p_i = (1 / N) * ((1 / 2) ** (math.ceil(np.log2(K / i))))
        prob.append(p_i)

else:
    p_e = 0
    for i in range(1, N+1):
        p_i = (1 / N) * ((1 / 2) ** (math.ceil(np.log2(K / i))))
        prob.append(p_i)


s = sum(prob) + p_e
print("{:.12f}".format(s))
X = input()
n500 = X // 500
n5 = (X - 500 * n500) // 5
happy = 1000 * n500 + 5 * n5
print(happy)

### FIXED CODE ###

X = int(input())
nfh = X // 500
nf = (X - 500 * nfh) // 5
happy = 1000 * nfh + 5 * nf
print(happy)
a,b,k=map(int,input().split())
d=set()
for i in range(k):
  d.add(a+i)
for i in range(k):
  d.add(b-i)
d.sort()
for i in d:
  print(i)


### FIXED CODE ###

a,b,k=map(int,input().split())
d=set()
f=min(b-a+1,k)
for i in range(f):
  d.add(a+i)
for i in range(f):
  d.add(b-i)
d=sorted(list(d))
for i in d:
  print(i)
N,K = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
p
for i in b:
    p.append((i+1)/2)
s = sum(p[:K])
max_s = s
for i in range(N-K):
    max_s+=p[K+i]
    max_s-=p[i]
    if max_s<s:
        max_s=s
print(max_s)


### FIXED CODE ###

N, K = map(int, input().split())
p = list(map(int,input().split()))
box = []
for i in p:
    box.append((i+1)/2)

sum_a = sum(box[:K])
max_a = sum_a
for i in range(N-K):
    max_a -= box[i]
    max_a += box[i+K]
    if max_a > sum_a:
        sum_a = max_a

print(sum_a)
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

a.append(10**9+1)
b.append(10**9+1)

i,j,ans=0,0,0
while k>=0:
    if a[i]>10**9:
        k-=b[j]
        j+=1
    elif b[i]>10**9:
        k-=a[i]
        i+=1
    elif a[i]>b[j]:
        k-=b[j]
        j+=1
    else:
        k-=a[i]
        i+=1
    if k<0:
        break
    ans+=1

print(ans)
    

### FIXED CODE ###

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

a,b=[0],[0]
for i in range(n):
    a.append(a[i]+A[i])
for i in range(m):
    b.append(b[i]+B[i])

j,ans=m,0
for i in range(n+1):
    if a[i]>k:
        break
    while b[j] > k-a[i]:
        j-=1
    ans=max(ans,i+j)
print(ans)
def make_divisors(n):
    if n>1:
        divisors = []
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                divisors.append(i)
                if i != n // i:
                    divisors.append(n//i)
        divisors.sort()
        return n*len(divisors)+make_divisors(n-1)
    elif n=1:
        return 1
n=int(input())
make_divisors(n)

### FIXED CODE ###

import math
n=int(input())
s=0
for i in range(1,n+1):
    s+=i*((math.floor(n/i)*math.floor(n/i+1))/2)
print (int(s))
H, W, D = map(int, input().split())
M = [(-1, -1)]*(H*W+1)
A = []
for i in range(H):
  As = list(map(int, input().split()))
  for j in range(W):
    a = As[j]
    M[a] = (i, j)
  A.append(As)
#print(M)
Dist = [0]*(H*W+1)
for k in range(0, H*W-D+1):
  i, j = M[k]
  x, y = M[k+D]
  Dist[k+D] = Dist[k]+abs(x-i)+abs(y-j)
Q = int(input())
for i in range(Q):
  L, R = map(int, input().split())
  r = Dist[R]-Dist[L]
  print(r)

### FIXED CODE ###

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

if a*b%2 == 0 :
  print(even)
  
else :
  print(odd)

### FIXED CODE ###

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

if a*b%2 == 0 :
  print("Even")
  
else :
  print("Odd")
import math

A,B,H,M = map(int,input().split())
MM = 6*M #分針の角度
HH = H*30 + M//2
rad = MM-HH
if(rad>=-90 and rad<=90):
    cosine = math.cos(math.radians(rad))
else:
    cosine = 0-math.cos(math.radians(rad))
    
r = math.sqrt(A**2+B**2-2*A*B*cosine)
print(r)

### FIXED CODE ###

N = str(input())

if(N[-1]=="3"):
    print("bon")
    
if(N[-1]=="0" or N[-1]=="1" or N[-1]=="6" or N[-1]=="8"):
    print("pon")
    
if(N[-1]=="2" or N[-1]=="4" or N[-1]=="5" or N[-1]=="7" or N[-1]=="9"):
    print("hon")
N = int(input())
T, A = map(int, (input().split()))
H = list(map(int, (input().split())))
tem_diff = [abs(A - (T - i * 0.006)) for i in H]
print(tem_diff.index(min(tem_diff)) + 1)

n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
tem = [abs(a - (t - i * 0.006)) for i in h]
print(tem.index(min(tem)) + 1)

### FIXED CODE ###

n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
tem = [abs(a - (t - i * 0.006)) for i in h]
print(tem.index(min(tem)) + 1)
K, S = map(int, input().split())

cnt = 0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if i + j + k == S:
                cnt += 1

print(cnt)

### FIXED CODE ###

sx, sy, tx, ty = map(int, input().split())

dx, dy = tx-sx, ty-sy
ans = ''
ans += 'U'*dy
ans += 'R'*dx
ans += 'D'*dy
ans += 'L'*dx
ans += 'L'
ans += 'U'*(dy+1)
ans += 'R'*(dx+1)
ans += 'DR'
ans += 'D'*(dy+1)
ans += 'L'*(dx+1)
ans += 'U'

print(ans)
import sys

alpha = 'abcdefghijklmnopqrstuvwxyz'

n = int(input())

i = 0
idx = n
if n > 26:
    while n > 0:
        idx = n
        i += 1
        n = n - 26**i
        # print(i, n)

else:
    print(alpha[n-1])
    sys.exit()

# letter len : i, idx 

def getstr(i, idx):

    if i == 0:
        return ""
    elif i == 1:
        return alpha[idx-1]
    else:
        # number in the range
        t = 26**i

        # number  of bin
        b = int(26 * idx / t)
        idx -= b * int(t/26) 
        i -= 1

        return alpha[b] + getstr(i, idx)

print(getstr(i,idx))


### FIXED CODE ###

import sys

alpha = 'abcdefghijklmnopqrstuvwxyz'

n = int(input())

i = 0
idx = n
if n > 26:
    while n > 0:
        idx = n
        i += 1
        n = n - 26**i
        # print(i, n)

else:
    print(alpha[n-1])
    sys.exit()

# letter len : i, idx 

def getstr(i, idx):

    if i == 0:
        return ""
    elif i == 1:
        return alpha[idx-1]
    else:
        # number in the range
        t = 26**i

        # number  of bin
        b = int(26 * idx / t)

        bb = 0
        tmp = idx
        while tmp > 0:
            tmp -= int(t/26)
            bb += 1

        b = bb - 1
        idx -= b * int(t/26) 
        i -= 1
        
        return alpha[b] + getstr(i, idx)

print(getstr(i,idx))
edges, vertices = map(int, input().split())
dp = [None for _ in range(edges+1)]

nodes = [[] for _ in range(edges+1)]

for i in range(vertices):
    start, end = map(int, input().split())
    nodes[end -1].append(start-1)
for i in range(edges):
    if not len(nodes[i]):
        dp[i] = 0

def find(arr):
    if not len(arr):
        return 0
    for x in arr:
        if dp[x] is None:
            dp[x] = find(nodes[x])
    return 1 + max(dp[x] for x in arr)



print(nodes) 
for i in range(edges):
    dp[i] = find(nodes[i])

print(max(dp))


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
edges, vertices = map(int, input().split())
dp = [None for _ in range(edges)]

nodes = [[] for _ in range(edges)]

for i in range(vertices):
    start, end = map(int, input().split())
    nodes[end -1].append(start-1)

def find(arr):
    if not len(arr):
        return 0
    for x in arr:
        if dp[x] is None:
            dp[x] = find(nodes[x])
    return 1 + max(dp[x] for x in arr)

for i in range(edges):
    dp[i] = find(nodes[i])

print(max(dp))
import bisect
n,k=map(int,input().split())
s=input()
f=[0 for i in range(n)]
f[0]=1-int(s[0])
for i in range(1,n):f[i]=(1-int(s[i]))*(s[i-1]^s[i])
for i in range(n-1):f[i+1]+=f[i]
ans=0
for l in range(n):
    r=bisect.bisect_right(f,k+f[l]*int(s[l]))
    ans=max(ans,r-l)
print(ans)

### FIXED CODE ###

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

#A
def A():
    a,b = LI()
    if a == b:
        print(2*a)
    else:
        print(2*max(a,b)-1)
    return

#B
def B():
    n = I()
    h = LI()
    m = h[0]
    ans = 1
    for i in range(1,n):
        if m <= h[i]:
            ans += 1
            m = h[i]
    print(ans)
    return

#C
def C():
    s = S()
    ans = 0
    n = len(s)
    t = ["1" if i%2 else "0" for i in range(n)]
    for i in range(n):
        if t[i] != s[i]:
            ans += 1
    ans2 = 0
    t = ["0" if i%2 else "1" for i in range(n)]
    for i in range(n):
        if t[i] != s[i]:
            ans2 += 1
    print(min(ans,ans2))
    return

#D
def D():
    n,k = LI()
    s = S()
    f = [0 for i in range(n)]
    if s[0] == "0":
        f[0] = 1
    for i in range(1,n):
        if s[i] ==  "0" and s[i-1] == "1":
            f[i] = 1
    for i in range(n-1):
        f[i+1] += f[i]
    ans = 0
    for l in range(n):
        r = bisect.bisect_right(f,k+f[l]*int(s[l]))
        ans = max(ans, r-l)
    print(ans)
    return

#Solve
if __name__ == "__main__":
    D()
N = int(input())
L = list()
for _ in range(N):
    A, B = map(int, input().split())
    L.append((A, B))
L = sorted(L, key=lambda x: x[0])

if N%2 == 1:
    W = L[N//2]
    for l in range(N//2, -1, -1):
        if W[0] <= l[1]:
            W = (l[0], W[1])
        else:
            break
    for l in range(N//2, N):
        if l[0] <= W[1]:
            W = (W[0], l[1])
    print(W[1] - W[0] + 1)
else:
    W = L[N//2 - 1]
    V = L[N//2]
    ans = max(W[1] - W[0] + 1, V[1] - V[0] + 1)
    if W[1] >= V[0]:
        print(2*ans - 1)
    else:
        print(ans + 2)


### FIXED CODE ###

N = int(input())
A = list()
B = list()
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
A.sort()
B.sort(reverse=True)
if N%2 == 1:
    print(B[(N+1)//2 - 1] - A[(N+1)//2 - 1] + 1)
else:
    print((B[(N+1)//2 - 1] - A[(N+1)//2 - 1]) + (B[(N+1)//2] - A[(N+1)//2]) + 1)
from collections import Counter

N = int(input())
A = [int(input()) for _ in range(N)]
c = Counter(A)
print(len([i for i in c if c.values(i) % 2 == 1]))


### FIXED CODE ###

from collections import Counter

N = int(input())
A = [int(input()) for _ in range(N)]
c = Counter(A).values()

print(len([i for i in c if i % 2 == 1]))
s = input()
sa = 'keyence'
sl = 0
for i in range(len(s)):
    if s[i] == sa[sl]:
        sl += 1
if sl == len(sa) and s[0] == sa[0] and s[-1] == sa[-1]:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

s = input()
for i in range(len(s)):
    if(i > 7):
        continue
    if(s[:i] + s[-(7-i):] == "keyence"):
        print("YES")
        exit()
print("NO")
t=input()
result=''
for i in range(len(t)):
    if t[i]=='?':
        try:
            if result[i-1]=='P':
                result+='D'
            else:
                result+='P'
        except:
            if  t[i+1]=='P':
                result+='D'
            else:
                result+='P'
    else:
        result+=t[i]
print(result)

### FIXED CODE ###

t=input()
result=''
for i in range(len(t)-1):
    if t[i]=='?':
        try:
            if result[i-1]=='P':
                result+='D'
            else:
                if t[i+1]=='P':
                    result+='D'
                else:
                    result+='P'
        except:
            if t[i+1]=='P':
                result+='D'
            else:
                result+='P'
    else:
        result+=t[i]
if t[len(t)-1]=='?' or  t[len(t)-1]=='D':
    print(result+'D')
else:
    print(result+'P')
import sys

for line in sys.stdin:
    count = 0
    n = int(line)
    
    nums = range(2, n+1)
    
    while True:
        if len(nums) == 1:
            count += 1
            break
        else:
            count += 1
            nums = [ for x in nums[1:] if x % nums[0] != 0 ]
    print count

### FIXED CODE ###

import math
import sys

n = 999999
nums = [1] * (n+1)
nums[:2] = [0,0]
    
cnt = 0
while cnt <= math.sqrt(n):
    flg = nums[cnt]
    if flg == 1:
        k = 2
        while k*cnt <= n:
            nums[k*cnt] = 0
            k += 1
    cnt += 1


for line in sys.stdin:
    n = int(line)
    print sum(nums[:n+1])
NM = list(map(int, input().split())
N, M = NM[0],NM[1]
a = list(map(int, input().split()))
x = 0
for i in range(M):
    x += a[i]

if x > N:
    print(-1)
else:
    print(N - x)

### FIXED CODE ###

N, M = input().split()
N, M = [int(N), int(M)]
a = list(map(int, input().split()))

for i in range(M):
    N -= a[i]

if N < 0:
    print(-1)
else:
    print(N)
n,m = map(int,input().split())
h = list(map(int,input().split()))
#h.sort()
l = [[] for _ in range(n)]

for i in range(m):
  a,b = map(int,input().split())
  l[a-1].append(b-1)
  l[b-1].append(a-1)

print(l)
  av
c = 0
for j in range(n):
  if len(l[j]) == 0:
    c += 1
  else:
    m = 0
    for k in l[j]:
      if h[j] <= h[k]:
        m = 1
        break
    if m == 0:

      c += 1
      
print(c)
  

### FIXED CODE ###

n,m = map(int,input().split())
h = list(map(int,input().split()))
#h.sort()
l = [[] for _ in range(n)]

for i in range(m):
  a,b = map(int,input().split())
  l[a-1].append(b-1)
  l[b-1].append(a-1)

c = 0
for j in range(n):
  if len(l[j]) == 0:
    c += 1
  else:
    m = 0
    for k in l[j]:
      if h[j] <= h[k]:
        m = 1
        break
    if m == 0:

      c += 1
      
print(c)
N, M, K = map(int, input().split())
friends_table = [[] for i in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    friends_table[a-1] += [b-1]
    friends_table[b-1] += [a-1]

blocks_table = [[] for i in range(N)]
for _ in range(K):
    a, b = map(int, input().split())
    blocks_table[a-1] += [b-1]
    blocks_table[b-1] += [a-1]

group_list = [i for i in range(N)]
friends_candidate = [[] for i in range(N)]

for i in range(N):
    friend = [i]
    # すでにDFS済み
    if i != group_list[i]:
        continue
    next_stack = friends_table[i][:]]
    while next_stack:
        next = next_stack.pop()
        # 訪問済み
        if i == group_list[next]:
            continue
        friend += [next]
        group_list[next] = i
        next_stack += friends_table[next]
    for f in friend:
        friends_candidate[f] = friend

for i in range(N):
    print(len(set(friends_candidate[i]).difference(set(friends_table[i] + blocks_table[i])))-1)

### FIXED CODE ###

print(((int(input()))+1)//2)
A, B = map(int, input().split())

def gcd( x, y ):
    count = 0
    while y != 0:
        x, y = y, x%y        
    return x


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = True
    is_prime[1] = True
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return {i: True for i in range(n + 1) if is_prime[i]}

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            if i in p:
                divisors.append(i)
            if i != n // i and n//i in p:
                divisors.append(n//i)

    return divisors
x = gcd(A, B)
p = primes(x)
x = make_divisors(x)
print(len(x))

### FIXED CODE ###

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


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

import math

def is_prime(n):
    if n == 1: return True

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

import fractions
x = fractions.gcd(A, B)
divisors = make_divisors(x)
ans = 0
for d in divisors:
    if is_prime(d):
        ans += 1
print(ans)
S = int(input())

h = S / 60
m = S % h
s = S % m

print(h+ ':' + m + ':' + s)

### FIXED CODE ###

S = int(input())

h = S // 3600
m = S // 60 % 60
s = S % 60

#print(h+ ':' + m + ':' + s)
print('{0}:{1}:{2}'.format(h,m,s));
n = int(input())
count = 0
for i in range(n):
    if i == 0:
        count = 0
    else:
        if n % i == 0:
            count += (n//i) -1
        else:
            count += (n//i)
print(count)

### FIXED CODE ###

s = input()
if s[-1:] == "s":
    print(s + "es")
else :
    print(s + "s")
n, m = map(int, input().split())
if n <= 10:
  minus = (10 - n) * 100
print(m - minus)

### FIXED CODE ###

n, r = map(int, input().split())
if n > 10:
    print(r)
else:
    print(r+100*(10-n))
N,K = list(int(t) for t in input().split())
price = list(int(t) for t in input().split())
price.sort()
total = sum(price[0,K])
print(total)

### FIXED CODE ###

N,K = input().split()
price = list(int(t) for t in input().split())
price_s = sorted(price)
total = sum(price_s[0:int(K)])
print(total)
H=int(input())

def rec(h):
  if h==1:
    return 1
  else:
    return rec(h/2)*2 + 1
print(rec(H))


### FIXED CODE ###

H=int(input())

def rec(h):
  if h==1:
    return 1
  else:
    return rec(h//2)*2 + 1
print(rec(H))
def main():
  # N個の県，M個の市，
  # 市iが誕生したのはY_i年で県P_iに属す
  # 市iが県P_iの中でx番目にできた市だと、市iの認識番号の上6桁はP_i,下6桁はx
  # 6桁以下だと6桁になるように左に0詰める

  N, M = map(int, input().split())
  iPY = []
  for i in enumerate(range(M)):
    p, y = map(int, input().split())
    iPY.append([i, p, y])
  # PY = [list(map(int, input().split())) for _ in range(M)]
  iPY_sorted = sorted(iPY, key=lambda x: x[2])

  city_count = {}
  order = {}
  for i, p, y in iPY_sorted:
    if not p in city_count:
      city_count[p] = 0
    city_count[p] += 1
    order[p, i] = city_count[p]
    
  for i, p, y in enumerate(iPY):
    print('{:06}{:06}'.format(p, order[p, i]))

main()

### FIXED CODE ###

N, M = map(int, input().split())
iPY = []
 
for i in range(M):
    p, y = map(int, input().split())
    iPY.append([i, p, y])
 
city_count = {}
order = {}
 
for i, p, y in sorted(iPY, key=lambda x: x[2]):
    if not p in city_count:
        city_count[p] = 0
    city_count[p] += 1
    order[p, i] = city_count[p]
    
for i, p, y in iPY:
    print('{:06}{:06}'.format(p, order[p, i]))
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect


if __name__ == "__main__":
    n = int(input())
    ans = [0]*(n**3+3)
    for i in range(1,int(n**0.5)+1):
        for j in range(1,int(n**0.5)+1):
            for k in range(1,int(n**0.5)+1):
                ans[i**2 + j**2 + k**2 + i*j + j*k + i*k]+=1
    for i in range(1,n+1):
        print(ans[i])

### FIXED CODE ###

import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect


if __name__ == "__main__":
    n = int(input())
    ans = [0]*(n+1)
    for i in range(1,int(n**0.5)+1):
        for j in range(1,int(n**0.5)+1):
            for k in range(1,int(n**0.5)+1):
                if i**2 + j**2 + k**2 + i*j + j*k + i*k<=n:
                    ans[i**2 + j**2 + k**2 + i*j + j*k + i*k]+=1
    for i in range(1,n+1):
        print(ans[i])
n = int(input())
a = list(map(int, input().split()))

ans = 0
max_ = 0
for i in range(n):
    ans += max(max_ - a[i], 0)
    max_ = max(max_, a[i])
print(ans)

### FIXED CODE ###

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

ans = 0
max_ = 0
for i in range(n):
    ans += max(max_ - a[i], 0)
    max_ = max(max_, a[i])
print(ans)