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

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

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    s = input()
    ans = ""
    k = I()
    for i,si in enumerate(s):
        if si == "a":
            ans += si
            continue
        j = (ord("a")-ord(si))%26
        if j <= k:
            k -= j
            ans += "a"
        else:
            ans += si
    k %= 26
    print(ans[:-1]+chr(ord(ans[-1])+k))
    return

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


### FIXED CODE ###

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

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    s = input()
    ans = []
    k = I()
    for i,si in enumerate(s):
        if si == "a":
            ans.append(si)
            continue
        j = (ord("a")-ord(si))%26
        if j <= k:
            k -= j
            ans.append("a")
        else:
            ans.append(si)
    k %= 26
    ans[-1] = chr(ord(ans[-1])+k)
    print(*ans,sep="")
    return

#Solve
if __name__ == "__main__":
    solve()
### BUGGY CODE ###

N = input()
A = map(int, input().split())
val = 1
for a in A:
    val *= a

if val > 10 ** 18:
    print(-1)
else:
    print(val)


### FIXED CODE ###

N = input()
A = list(map(int, input().split()))
 
if 0 in A:
    print(0)
    exit()
 
A = sorted(A)[::-1]
val = 1
 
for a in A:
    val *= a
    if val > 10 ** 18:
        print(-1)
        exit()
print(val)
### BUGGY CODE ###

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

N = int(input().strip())
S_list = [input().strip() for _ in range(N)]
#-----

def count_brackets(brackets):
    L = R = 0
    L_rev = R_rev = 0
    max_R = -float("inf")
    max_L = -float("inf")
    
    
    for i in range(len(brackets)):
        if brackets[i] == "(":
            L += 1
        else:  # brackets[i] == ")"
            R += 1
            max_R = max(max_R, R - L)
        
        if brackets[len(brackets)-1-i] == "(":
            L_rev += 1
            max_L = max(max_L, L_rev - R_rev)
        else:  # brackets[len(brackets)-1-i] == ")"
            R_rev += 1
    
    if max_L < 0: max_L = 0
    if max_R < 0: max_R = 0
    
    return max_L, max_R

#-----
cnt_brackets = []

for S in S_list:
    cnt_brackets.append( count_brackets(S) )


tmp_cnt1 = []
tmp_cnt2 = []

for cnt_L,cnt_R in cnt_brackets:
    if cnt_L == cnt_R == 0:
        continue
    
    if cnt_L >= cnt_R:
        tmp_cnt1.append( (cnt_L,cnt_R) )
    else:
        tmp_cnt2.append( (cnt_L,cnt_R) )

tmp_cnt1.sort(key=lambda x: x[1])
tmp_cnt2.sort(key=lambda x: -x[0])


sum_bracket = 0
flag = True

for cnt_L,cnt_R in (tmp_cnt1 + tmp_cnt2):
    sum_bracket -= cnt_R
    if sum_bracket < 0:  flag = False
    
    sum_bracket += cnt_L
    if sum_bracket < 0:  flag = False
    
    if flag == False:
        break


if (sum_bracket == 0) and flag:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

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

N = int(input().strip())
S_list = [input().strip() for _ in range(N)]
#-----

def count_brackets(brackets):
    L = R = 0
    L_rev = R_rev = 0
    max_R = -float("inf")
    max_L = -float("inf")
    
    
    for i in range(len(brackets)):
        if brackets[i] == "(":
            L += 1
        else:  # brackets[i] == ")"
            R += 1
            max_R = max(max_R, R - L)
        
        if brackets[len(brackets)-1-i] == "(":
            L_rev += 1
            max_L = max(max_L, L_rev - R_rev)
        else:  # brackets[len(brackets)-1-i] == ")"
            R_rev += 1
    
    if max_L < 0: max_L = 0
    if max_R < 0: max_R = 0
    
    return max_L, max_R


tmp_cnt1 = []  #  the number of "("  >=  the number of ")"
tmp_cnt2 = []  #  the number of "("  <   the number of ")"

for S in S_list:
    cnt_L,cnt_R = count_brackets(S)

    if cnt_L == cnt_R == 0:
        continue
    
    if cnt_L >= cnt_R:
        tmp_cnt1.append( (cnt_L,cnt_R) )
    else:
        tmp_cnt2.append( (cnt_L,cnt_R) )


tmp_cnt1.sort(key=lambda x: x[1])
tmp_cnt2.sort(key=lambda x: -x[0])


sum_bracket = 0
flag = True

for cnt_L,cnt_R in (tmp_cnt1 + tmp_cnt2):
    sum_bracket -= cnt_R
    if sum_bracket < 0:  flag = False
    
    sum_bracket += cnt_L
    if sum_bracket < 0:  flag = False
    
    if flag == False:
        break


if (sum_bracket == 0) and flag:
    print("Yes")
else:
    print("No")
### BUGGY CODE ###

n = input()
num_list = map(int, input().split())

ans = 1
max_ans = 10**18
for num in num_list:
    ans = ans * num

if ans > max_ans:
    ans = -1


print(ans)

### FIXED CODE ###

n = input()
list = input().split()

ans = 1
max_ans = 10**18

if "0" in list:
    ans = 0
else:       
    for num in list:
        ans = ans * int(num)
        if ans > max_ans:
            ans = -1
            break

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

[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = []
mini = min(A[0:L])
ans.append(mini - N)
for i in range(1,N-L+1) :
    if A[i+L-1] <= mini :
        mini = A[i+L-1]
    elif A[i-1] == mini :
        mini = min(A[i:i+L])
    ans.append(mini-N)
for i in ans[:-1] : print(i+N, end=" ")
print(ans[-1]+N)

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])
### BUGGY CODE ###

import math
N=int(input())
for n in range(1,N+1):
    ans=0
    if n<=5:
        print(ans)
        continue
    X=math.floor(n**0.5)
    for x in range(1,X+1):
        for y in range(1,x+1):
            for z in range(1,y+1):
                if x**2 + y**2 + z**2 + x*y + y*z + x*z==n:
                    if (x==y and y!=z and z!=x) or (x!=y and y==z and z!=x) or (x!=y and y!=z and z==x): 
                        ans+=3
                    elif x==y and y==z and z==x:
                        ans+=1
                    else:
                        ans+=6
    print(ans)


### FIXED CODE ###

N = int(input())
ans = [0] * 100000
for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            ans[x*x+y*y+z*z+x*y+y*z+z*x-1] += 1
for i in range(N):
    print(ans[i])
### BUGGY CODE ###

n = int(input())
s = []
 
for i in range(n):
    s.append(input())
 
buf = []
cnt = []
for i in s:
    if i not in buf:
        buf.append(i)
        cnt.append(0)
    cnt[buf.index(i)] += 1
 
max_cnt = max(cnt)
ans = [i for i, x in enumerate(cnt) if x == max_cnt]
 
ans2 = [buf[i] for i in range(len(buf)) if i in ans]
 
ans3 = sorted(ans2)
 
for i in ans3:
    print(i)

### FIXED CODE ###

n = int(input())
s = []

for i in range(n):
    s.append(input())

word_buf = {}

for i in s:
    if i in word_buf.keys():
        word_buf[i] += 1
    else:
        word_buf[i] = 1

max_cnt = max(word_buf.values())
max_word = [i[0] for i in word_buf.items() if i[1] == max_cnt]
max_word.sort()

for i in max_word:
    print(i)
### BUGGY CODE ###

a, b = map(int, input().split())
snowless = []
cnt = 0
ans = 0
for i in range(1, 1000):
    cnt += i
    snowless.append(cnt)

for j in range(snowless[-1]):
    if a + j in snowless and b + j in snowless:
        ans = j

print(ans)


### FIXED CODE ###

a, b = map(int, input().split())
snowless = []
cnt = 0
ans = 0
for i in range(1, 1000):
    cnt += i
    snowless.append(cnt)

for j in range(snowless[-1]):
    if a + j in snowless and b + j in snowless:
        ans = j

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

N = int(input())
z = 0
for a in range(N):
    for b in range(N):
        for c in range(N):
            if (a+1)*(b+1)+(c+1) == N:
                z = z+1
            else:
                pass
print(z)

### FIXED CODE ###

import math
N = int(input())
z = 0
for a in range(N):
    for b in range(min(a,math.floor(N/(a+1)))):
        if N - (a+1)*(b+1) > 0:
            z = z+2
        else:
            pass
    if N - (a+1)*(a+1) > 0:
        z = z+1
    else:
        pass
print(z)
### BUGGY CODE ###

import numpy as np

S = input()
MOD = 2019
dp = np.zeros(MOD, dtype=np.int64)
dp[0] = 1

def hoge(dp, s):
    T = dp.copy()
    dp[s:] = T[:-s]
    dp[:s] = T[-s:]

def huga(dp, s):
    T = dp.copy()
    for i in range(MOD):
        dp[i] = T[(i - s) % MOD]

ans = 0
for i, s in enumerate(S[::-1]):
    huga(dp, (int(s) * pow(10, i, MOD)) % MOD)
    ans += dp[0]
    dp[0] += 1
print(ans)


### FIXED CODE ###

from collections import defaultdict
S = input()
MOD = 2019

cnt = [0] * MOD
cnt[0] = 1

now = 0
ans = 0
for d, n in enumerate(map(int, S[::-1])):
    now = (n * pow(10, d, MOD) + now) % MOD
    ans += cnt[now]
    cnt[now] += 1

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

import fractions
from functools import reduce
m=int(input())
a=list(map(int,input().split()))
def lcm_base(x,y):
    return (x*y)//fractions.gcd(x,y)
def lcm_list(numbers):
    return reduce(lcm_base,numbers,1)
#print(lcm_list(a))

n=lcm_list(a)

mod=10**9+7
ans=0
for i in range(m):
    ans+=n//a[i]%mod
print(ans%mod)

### FIXED CODE ###

import fractions
from functools import reduce
m=int(input())
a=list(map(int,input().split()))
def lcm_base(x,y):
    return (x*y)//fractions.gcd(x,y)
def lcm_list(numbers):
    return reduce(lcm_base,numbers,1)
mod=10**9+7
n=lcm_list(a)
ans=0
for i in range(m):
    ans+=(n//a[i])
print(ans%mod)
### BUGGY CODE ###

N, K = map(int, input().split())
h = list(map(int, input().split()))
 
DP = [0]
for i in range(N-1):
    act = float("inf")
    for k in range(K):
        if i-k < 0 : continue
        act = min(DP[-1-k] + abs(h[i-k]-h[i+1]) , act)
    DP += [act]
 
print(DP[-1])

### FIXED CODE ###

import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
#文字列を一文字ずつ数字に変換、'5678'を[5,6,7,8]とできる
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))
def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
#文字列として取得
def ST(): return sys.stdin.readline().rstrip()
def LST(): return sys.stdin.readline().rstrip().split()
def LST2(N): return [sys.stdin.readline().rstrip().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)

N, K= MI()
S = [0]+LI()
S += [0]
dp = [INF]*(N+5)
dp[1] = 0
for i in range(N):
    for j in range(1,K+1):
        if i+j <= N:
            dp[i+j] = min(dp[i+j],dp[i] + abs(S[i+j]-S[i]))
print(dp[N])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(500000)

def dfs(v,d):
    memo[i][v] = d
    for k in graph[v]:
        if memo[i][k[0]] != -1:
            if memo[i][k[0]] > d+k[1]:
                dfs(k[0],d+k[1])
                continue
            continue
        dfs(k[0],d+k[1])

def check(count,last,distance):
    if (count == r):
        if (ans[0] > distance ):ans[0] = distance
        return
    for i in range(r):
        if seen[i]:continue
        seen[i] = True
        if last == -1:check(count+1,i,0)
        else:check(count+1,i,distance+memo[R[last]-1][R[i]-1])
        seen[i] = False

n,m,r = map(int,input().split())
R = list(map(int,input().split()))
graph = [[] for _ in range(n)]
for i in range(m):
    x,y,z = map(int,input().split())
    graph[x-1].append([y-1,z])
    graph[y-1].append([x-1,z])
memo = [[-1]*n for _ in range(n)]
for i in range(n):
    dfs(i,0)
seen = [False]*r
ans = [float("Inf")]
check(0,-1,0)
print(*ans)

### FIXED CODE ###

def dfs(count,last,distance):
    if (count == r):
        if (ans[0] > distance ):ans[0] = distance
        return
    for i in range(r):
        if seen[i]:continue
        seen[i] = True
        if last == -1:dfs(count+1,i,0)
        else:dfs(count+1,i,distance+dp[R[last]-1][R[i]-1])
        seen[i] = False

n,m,r = map(int,input().split())
R = list(map(int,input().split()))
dp = [[ 0 if i == j else float("inf") for i in range(n)] for j in range(n)]
for i in range(m):
    x,y,z = map(int,input().split())
    dp[x-1][y-1] = z
    dp[y-1][x-1] = z
for k in range(n):
    for i in range(n):
        for j in range(n):
            if dp[i][j] > dp[i][k] + dp[k][j]:
                dp[i][j] = dp[i][k] + dp[k][j]
ans = [float("Inf")]
seen = [False]*r
dfs(0,-1,0)
print(*ans)
### BUGGY CODE ###

def resolve():
    k = int(input())
    a = list(map(int, input().split()))

    ra = a[::-1]
    now = [2]
    for i in range(k):
        nxt = []
        for j in range(len(now)):
            test = now[j]
            if test % ra[i] == 0:
                k = 0
                while k < ra[i]:
                    nxt.append(test+k)
                    k += 1
        if not nxt:
            print(-1)
            exit()
        now = nxt
    nxt = sorted(nxt)
    print("{} {}".format(nxt[0], nxt[-1]))
resolve()

### FIXED CODE ###

def resolve():
    # from collections import deque
    k = int(input())
    a = list(map(int, input().split()))
    rl = [2, 2]
    ra = a[::-1]

    for i in range(k):
        nxt = []
        nowa = ra[i]
        if (rl[-1] // nowa) - ((rl[0]-1)//nowa) > 0:
            nxt.append((((rl[0]-1)//nowa)+1)*nowa)
            nxt.append((rl[-1]//nowa)*nowa + nowa-1)
        if not nxt:
            print(-1)
            exit()
        rl = nxt

    print("{} {}".format(rl[0], rl[-1]))
resolve()
### BUGGY CODE ###

import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    H, W = map(int, readline().split())
    A = [list(map(int, readline().split())) for _ in range(H)]
    B = [list(map(int, readline().split())) for _ in range(H)]

    G = [[0] * W for _ in range(H)]
    M = 0
    for i in range(H):
        for j in range(W):
            G[i][j] = abs(A[i][j] - B[i][j])
            if M < G[i][j]:
                M = G[i][j]

    L = (H + W) * M
    dp = [[[False] * (L + 1) for j in range(W + 1)] for i in range(H + 1)]
    dp[0][1][0] = dp[1][0][0] = True

    for i in range(H):
        for j in range(W):
            b = G[i][j]
            for k in range(L + 1):
                if abs(k + b) <= L:
                    dp[i + 1][j + 1][k] = (
                        dp[i][j + 1][abs(k - b)]
                        or dp[i][j + 1][abs(k + b)]
                        or dp[i + 1][j][abs(k - b)]
                        or dp[i + 1][j][abs(k + b)]
                    )
                else:
                    dp[i + 1][j + 1][k] = dp[i][j + 1][abs(k - b)] or dp[i + 1][j][abs(k - b)]

    ans = INF
    for k in range(L + 1):
        if dp[H][W][k]:
            ans = k
            break

    print(ans)
    return


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    H, W = map(int, readline().split())
    A = [list(map(int, readline().split())) for _ in range(H)]
    B = [list(map(int, readline().split())) for _ in range(H)]

    G = [[0] * W for _ in range(H)]
    M = 0
    for i in range(H):
        for j in range(W):
            G[i][j] = abs(A[i][j] - B[i][j])
            if M < G[i][j]:
                M = G[i][j]

    dp = [[set() for j in range(W + 1)] for i in range(H + 1)]
    dp[0][1].add(0)
    dp[1][0].add(0)

    for i in range(H):
        for j in range(W):
            b = G[i][j]
            for k in dp[i + 1][j]:
                dp[i + 1][j + 1].add(k + b)
                dp[i + 1][j + 1].add(abs(k - b))
            for k in dp[i][j + 1]:
                dp[i + 1][j + 1].add(k + b)
                dp[i + 1][j + 1].add(abs(k - b))

    print(min(dp[H][W]))
    return


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

n=int(input())

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

sum=1

for i in a:
    sum*=i
if sum > 10**18:
    sum = -1
print(sum)


### FIXED CODE ###

n=int(input())

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

sum=1

for i in a:
    sum*=i
    if sum > 10**18:
        if 0 in a:
            sum = 0
            break
        else:
            sum = -1
            break
print(sum)
### BUGGY CODE ###

import math
H, N = list(map(int, input().split()))
 
AB = [list(map(int, input().split())) for _ in range(N)]
 
dp = [float('inf')] *(H+1)
dp[H] = 0
for a,b in AB:
    for i in range(H,-1,-1):
        if i <= H - a:
            dp[i] = min(dp[i], dp[i+a] + b)
    dp[0] = min(dp[0], min(dp[:a+1]) + b) # if hp is not just 0
print(dp[0])


### FIXED CODE ###

import math
H, N = list(map(int, input().split()))
 
AB = [list(map(int, input().split())) for _ in range(N)]
 
dp = [float('inf')] *(H+1)
dp[H] = 0
for a,b in AB:
    for i in range(H,-1,-1):
        if i <= H - a:
            dp[i] = min(dp[i], dp[i+a] + b)
    dp[0] = min(dp[0], min(dp[:a+1]) + b) # if hp is not just 0
print(dp[0])
### BUGGY CODE ###

#!/usr/bin/env python3
# coding=utf-8

import itertools
import sys

import numpy as np

n, k = map(int, sys.stdin.readline().strip().split(" "))
xyc = [l.strip().split(" ") for l in sys.stdin.readlines()]
xyc = [tuple((int(_x), int(_y), _c == "W")) for (_x, _y, _c) in xyc]
xyc = [
    tuple((_x % k, _y % k, _c if (_x // k + _y // k) % 2 == 0 else not _c)) for (_x, _y, _c) in xyc
]


def checker(base, condition):
    i, j, f = base
    x, y, c = condition
    if not ((x <= i and y <= j) or (i < x and j < y)):
        f = not f
    return f == c


xs = np.asarray([_x for (_x, _y, _c) in xyc])
ys = np.asarray([_y for (_x, _y, _c) in xyc])
cs = np.asarray([_c for (_x, _y, _c) in xyc])
ans = 0
for i, j, f in itertools.product(set(xs), set(ys), {True, False}):
    checks = np.logical_not(np.logical_xor((xs - i - 0.5) * (ys - j - 0.5) > 0, cs)) == f
    # checks = [checker((i, j, f), _xyc) for _xyc in xyc]
    ans = max(ans, sum(checks))
    if ans == n:
        break
print(ans)


### FIXED CODE ###

import numpy as np
N, K = map(int, input().split())
ub = K * 2
b = [[0 for j in range(ub + 1)] for i in range(ub + 1)]
ADD = {"B": 0, "W": K}


def create_bound(p, K, ub):
    if p - K + 1 >= 0:
        return [(p - K + 1, p + 1)]
    else:
        return [(0, p + 1), ((p - K + 1) % ub, ub)]


for i in range(N):
    x, y, c = input().split()
    nx = int(x) % ub
    ny = (int(y) + ADD[c]) % ub
    for add in [0, K]:
        for xlb, xub in create_bound((nx + add) % ub, K, ub):
            for ylb, yub in create_bound((ny + add) % ub, K, ub):
                b[xlb][ylb] += 1
                b[xlb][yub] -= 1
                b[xub][ylb] -= 1
                b[xub][yub] += 1

b_arr = np.array(b)
for i in range(ub):
    b_arr[i + 1, :] += b_arr[i, :]
for j in range(ub):
    b_arr[:, j + 1] += b_arr[:, j]
print(b_arr.max())
### BUGGY CODE ###

n, k = map(int, input().split())
l = []
for i in range(n):
    l.append(int(input()))

root = [1]*n

for i in range(n)[-2::-1]:
    num = 0
    for j in range(i + 1, n)[:i + 10**3]:
        if abs(l[i] - l[j]) <= k:
            num = max(num, root[j])
    root[i] += num

print(max(root))

### FIXED CODE ###

n, k = map(int, input().split())
l = []
for i in range(n):
    l.append(int(input()))

root = [1]*n

for i in range(n)[-2::-1]:
    num = 0
    for j in range(i + 1, i + 200):
        if j >= n:
            break
        if abs(l[i] - l[j]) <= k:
            num = max(num, root[j])
    root[i] += num

print(max(root))
### BUGGY CODE ###

n = int(input())
h = list(map(int, input().split()))
if h == sorted(h):
    print("Yes")
    exit()
for i in range(len(h)):
    copyh = h
    copyh[i] -= 1
    if copyh == sorted(copyh):
        print("Yes")
        exit()
print("No")

### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))
down = 0
for i in range(1, n):
    if h[i-1] > h[i]:
        down += h[i-1] - h[i]
    if h[i-1] < h[i]:
        down = 0
    if down >= 2:
        print("No")
        exit()
print("Yes")
### BUGGY CODE ###

import numpy
ans = 0
n, m = map(int, input().split())
a = numpy.cumsum([0] + [int(i) for i in input().split()])
for i in range(n):
    for j in range(i+1):
        if (a[i+1] - a[j]) % m == 0:
            ans += 1
print(ans)

### FIXED CODE ###

import numpy
na = lambda: list(map(int, input().split()))

n, m = na()
a = list(map(lambda x: x%m, list(numpy.cumsum([0] + na()))))

def count(n):
    return n*(n-1)//2

dic = dict()
ans = 0
for i in a:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1

ans = 0
for i in dic.values():
    ans += count(i)
print(ans)
### BUGGY CODE ###

S = list(input())
T = list(input())

new_S = ""
new_T = ""


def change_word(a,b,S):
    for i in range(len(S)):
        if S[i] == a:
            S[i] = b
        elif S[i] == b:
            S[i] = a
        else:
            S[i] == S[i]
    return S




for i in range(len(S)):
    if S[i] != T[i]:
        S = change_word(S[i], T[i], S)
        T = change_word(S[i], T[i], T)

if S == T:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

S = list(input())
T = list(input())
 
test = [-1] * 26
test2 = [-1] * 26

for i in range(len(S)):
    a = ord(S[i]) - ord('a')
    b = ord(T[i]) - ord('a')

    if (test[a] != -1) or test2[b] != -1:
        if test[a] != b or test2[b] != a:
           print("No")
           exit()

    else:
        test[a] = b
        test2[b] = a


print("Yes")