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

def isLunlun(num):
    prev = num%10
    num = num//10
    while(num!=0):
        curr = num%10
        if(abs(curr - prev)>1):
            return False
        prev = curr
        num = num//10
    return True

k = int(input())
count = 0
i = 1
while count<k:
    if(isLunlun(i)):
        count+=1
    i+=1
print(i-1)


### FIXED CODE ###

from queue import Queue
k = int(input())
q = Queue(maxsize = 10000000)
for i in range(1,10):
    q.put(i)
if(k<10):
    print(k)
else:
    count = 0
    while(count<k-1):
        ele = q.get()
        temp = ele%10
        if(temp-1>=0):
            q.put(int(str(ele)+str(temp-1)))
        q.put(int(str(ele)+str(temp)))
        if(temp+1<=9):
            q.put(int(str(ele)+str(temp+1)))
        count+=1
    print(q.get())
### BUGGY CODE ###

n,W = map(int, input().split(' '))
WV = (map(int, input().split(' ')) for _ in range(n))
dp = [0] * (W+1)
 
for w, v in WV:
  for j in range(W, w-1, -1):
    DP = dp[j-w] + v
    if dp[j] < DP:
      dp[j] = DP
print(dp[W])

### FIXED CODE ###

def DP():
    n,W = map(int, input().split(' '))
    WV = (map(int, input().split(' ')) for _ in range(n))
    dp = [0] * (W+1)

    for w, v in WV:
        for j in range(W, w-1, -1):
            DP = dp[j-w] + v
            if dp[j] < DP:
                dp[j] = DP
    return max(dp)
print(DP())
### BUGGY CODE ###

n, m = map(int, input().split())
lis = [1]*(n+2)
lis[0] = 0
lis[-1] = 0

for k in range(m):
  i, j = map(int, input().split())
  lis[:i] = [0]*(i)
  lis[j+1:] = [0]*(n - j + 2)
  
print(sum(lis))

### FIXED CODE ###

n, m = map(int, input().split())
i = 0
j = n + 1

for k in range(m):
  ti, tj = map(int, input().split())
  if ti > i:
    i = ti
  if tj < j:
    j = tj

if j == 0 and i == 0:
  print(0)
else:
  print(max(j - i + 1, 0))
### BUGGY CODE ###

import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, X, Y = [int(x) for x in input().split()]

    ans = [0] * N
    for i in range(1, N + 1):
        s = collections.deque()
        s.append([i, 0])
        v = set()
        v.add(i)
        while s:
            c = s.popleft()
            ans[c[1]] += 1

            if c[0] == X:
                if Y not in v:
                    s.append([Y, c[1] + 1])
                    v.add(Y)
            if c[0] == Y:
                if X not in v:
                    s.append([X, c[1] + 1])
                    v.add(X)

            if c[0] != 1:
                if c[0] - 1 not in v:
                    s.append([c[0] - 1, c[1] + 1])
                    v.add(c[0] - 1)

            if c[0] != N:
                if c[0] + 1 not in v:
                    s.append([c[0] + 1, c[1] + 1])
                    v.add(c[0] + 1)

    for a in ans[1:]:
        print(a // 2)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, X, Y = [int(x) for x in input().split()]

    ans = [0] * N
    for i in range(1, N + 1):
        s = collections.deque()
        s.append([i, 0])
        v = set()
        v.add(i)
        while s:
            c = s.popleft()
            ans[c[1]] += 1

            if c[0] == X:
                if Y not in v:
                    s.append([Y, c[1] + 1])
                    v.add(Y)
            if c[0] == Y:
                if X not in v:
                    s.append([X, c[1] + 1])
                    v.add(X)

            if c[0] != 1:
                if c[0] - 1 not in v:
                    s.append([c[0] - 1, c[1] + 1])
                    v.add(c[0] - 1)

            if c[0] != N:
                if c[0] + 1 not in v:
                    s.append([c[0] + 1, c[1] + 1])
                    v.add(c[0] + 1)

    for a in ans[1:]:
        print(a // 2)


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

n,k=map(int,input().split())
A=[int(i) for i in input().split()]
AA=[0]*n
B=[2*n+1]*(2*(10**5)+1)
for i in reversed(range(n)):
  B[A[i]]=min(B[A[i]],n+i+1)
for i in reversed(range(n)):
  AA[i]=B[A[i]]-(i+1)
  B[A[i]]=i+1
count,index,inc=0,0,0
while count<n*k:
  index=(index+inc)%n
  inc=AA[index]+1
  count+=inc  
  if count%n==0:
    count*=(n*k)//count

count-=inc
d=n*k-count
Ans1=A+A
Ans1=Ans1[index:index+d]
Ans2=AA+AA
Ans2=Ans2[index:index+d]
Ans=[]
i=0
while i<d:
  if i+Ans2[i]>=d:
    Ans.append(Ans1[i])
    i+=1
  else:
    i+=Ans2[i]+1
print(*Ans)


### FIXED CODE ###

n,k=map(int,input().split())
A=[int(i) for i in input().split()]
AA=[0]*n
B=[2*n+1]*(2*(10**5)+1)
for i in reversed(range(n)):
  B[A[i]]=n+i+1
for i in reversed(range(n)):
  AA[i]=B[A[i]]-(i+1)
  B[A[i]]=i+1
count,index,inc=0,0,0
Chk=[0]*n
flag=False
while count<n*k:

  inc=AA[index]+1
  count+=inc  
  index=(index+inc)%n
  if Chk[index]!=0 or index==0:
    if flag==False:
      dd=count-Chk[index]
      count+=(((n*k)-count)//dd)*dd
      flag=True
  Chk[index]=count

count-=inc
index=(index+n-inc)%n

d=n*k-count
Ans1=A+A
Ans2=AA+AA
Ans=[]
i=index
while i<d+index:
  if i+Ans2[i]>=d+index:
    Ans.append(Ans1[i])
    i+=1
  else:
    i+=Ans2[i]+1
print(*Ans)
### BUGGY CODE ###

import numpy as np
from itertools import combinations
N = int(input())
A = np.array(list(map(int, input().split())), dtype= int)
X = A.sum()
A1 = np.cumsum(A)
mincost1 = -1
for r2 in range(1,N-2):
    Y = A1[r2]
    mincost2 = -1
    r1 = 1
    for i in np.arange(-1,2)+np.argmax(A1*(A1<=Y/2)):
        L = A1[i]
        R = Y - L
        cost = np.abs(R-L)
        if mincost2 < 0 or mincost2 >  cost:
            mincost2 = cost
            r1 = i
    P = A1[r1]
    Q = Y - A1[r1]

    mincost3 = -1
    r3 = N-1
    for i in  np.arange(-1,2)+np.argmax(A1*(A1<=(X+Y)/2)):
        L = A1[i] - Y
        R = X - Y - L
        cost = np.abs(R-L)
        if mincost3 < 0 or mincost3 >  cost:
            mincost3 = cost
            r3 = i

    R = A1[r3]-Y
    S = X-A1[r3]
    cost = max(P,Q,R,S) - min(P,Q,R,S)
    if mincost1 < 0 or mincost1 >  cost:
            mincost1 = cost
print(mincost1)

### FIXED CODE ###

from itertools import accumulate
input()
*s, = accumulate(map(int, input().split()))
l,r,t = 0,2,s[-1]
c = t
for m in s[1:-2]:
    while t+m > s[r]+s[r+1]:
        r += 1
    while m > s[l]+s[l+1]:
        l += 1
    x = sorted([s[l],m-s[l],s[r]-m,t-s[r]])
    c = min(c,x[-1]-x[0])
print(c)
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
b=0
c=0
for v in range(n-1):
  b+=a[v]
  c+=a[v]*(sum(a)-b)
print(c%(10**9+7))  

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=sum(a)
c=0
for v in range(n-1):
  b-=a[v]
  c+=a[v]*b
print(c%(10**9+7))
### BUGGY CODE ###

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

L=[0]*M
R=[0]*M

for i in range(M):
  L[i],R[i]=map(int,input().split())

def prison(N,M,L,R):
  count=0
  for n in range(N):
    num_of_truth=0
    for l,r in zip(L,R):
      if l<=(n+1)<=r:
        num_of_truth+=1
    if num_of_truth==M:
      count+=1
  return count
print(prison(N,M,L,R))

### FIXED CODE ###

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

L=[0]*M
R=[0]*M

for i in range(M):
  L[i],R[i]=map(int,input().split())

def prison(N,M,L,R):
  max_val=min(R)
  min_val=max(L)
  num=max_val-min_val+1
  if num<=0:
    num=0
  return(num)

print(prison(N,M,L,R))
### BUGGY CODE ###

n,m = map(int,input().split())
one_li = []
to_n_li = []
for _ in range(m):
    a,b = map(int,input().split())
    if a == 1:
        one_li.append(b)
    if b == n:
        to_n_li.append(a)
#print(one_li,to_n_li)
for o in one_li:
    if o in to_n_li:
        print('POSSIBLE')
        exit()
else:
    print('IMPOSSIBLE')

### FIXED CODE ###

n,m = map(int,input().split())
one_li = []
to_n_li = []
for _ in range(m):
    a,b = map(int,input().split())
    if a == 1:
        one_li.append(b)
    if b == n:
        to_n_li.append(a)
ll = len(set(one_li) & set(to_n_li))
if ll == 0:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')
### BUGGY CODE ###

N = list(map(int, input().split()))[-1]
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

first = [i+j for i in A for j in B]
first = sorted(first)[::-1]
second = [first[i]+j for i in range(len(first)) for j in C if i <= N]

print("\n".join([str(value) for value in sorted(second)[::-1][:N]]))

### FIXED CODE ###

N = list(map(int, input().split()))[-1]
A = sorted(list(map(int, input().split())), reverse=True)[:N]
B = sorted(list(map(int, input().split())), reverse=True)[:N]
C = sorted(list(map(int, input().split())), reverse=True)[:N]

first = [i+j for i in A for j in B]
first = sorted(first, reverse=True)[:N]
second = [i+j for i in first for j in C]
result = sorted(second, reverse=True)[:N]

[print(i) for i in result]
### BUGGY CODE ###

n, m = list(map(int, input().split()))
ab = []
aida = []
for i in range(m):
    x, y = [int(j) for j in input().split()]
    if y == n:
        aida.append(x)
    ab.append((x, y))

for i in range(m):
    if ab[i][0] == 1 and ab[i][1] in aida:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

### FIXED CODE ###

n, m = list(map(int, input().split()))
# a = list(map(int, input().split()))
# abc = [int(input()) for i in range(5)]
to = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    to[a-1].append(b-1)
    to[b-1].append(a-1)
# print(to)
for i in range(len(to[0])):
    if n-1 in to[to[0][i]]:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")
### BUGGY CODE ###

n=int(input())
h=list(map(int,input().split()))
ans=0
for i in range(n):
    cnt=0
    step=h[i]
    for j in range(i+1,n):
        if step<h[j]: break
        step=h[j]
        cnt+=1
    ans=max(ans,cnt)
print(ans)

### FIXED CODE ###

n=int(input())
if n==1:print('0'); exit()
h=list(map(int,input().split()))
ans=0
step=0
for i in range(n):
    cnt=0
    for j in range(n):
        if h[step]<h[step+1]: step+=1; break
        cnt+=1; step+=1
        if step+1==n: break
    ans=max(ans,cnt)
    if step+1==n: break
print(ans)
### BUGGY CODE ###

N, M ,K= map(int, input().split())
a=[0]*M
b=[0]*M
c=[0]*K
d=[0]*K

for i in range(M):
    a[i], b[i] = map(int, input().split())
for i in range(K):
    c[i], d[i] = map(int, input().split())

l=list(range(N+1))
r=[0]*(N+1)
la=N
di=[[]for _ in range(N+1)]
def find(x):
    if l[x]==x:
        return x
    else:
        return find(l[x])

def union(x,y):
    X=find(x)
    Y=find(y)
    if r[X]>r[Y]:
        l[Y]=l[X]
    else:
        l[X]=l[Y]
        if r[X]==r[Y]:
            r[Y]+=1

for i in range(M):
    union(a[i],b[i])
    di[a[i]].append(b[i])
    di[b[i]].append(a[i])
for i in range(K):
    di[c[i]].append(d[i])
    di[d[i]].append(c[i])

for i in range(N+1):
    l[i]=find(i)
t=[]
for i in range(N+1):
    w=0
    for j in range(len(di[i])):
        if l[i]==l[di[i][j]]:
            w+=1
    p=l.count(l[i])-1-w

    t.append(p)


print(" ".join(map(str, t[1:])))



### FIXED CODE ###

N, M ,K= map(int, input().split())
a=[0]*M
b=[0]*M
c=[0]*K
d=[0]*K

for i in range(M):
    a[i], b[i] = map(int, input().split())
for i in range(K):
    c[i], d[i] = map(int, input().split())

l=list(range(N+1))
r=[0]*(N+1)
size=[1]*(N+1)
la=N
di=[[]for _ in range(N+1)]
def find(x):
    if l[x]==x:
        return x
    else:
        return find(l[x])

def union(x,y):
    X=find(x)
    Y=find(y)
    if r[X]>r[Y]:
        l[Y]=l[X]
        size[X]+=size[Y]
    else:
        l[X]=l[Y]

        if r[X]==r[Y]:
            r[Y]+=1
        if X!=Y:
            size[Y] += size[X]
for i in range(M):
    union(a[i],b[i])
    di[a[i]].append(b[i])
    di[b[i]].append(a[i])
for i in range(K):
    if (find(c[i])==find(d[i])):
        di[c[i]].append(d[i])
        di[d[i]].append(c[i])

t=[]
for i in range(N+1):
    p=size[find(i)]-1-len(di[i])

    t.append(p)


print(" ".join(map(str, t[1:])))
### BUGGY CODE ###

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

#c = collections.Counter(A)
#print(c)

for i in range(Q):
  A = [C[i] if B[i]==A[j] else A[j] for j in range(N)]
#  print(A)
  print(sum(A))
#l_replace = [100 if i > 0 else i for i in l]  
#
#  print(C[i]-1,B[i]-1)
##  D[B[i]-1]=0
#  print(int(np.average(D, weights=W)))
  

### FIXED CODE ###

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

D = collections.Counter(A)
s=sum(A)
for i in range(Q):
  s=s-B[i]*D[B[i]]
  D[C[i]]+=D[B[i]]
  s=s+C[i]*D[B[i]]
  D[B[i]]=0
#  A = [C[i] if B[i]==A[j] else A[j] for j in range(N)]
#  print(A)
  print(s)
### BUGGY CODE ###

from collections import Counter
N = int(input())
D = list(map(int,input().split()))
M = int(input())
T = list(map(int,input().split()))
CT = Counter(T)
D.sort()
T.sort()
ans = 'YES'

for i,j in CT.items():
  if D.count(i) < j:
    ans = 'NO'
    break

print(ans)

### FIXED CODE ###

from collections import Counter
N = int(input())
D = list(map(int,input().split()))
M = int(input())
T = list(map(int,input().split()))

CD = Counter(D)
CT = Counter(T)
ans = CT - CD

if ans:
  print('NO')
else:
  print('YES')
### BUGGY CODE ###

# -*- coding: utf-8 -*-
from operator import itemgetter

N, M = list(map(int, input().split()))
A = [[0] * 4 for i in range(M)]
P = []
for i, a in enumerate(A):
    a[0], a[1] = list(map(int, input().split()))
    a[2] = i
    if not a[0] in P:
        P.append(a[0])

P_counts = [0]*len(P)
sorted_A = sorted(A, key=itemgetter(1))

for a in sorted_A:
    idx = P.index(a[0])
    P_counts[idx] += 1
    a[3] = str(a[0]).zfill(6) + str(P_counts[idx]).zfill(6)

B = sorted(sorted_A, key=itemgetter(2))
for b in B:
    print(b[3])


### FIXED CODE ###

# -*- coding: utf-8 -*-
from operator import itemgetter

N, M = list(map(int, input().split()))
A = [[0] * 4 for i in range(M)]
for i in range(M):
    A[i][0], A[i][1] = list(map(int, input().split()))
    A[i][2] = i

sorted_A = sorted(A, key=itemgetter(1))

P_num = [1]*N
for a in sorted_A:
    y = a[0]
    a[3] = P_num[y-1]
    P_num[y-1] += 1

B = sorted(sorted_A, key=itemgetter(2))
for b in B:
    print("%06d%06d" % (b[0], b[3]))
### BUGGY CODE ###

t_max = 10 ** 5

N, C = map(int, input().split())
imos = [[0] * (t_max + 1) for _ in range(C + 1)]
# imos[c][x]:=チャンネルc,時刻xの使用有無
# c: 1-indexed
# x: 1-indexed

for _ in range(N):
    s, t, c = map(int, input().split())
    imos[c][s] += 1
    imos[c][t] -= 1

for c in range(1, C + 1):
    for i in range(1, t_max + 1):
        imos[c][i] += imos[c][i - 1]
        if imos[c][i] > 0 and imos[c][i - 1] == 0:
            imos[c][i - 1] = imos[c][i]

ans = 0
for i in range(1, t_max + 1):
    ans = max(ans, sum(imos[c][i] for c in range(1, C + 1)))
print(ans)


### FIXED CODE ###

t_max = 10 ** 5

N, C = map(int, input().split())
imos = [[0] * (t_max + 1) for _ in range(C + 1)]
# imos[c][x]:=チャンネルc,時刻xの使用有無
# c: 1-indexed
# x: 1-indexed

for _ in range(N):
    s, t, c = map(int, input().split())
    imos[c][s] += 1
    imos[c][t] -= 1

for c in range(1, C + 1):
    for i in range(1, t_max + 1):
        imos[c][i] += imos[c][i - 1]
        if imos[c][i] > 0 and imos[c][i - 1] == 0:
            imos[c][i - 1] = imos[c][i]

ans = 0
for i in range(1, t_max + 1):
    ans = max(ans, sum(imos[c][i] for c in range(1, C + 1)))
print(ans)
### BUGGY CODE ###

import sys
import collections
import copy

input = sys.stdin.readline


def main():
    N = int(input())
    A = [collections.deque([int(x) for x in input().split()]) for _ in range(N)]

    day = 0
    c = 0
    nxt = [A[x][0] for x in range(N)]
    for i in range(N):
        A[i].popleft()

    while c != N * (N - 1):
        day += 1

        nxt2 = copy.copy(nxt)
        tmp = set()
        for i in set(nxt):
            if i == -1 or i in tmp:
                continue
            if i == nxt[nxt[i - 1] - 1]:
                if A[i - 1]:
                    nxt2[i - 1] = A[i - 1].popleft()
                else:
                    nxt2[i - 1] = -1
                if A[nxt[i - 1] - 1]:
                    nxt2[nxt[i - 1] - 1] = A[nxt[i - 1] - 1].popleft()
                else:
                    nxt2[nxt[i - 1] - 1] = -1
                tmp.add(i)
                tmp.add(nxt[i - 1])
                c += 2
        if not tmp:
            print(-1)
            return

        nxt = copy.copy(nxt2)

    print(day)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import collections
import copy

input = sys.stdin.readline


def main():
    N = int(input())
    A = [collections.deque([int(x) for x in input().split()]) for _ in range(N)]

    day = 0
    c = 0
    nxt = [x for x in range(N)]
    oppo = [0] * N

    while c != N * (N - 1):
        day += 1

        for i in nxt:
            oppo[i] = A[i].popleft() if A[i] else -1

        tmp = set()
        for i in nxt:
            if i == -1 or i in tmp:
                continue
            if i == oppo[oppo[i] - 1] - 1:
                tmp.add(i)
                tmp.add(oppo[i] - 1)
                c += 2
        if not tmp:
            print(-1)
            return

        nxt = tmp

    print(day)


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

import collections

n = int(input())
s = [str(input()) for _ in range(n)]
ans = []

c = collections.Counter(s)
for k, v in sorted(c.items()):
    if v == max(c.values()):
        print(k)

### FIXED CODE ###

n = int(input())

d = {}
for i in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

m = max(d.values())
for i in sorted(k for k in d if d[k] == m):
    print(i)
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
mul=1
for i in range(len(a)):
    mul=mul*a[i]
    
if mul>10**18:
    print(-1)
if mul<=10**18:
    print(mul)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
mul=1
if a.count(0)>=1:
    print(0)
if a.count(0)==0:
    for i in range(len(a)):
        mul=mul*a[i]
        if mul>10**18:
            break
    
    if mul>10**18:
        print(-1)
    if mul<=10**18:
        print(mul)
### BUGGY CODE ###

s = input()

s_val = int(s, 2)


s1 = 0
s2 = 0
for i in range(len(s)):
    if i%2==0:
        s1 += 2**i
    elif i%2==1:
        s2 += 2**i

num = min(str(bin(s_val^s1)).count('1'), str(bin(s_val^s2)).count('1'))
print(num)

### FIXED CODE ###

s = input()

s_val = int(s, 2)


s1 = ''
s2 = ''
for i in range(len(s)):
    if i%2==0:
        s1 = s1 + '1'
        s2 = s2 + '0'
    else:
        s1 = s1 + '0'
        s2 = s2 + '1'

num = min(str(bin(s_val^int(s1,2))).count('1'), str(bin(s_val^int(s2,2))).count('1'))
print(num)
### BUGGY CODE ###

n = int(input())
ai = [int(i) for i in input().split()]

num_li = [0]*(10**6+1)


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)

    divisors.sort(reverse=True)
    return divisors

#昇順
ai.sort()
min_ai = ai[0]

for i in range(n):
    num_li[ai[i]] += 1

ans = 0
    
for i in range(n):
    if num_li[ai[i]] > 1:
        continue
    #print(ai[i])
    flag = True
    div = make_divisors(ai[i])
    #print(div)
    #print(div)
    for j in range(len(div)):
        if div[j] < min_ai:
            break
        if div[j] == ai[i]:
            continue
        #print(div[j],div)
        if num_li[div[j]] > 0:
            flag = False
            break
    if flag == True:
        ans += 1
    #exit()
print(ans)


### FIXED CODE ###

import math
n = int(input())
ai = [int(i) for i in input().split()]

ai.sort()

sqr_max_val = int(ai[n-1]**0.5)
max_val = ai[n-1]
#print(ai)
ai_ex = [0]*(2*10**6)
#ai_ex = [0]*(30)

for i in range(n):
    ai_ex[ai[i]-1] += 1

for i in range(n):
    if ai_ex[ai[i]-1] > 1:
        ai_ex[ai[i]-1] = 0
    """
    if ai[i] > sqr_max_val:
        break
    """
    tmp = ai[i]
    baisu = 2
    #print(ai[i])
    while tmp * baisu <=  max_val:
        ai_ex[tmp*baisu-1] = 0
        #print(tmp*baisu)
        baisu += 1
"""
for i in range(100):
    if ai_ex[i] == 1:
        a = 1
        #print(i)
"""
print(sum(ai_ex))
#print(ai_ex)
### BUGGY CODE ###

N = int(input())
P = list(map(int, input().split()))
ans = 0
for i in range(N):
    partP = P[:i+1]
    cnt = 1
    for p in partP:
        if cnt == 0:
            break
        elif P[i] <= p:
            continue
        else:
            cnt *= 0
    if cnt == 1:
        ans += 1

print(ans)


### FIXED CODE ###

N = int(input())
P = list(map(int, input().split()))
ans =1 
newP = P[0]
for i in range(1, N):
    newP = (min(newP, P[i]))
    if newP == P[i]:
        ans += 1

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

from collections import defaultdict


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s = (s + self.tree[i]) % 1000000007
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] = (self.tree[i] + x) % 1000000007
            i += i & -i


n, m = list(map(int, input().split()))
sss = list(map(int, input().split()))
ttt = list(map(int, input().split()))

sid = defaultdict(list)
for i, s in reversed(list(enumerate(sss))):
    sid[s].append(i)

bit = Bit(n + 1)
bit.add(1, 1)

for t in ttt:
    if t not in sid:
        continue
    for i in sid[t]:
        bit.add(i + 2, bit.sum(i + 1))

print(bit.sum(n + 1))


### FIXED CODE ###

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s = (s + self.tree[i]) % 1000000007
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] = (self.tree[i] + x) % 1000000007
            i += i & -i


n, m = list(map(int, input().split()))
sss = list(map(int, input().split()))
ttt = list(map(int, input().split()))

bit = Bit(n + 1)

for t in ttt:
    for i in range(n - 1, -1, -1):
        s = sss[i]
        if s != t:
            continue
        bit.add(i + 2, bit.sum(i + 1) + 1)

print(bit.sum(n + 1) + 1)
### BUGGY CODE ###

n, m = map(int, input().split())
li = []
d = {}
for _ in range(m):
    p, y = map(int, input().split())
    li.append([p, y])
    if p not in d:     
        d[p] = [y]
    else:
        d[p].append(y)
for k, v in d.items():
    v.sort()
for p, y in li:
    r = d[p].index(y) + 1
    print(str(p).zfill(6) + str(r).zfill(6))


### FIXED CODE ###

import bisect

n, m = map(int, input().split())
li = []
d = {}
for _ in range(m):
    p, y = map(int, input().split())
    li.append([p, y])
    if p not in d:     
        d[p] = [y]
    else:
        d[p].append(y)
for k, v in d.items():
    v.sort()
for p, y in li:
    r = bisect.bisect_right(d[p], y)
    print(str(p).zfill(6) + str(r).zfill(6))