CodeEff/ECCO huggingface dataset:
# Original solution
import copy
while 1:
    W,H = list(map(int,input().split()))
    if W == 0: break
    field = [list(map(int,input().split())) for _ in range(H)]
    for y in range(H):
        for x in range(W):
            if field[y][x] == 2: sx,sy = x,y

    que = [[sx,sy,10,field[:]]]
    while que:
        x,y,t,field = que.pop(0)
        if t == -1: continue
        if field[y][x] == 3:
            print(10-t)
            break
        for dx,dy in zip([1,0,-1,0],[0,1,0,-1]):
            _field = copy.deepcopy(field[:])
            nx,ny = x+dx,y+dy
            while 0 <= nx < W and 0 <= ny < H:
                if _field[ny][nx] == 3:
                    que.append([nx,ny,t-1,_field[:]])
                    break
                if _field[ny][nx] == 1:
                    _field[ny][nx] = 0
                    if abs(nx-x)+abs(ny-y) == 1: break
                    que.append([nx-dx,ny-dy,t-1,_field[:]])
                    break
                nx += dx; ny += dy
    else:
        print(-1)

# Optimized solution
def rec(x,y,t):
    global ans
    if t >= ans: return
    if field[y][x] == 3: ans = min(ans,t)
    for dx,dy in zip([1,0,-1,0],[0,1,0,-1]):
        nx,ny = x+dx,y+dy
        while 0 <= nx < W and 0 <= ny < H:
            if field[ny][nx] == 3:
                rec(nx,ny,t+1)
            if field[ny][nx] == 1:
                if abs(nx-x)+abs(ny-y) == 1: break
                field[ny][nx] = 0
                rec(nx-dx,ny-dy,t+1)
                field[ny][nx] = 1
                break
            nx += dx; ny += dy

while 1:
    W,H = list(map(int,input().split()))
    if W == 0: break
    field = [list(map(int,input().split())) for _ in range(H)]
    for y in range(H):
        for x in range(W):
            if field[y][x] == 2: sx,sy = x,y
    ans = 11
    rec(sx,sy,0)
    print(ans if ans <= 10 else -1)
# Original solution
def rec(x,y,t):
    global ans
    if t >= ans: return
    if field[y][x] == 3: ans = min(ans,t)
    for dx,dy in zip([1,0,-1,0],[0,1,0,-1]):
        nx,ny = x+dx,y+dy
        while 0 <= nx < W and 0 <= ny < H:
            if field[ny][nx] == 3:
                rec(nx,ny,t+1)
            if field[ny][nx] == 1:
                if abs(nx-x)+abs(ny-y) == 1: break
                field[ny][nx] = 0
                rec(nx-dx,ny-dy,t+1)
                field[ny][nx] = 1
                break
            nx += dx; ny += dy

while 1:
    W,H = list(map(int,input().split()))
    if W == 0: break
    field = [list(map(int,input().split())) for _ in range(H)]
    for y in range(H):
        for x in range(W):
            if field[y][x] == 2: sx,sy = x,y
    ans = 11
    rec(sx,sy,0)
    print(ans if ans <= 10 else -1)

# Optimized solution
dxy = list(zip([1,0,-1,0],[0,1,0,-1]))
def rec(x,y,t):
    global ans
    if t >= ans: return
    if field[y][x] == 3: ans = min(ans,t)
    for dx,dy in dxy:
        nx,ny = x+dx,y+dy
        while 0 <= nx < W and 0 <= ny < H:
            if   field[ny][nx] == 3: ans = t
            elif field[ny][nx] == 1:
                if abs(nx-x)+abs(ny-y) == 1: break
                field[ny][nx] = 0
                rec(nx-dx,ny-dy,t+1)
                field[ny][nx] = 1
                break
            nx += dx; ny += dy

while 1:
    W,H = list(map(int,input().split()))
    if W == 0: break
    field = [list(map(int,input().split())) for _ in range(H)]
    for y in range(H):
        for x in range(W):
            if field[y][x] == 2: sx,sy = x,y
    ans = 11
    rec(sx,sy,1)
    print(ans if ans <= 10 else -1)
# Original solution
from copy import deepcopy as dcp
delta = ((1, 0), (0, 1), (-1, 0), (0, -1))
def ds(here, lb, ub, field, count):
	result = 11
	if count == 11:
		return count
	for dx, dy in delta:
		next = (here[0]+dx,here[1]+dy)
		if ( not (lb[0] <= next[0] <= ub[0] and lb[1] <= next[1] <= ub[1]) or
		   field[next[1]][next[0]] == 1) :
		    continue
		tmp = slide(next, (dx,dy), lb, ub, dcp(field), count + 1) 
		if tmp < result:
			result = tmp
	return result

def slide(here, di, lb, ub, field, count):
	while lb[0] <= here[0] <= ub[0] and lb[1] <= here[1] <= ub[1]:
		if here == goal:
			return count
		if field[here[1]][here[0]] == 1:
			field[here[1]][here[0]] = 0
			return ds((here[0]-di[0],here[1]-di[1]), lb, ub, field, count)
		here = (here[0]+di[0],here[1]+di[1])
	else:
		return 11
while 1:
	w, h = list(map(int,input().split(" ")))
	if w == h == 0: break
	board = [[0 for _ in range(w)] for _ in range(h)]
	for j in range(h):
		inp = list(map(int,input().split(" ")))
		for i in range(w):
			tmp = inp[i]
			if tmp == 0: continue
			if tmp == 1: board[j][i] = 1
			elif tmp == 2: start = (i,j)
			else : goal = (i,j)
	count = ds(start, (0,0), (w-1,h-1), board, 0) 
	print(count if count < 11 else -1)

# Optimized solution
delta = ((1, 0), (0, 1), (-1, 0), (0, -1))
def ds(here, lb, ub, field, count):
	result = 11
	if count == 11:
		return count
	for dx, dy in delta:
		next = (here[0]+dx,here[1]+dy)
		if ( not (lb[0] <= next[0] <= ub[0] and lb[1] <= next[1] <= ub[1]) or
		   field[next[1]][next[0]] == 1) :
		    continue
		tmp = slide(next, (dx,dy), lb, ub, field, count + 1) 
		if tmp < result:
			result = tmp
	return result

def slide(here, di, lb, ub, field, count):
	while lb[0] <= here[0] <= ub[0] and lb[1] <= here[1] <= ub[1]:
		if here == goal:
			result = count
			break
		if field[here[1]][here[0]] == 1:
			field[here[1]][here[0]] = 0
			result = ds((here[0]-di[0],here[1]-di[1]), lb, ub, field, count)
			field[here[1]][here[0]] = 1
			break
		here = (here[0]+di[0],here[1]+di[1])
	else:
		result = 11
	return result
while 1:
	w, h = list(map(int,input().split(" ")))
	if w == h == 0: break
	board = [[0 for _ in range(w)] for _ in range(h)]
	for j in range(h):
		inp = list(map(int,input().split(" ")))
		for i in range(w):
			tmp = inp[i]
			if tmp == 0: continue
			if tmp == 1: board[j][i] = 1
			elif tmp == 2: start = (i,j)
			else : goal = (i,j)
	count = ds(start, (0,0), (w-1,h-1), board, 0) 
	print(count if count < 11 else -1)
# Original solution
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]


    n = int(lines[0])
    p = [int(e) for e in lines[1].split(' ')]

    return (n, p)


def solve(n, p):


    result = [] 
    current_min = 200000 + 1
    for i in range(n):

        if current_min < p[i]:
            continue 

        current_min = min([current_min, p[i]])

        done = False
        for j in range(i+1):
            if p[i] <= p[j]:
                if j == i:
                    done = True
            else:
                break
        if done:
            result.append(i)


    return len(result)


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        print("%d %d" % (result[0], result[1]))
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()


# Optimized solution
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]


    n = int(lines[0])
    p = [int(e) for e in lines[1].split(' ')]

    return (n, p)


def solve(n, p):


    result = [] 
    current_min = 200000 + 1
    current_min_index = None
    for i in range(n):

        if current_min < p[i]:
            pass
        else:
           current_min = p[i]
           current_min_index = i

        done = False
        for j in range(current_min_index, i+1):
            if p[i] <= p[j]:
                if j == i:
                    done = True
            else:
                break
        if done:
            result.append(i)


    return len(result)


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        print("%d %d" % (result[0], result[1]))
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
# Original solution
N = int(eval(input()))
P = list(map(int, input().split()))

rui = [None] * (N)
rui[0] = P[0]
# print(rui)

for i in range(1, N):
    a = rui[i-1]
    b = P[i]
    rui[i] = min(a, b)


c = 0
for i in range(N):
    if P[i] <= rui[i]:
        c += 1
print(c)

# Optimized solution
N = int(eval(input()))
P = list(map(int, input().split()))

mn = N+1
c = 0
for pi in P:
    if pi <= mn:
        c += 1
        mn = pi

print(c)
# Original solution
N = int(eval(input()))
P = list(map(int, input().split()))

count = 0
isBigger = True

for i in range(len(P)):
	for j in range(i):
		isBigger = True
		if not (P[i] <= P[j]):
			isBigger = False
			break
	if isBigger:
		count += 1

print(count)

# Optimized solution
N = int(eval(input()))
P = list(map(int, input().split()))

count = 0
min_value = 2e5+1

for p in P:
	if p <= min_value:
		min_value = p
		count += 1

print(count)
# Original solution
n = int(eval(input()))
data = [int(x) for x in input().split()]

total = 0
for i in range(n):
    if min(data[:(i+1)]) == data[i]:
        total += 1

print(total)

# Optimized solution
n = int(eval(input()))
data = [int(x) for x in input().split()]

min_num = data[0]
ans = 0
for i in range(n):
    if min_num >= data[i]:
        ans += 1
        min_num = data[i]

print(ans)
# Original solution
N = int(eval(input()))
a = input().rstrip().split()
ans = 0
p = [0]*N
for i in range(N):
  p[i] = int(a[i])
for i in range(N):
  if i == 0:
    ans += 1
  else:
    Plus = True
    for i2 in range(i):
      if p[i2] <= p[i]:
        Plus = False
    if Plus == True:
      ans += 1
print(ans)


# Optimized solution
N = int(eval(input()))
a = input().rstrip().split()
P = [0] * N
for i in range(N):
  P[i] = int(a[i])
minP = P[0]
ans = 1
for i in range(N - 1):
  if minP >= P[i + 1]:
    ans += 1
    minP = P[i + 1]
print(ans)
# Original solution
N = int(eval(input()))
P = list(map(int,input().split()))

count=0
for i in range(N):
    A=P[i]
    if min(P[0:i+1])==A:
        count += 1
    else:
        continue
print(count)

# Optimized solution
N = int(eval(input()))
P = list(map(int,input().split()))

count=0
mi=P[0]  #minimum

for i in range(N):
    A=P[i]
    if A<=mi:
        mi=A
        count+=1
    else:
        continue

print(count)
# Original solution
n = int(eval(input()))
p = list(map(int,input().split()))
pp = list()
pp.append(p[0])
cnt=1
for i in range(1,n):
    min_pp = min(pp)
    if p[i] <= min_pp:
        cnt +=1
    pp.append(p[i])
print(cnt)

# Optimized solution
n = int(eval(input()))
p = list(map(int,input().split()))
min_p = p[0]
cnt=1
for i in range(1,n):
    if p[i] <= min_p:
        min_p = p[i]
        cnt +=1
print(cnt)
# Original solution
N = int(eval(input()))
P = list(map(int, input().split()))
ans = 0
for i in range(N):
    if P[i] <= min(P[:(i+1)]):
        ans += 1
print(ans)

# Optimized solution
N = int(eval(input()))
P = list(map(int, input().split()))
min = float('inf')
ans = 0
for i in range(N):
    if P[i] <= min:
        min = P[i]
        ans += 1
    # if P[i] <= min(P[:(i+1)]):
    #     ans += 1
print(ans)
# Original solution
n = int(eval(input()))
ps = list(map(int,input().split()))
count = 1
x = ps[0]
for i in range(1,len(ps)):
    if x>ps[i]:
        x = ps[i]
        mi = min(ps[0:i])
        if mi>ps[i]:
            count += 1
print(count)

# Optimized solution
n = int(eval(input()))
ps = list(map(int,input().split()))
count = 1
mi = ps[0]
for i in range(1,len(ps)):
    if mi>=ps[i]:
        mi = ps[i]
        count += 1
print(count)
# Original solution
#!/usr/bin/env python
# -*- coding: utf-8 -*-

n = int(eval(input()))
pn = list(map(int, input().split()))


def checkAllLess(tgt):
    for id in range(tgt):
        # print("id=" + str(id) + ", pn[]=" + str(pn[id]) + ", tgt=" + str(tgt))
        if(pn[id] < pn[tgt]):
            # print('False')
            return False
    # print('True')
    return True


cnt = 1
min = pn[0]
for i in range(n):
    if (min > pn[i] and checkAllLess(i)):
        cnt += 1
    if (min > pn[i]):
        min = pn[i]
    # print(str(i) + ":" + str(cnt))

print(cnt)


# Optimized solution
#!/usr/bin/env python
# -*- coding: utf-8 -*-

n = int(eval(input()))
pn = list(map(int, input().split()))

cnt = 1
min = pn[0]
for i in range(1, n):
    if min > pn[i]:
        cnt += 1
        min = pn[i]

print(cnt)
# Original solution
n=int(eval(input()))
p=list(map(int,input().split()))
c=0
for i in range(n):
    lFlag=True
    for j in range(i):
        if (p[i]>p[j]):
            lFlag=False
            break
    if lFlag:
        c=c+1
print(c)


# Optimized solution
n=int(eval(input()))
p=list(map(int,input().split()))
c=0
min=2*10**5
for i in range(n):
    if (p[i]<=min):
        c=c+1
    if p[i]<min:
        min=p[i]
print(c)
# Original solution
N = int(eval(input()))
Ps = list(map(int, input().split()))

answer = 0
for i in range(N):
    if min(Ps[:i + 1]) >= Ps[i]:
        answer = answer + 1

print(answer)

# Optimized solution
N = int(eval(input()))
Ps = list(map(int, input().split()))

answer = 0
min_num = 2 * 10 ** 5 + 1
for p in Ps:
    min_num = min(p, min_num)
    if min_num >= p:
        answer = answer + 1

print(answer)
# Original solution
n=int(eval(input()))
p=list(map(int, input().split()))
count2=0
for i in range(n):
  count1=0
  for j in range(i+1):
    if p[i] <= p[j]:
      count1 += 1
  if count1 == i+1:
    count2 += 1
print(count2)

# Optimized solution
n=int(eval(input()))
p=list(map(int, input().split()))
min = p[0]
count=0
for i in range(n):
  if p[i] <= min:
    min = p[i]
    count += 1
print(count)
# Original solution
import sys

N = int(sys.stdin.readline())
P = list(map(int, sys.stdin.readline().split()))

count = 0
max = P[0]
for i in range(N):
    if P[i] > max:
        max = P[i]
    else:
        for j in range(i+1):
            if P[i] > P[j]:
                break
        else:
            count += 1
            
print(count)

# Optimized solution
import sys

N = int(sys.stdin.readline())
P = list(map(int, sys.stdin.readline().split()))

count = 0
min = P[0]
for i in range(N):
    if P[i] <= min:
        min = P[i]
        count += 1
    """
    else:
        for j in range(i+1):
            if P[i] > P[j]:
                break
        else:
            count += 1
    """
print(count)
# Original solution
n = int(eval(input()))
ls = list(map(int, input().split()))

ans = 0
for i in range(n):
  if(ls[i] == min(ls[:i+1])):
    ans += 1

print(ans)

# Optimized solution
n   = int(eval(input()))
p = list(map(int, input().split()))

# 初期化
cnt = 1
min = p[0]
# カウント処理
for i in range(1, n):
  if(p[i] <= min):
    cnt += 1
    min = p[i]

print(cnt)
# Original solution
N = int(eval(input()))
P = list(map(int, input().split()))

cnt = 1

for i in range(1, N):
  if P[i] == min(P[:i+1]):
    cnt += 1
print(cnt)

# Optimized solution
N = int(eval(input()))
P = list(map(int, input().split()))
min_p = P[0]
cnt = 0

for p in P:
  if p <= min_p:
    min_p = p
    cnt += 1

print(cnt)
# Original solution
#https://atcoder.jp/contests/abc152/tasks/abc152_c
# -*- coding: utf-8 -*-
N = int(eval(input()))
P = input().split()
T = []
L =0

T.insert(0,int(P[0]))
P[0] = int(P[0])
for i in  range(1,len(P)):
  P[i] = int(P[i])
  if min(T)>=P[i]:
    L =+ 1
    T.append(P[i])
print((len(T)))

# Optimized solution
#https://atcoder.jp/contests/abc152/tasks/abc152_c
# -*- coding: utf-8 -*-
N = int(eval(input()))
P = input().split()
T = []
L =0
T.insert(0,int(P[0]))
P[0] = int(P[0])
for i in  range(1,len(P)):
  P[i] = int(P[i])
  if T[-1]>=P[i]:
    L =+ 1
    if T[-1]>P[i]:
      T.append(P[i])
print((len(T)))
# Original solution
def main():
    n = int(eval(input()))
    ps = list(map(int, input().split()))
    li = []
    ans = 0
    for i in ps:
        li.append(i)
        if sorted(li)[0] >= i:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


# Optimized solution
def main():
    n = int(eval(input()))
    ps = list(map(int, input().split()))
    ans = 0
    minp = float("inf")
    for p in ps:
        minp = min(minp, p)
        if minp >= p:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()
# Original solution
def main():
    N = int(eval(input()))
    P = list(map(int, input().split()))

    ans = 0
    for i in range(N):
        for j in reversed(list(range(0, i))):
            if P[j] < P[i]:
                break
        else:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()

# Optimized solution
def main():
    N = int(eval(input()))
    P = list(map(int, input().split()))

    ans = 1
    m = P[0]
    for i in range(1, N):
        if P[i] > m:
            continue
        m = min(m, P[i])
        ans += 1
    print(ans)


if __name__ == '__main__':
    main()
# Original solution
n = int(eval(input()))
ps  = [int(elem) for elem in input().split()]

res = []
for i, p in enumerate(ps):
  if ps[:i] == []:
    res.append(p)
  else:
    if res[-1] > p:
      res.append(p)
print((len(res)))

# Optimized solution
n = int(eval(input()))
ps  = [int(elem) for elem in input().split()]

cnt = 0
for i, p in enumerate(ps):
  if i == 0:
    last = p
    cnt += 1
  else:
    if last > p:
      last = p
      cnt += 1
print(cnt)
# Original solution
def main():
  N=int(eval(input()))
  P=list(map(int,input().split()))
  sumCount=1
  for i in range(1,N):
    if(P[i]<=min(P[0:i+1])):
      sumCount=sumCount+1
  print(sumCount)
if __name__ == '__main__':
  main()

# Optimized solution
n = int(eval(input()))
p = list(map(int, input().split()))

num = p[0]
ans = 1

for i in range(1, n):
    if num >= p[i]:
        ans += 1
        num = p[i]

print(ans)
# Original solution
N=int(eval(input()))
a=list(map(int,input().split()))
b=1
for i in range(N-1):
	if min(a[:i+2])==a[i+1]:
		b+=1
print(b)

# Optimized solution
N=int(eval(input()))
a=list(map(int,input().split()))
b=1
c=a[0]
for i in range(N-1):
	if c>a[i+1]:
		b+=1
		c=a[i+1]
print(b)
# Original solution
N, *P = list(map(int, open(0).read().split()))

min_v = 10 ** 6
max_v = 0
ans = 0
for i in range(N):
    if P[i] < min_v:
        ans += 1
        min_v = P[i]
    elif P[i] > max_v:
        max_v = P[i]
        
print(ans)


# Optimized solution

N = int(eval(input()))
X = list(map(int, input().split()))

ans = 0
cur = 10 ** 6
for i in range(N):
    if X[i] <= cur:
        ans += 1
    cur = min(cur, X[i])

print(ans)
# Original solution
n = int(eval(input()))
p = list(map(int, input().split()))
cnt = 1
for _ in range(1,n):
    for j in range(_):
        if p[_] <= p[j]:
            if _ == j+1:
                cnt += 1
        else:
            break
print(cnt)

# Optimized solution
n = int(eval(input()))
p = list(map(int, input().split()))
cnt = 0
for _ in p:  #p[i]よりも小さいものが出てきたらだめ
    if _ <= n:
        cnt += 1
        n = _
print(cnt)
# Original solution
N = int(eval(input()))
p = list(map(int, input().split()))

cnt = 1
if len(p) >= 2 and p[0] >= p[1]:
  cnt += 1

for i in range(2, N):
  if min(p[:i+1]) == p[i]:
    cnt += 1
  else:
    continue

print(cnt)


# Optimized solution
N = int(eval(input()))
p = list(map(int, input().split()))

cnt = 1
mi = p[0]

for i in range(N):
  if mi > p[i]:
    mi = p[i]
    cnt += 1


print(cnt)
# Original solution
n = int(eval(input()))
lis = list(map(int, input().split()))
count = 0
minn = lis[0]
flug = 0
for i in range(n):
    if flug == 0:
        newlis = lis[0:i+1]
        if  minn >= lis[i]:
            count += 1
            minn = lis[i]
            if minn == 1:
                count += lis[i+1:].count(1)
                flug = 1
print(count)

# Optimized solution
n = int(eval(input()))
lis = list(map(int, input().split()))
count = 0
minn = lis[0]
minl = min(lis)
flug = 0
for i in range(n):
    if flug == 0:
        if  minn >= lis[i]:
            count += 1
            minn = lis[i]
            if minn == minl:
                count += lis[i+1:].count(minl)
                flug = 1
print(count)
# Original solution
N=int(eval(input()))
P=list(map(int, input().split()))

ans=0
for i in range(N):
  flag=True
  for j in range(i):
    if P[i]>P[j]:
      flag=False
      break
  if flag:
    ans+=1
print(ans)

# Optimized solution
N=int(eval(input()))
P=list(map(int, input().split()))

ans=1
mi=P[0]
for i in range(1,N):
  if P[i]<=mi:
    ans+=1
    mi=P[i]
print(ans)
# Original solution
N = int(eval(input()))
P = list(map(int, input().split()))

count = 0
for i in range(N):
  if all(list([x >= P[i] for x in P[:i]])):
  	count += 1
print(count)


# Optimized solution
N = int(eval(input()))
P = list(map(int, input().split()))

count = 0
m = P[0]
for i in range(N):
  if (m >= P[i]):
    count += 1
    m = P[i]
print(count)
# Original solution
n = int(eval(input()))
p = list(map(int,input().split()))
l = [2*10**5]
cnt=0
if n == 1:
  print((1))
else:
  for i in range(n-1):
    l.append(p[i])
    m = min(l)
    if m > p[i+1]:
      #print(p[i+1])
      cnt+=1
  print((cnt+1))

# Optimized solution
n = int(eval(input()))
p = list(map(int,input().split()))
m = 2*10**5
cnt=0
if n == 1:
  print((1))
else:
  for i in range(n-1):
    if m > p[i]:
      m = p[i]
    if m > p[i+1]:
      #print(p[i+1])
      cnt+=1
  print((cnt+1))
# Original solution
n = int(eval(input()))
p = list(map(int, input().split())) 
count=0
for i in range(len(p)):
    if min(p[:(1+i)])==p[i]:
      count+=1
print(count)

# Optimized solution
n = int(eval(input()))
p = list(map(int, input().split())) 
count=0
minmin=100000000
for i in range(len(p)):
  if p[i]<minmin:
    count+=1
    minmin=p[i]
print(count)
# Original solution
n=int(eval(input()))
p=list(map(int,input().split()))

cnt=0
for i in range(1,n):
    if min(p[0:i])<p[i]:
            cnt+=1
print((n-cnt))

# Optimized solution
n=int(eval(input()))
p=list(map(int,input().split()))

a=p[0]
cnt=1
for i in range(1,n):
    if a>=p[i]:
        cnt+=1
        a=p[i]

print(cnt)
# Original solution
N=int(eval(input()))
P=list(map(int,input().split()))
count=0
flag=True
for i in range(N):
    for k in range(1):
        l=min(P[:i+1])
        if P[i]>l:
            flag=False
            break
    if flag:
        count+=1
    else:
        flag=True
print(count)

# Optimized solution
N=int(eval(input()))
P=list(map(int,input().split()))
count=1
min=P[0]
for i in range(1,N):
    if min>P[i]:
      count+=1
      min=P[i]
print(count)
# Original solution
N = int(eval(input()))
nos = list(map(int, input().split()))
count = 1
for j in range(1,N):
  if min(nos[0:j+1]) == nos[j]:
    count += 1
print(count)

# Optimized solution
N = int(eval(input()))
nos = list(map(int, input().split()))
count = 1
min = nos[0]
for j in range(1,N):
  if nos[j] <= min:
    count += 1
    min = nos[j]
print(count)
# Original solution
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n, *a = list(map(int, read().split()))

    r = 0
    for i1 in range(n):
        r += min(a[:i1+1]) >= a[i1]

    print(r)

if __name__ == '__main__':
    main()


# Optimized solution
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n, *a = list(map(int, read().split()))

    r = 0
    minp = a[0]
    for i1 in range(n):
        if minp >= a[i1]:
            r += 1
            minp = a[i1]

    print(r)

if __name__ == '__main__':
    main()
# Original solution
n=int(eval(input()))
p =list(map(int,input().split()))

c=0
for i in range(n):
  s=p[0:i+1]
  s.sort()
  if s[0]==p[i]:
    c=c+1
    
print(c)

# Optimized solution
n=int(eval(input()))
p =list(map(int,input().split()))

c=0
mini=p[0]
for i in range(n):
  if mini>=p[i]:
    c=c+1
    mini=p[i]
    
print(c)