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

#C - Stones
#黒い石のすぐ右に白い石があるような箇所がないようにしたいです。 

n = int(input())
state = input()
state_list = list(state)
state_list.append(" ")

#specify the locate causing problem
prob_locate = []
prob_num = 0
for i in range(n):
	if state_list[i] == "#" and state_list[i+1] == ".":
		prob_locate.append(i)
		prob_num += 1
if prob_num == 0:
		print(0)
		exit()

#finding optimal position
import random
while prob_num > 0:
	for i in prob_locate:
		r_0 = random.randint(0,1)
		r_1 = random.randint(0,1)
		state_list[(i + r_0)] = ["#", "."][r_1]
	prob_locate = []
	prob_num = 0
	for i in range(n):
		if state_list[i] == "#" and state_list[i+1] == ".":
			prob_locate.append(i)
			prob_num += 1

#checking the difference
state_list.remove(" ")
diff = 0
for i, j in zip(state_list, list(state)):
	if i != j: diff += 1

print(diff)
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		

### FIXED CODE ###

#毎回関数を呼ぶとおそくなる
n = int(input())
stones = input()
score = stones.count(".")
r = score
for i in range(n):
	if stones[i] == ".":
		r -= 1
	else:
		r += 1
	score = min(r, score)
print(score)
### BUGGY CODE ###

N = int(input())
P = [i%(i+1) for i in range(1,N)]
print(sum(P))

### FIXED CODE ###

N = int(input())
N = N-1
ans = N*(N+1)//2
print(int(ans))
### BUGGY CODE ###

from collections import namedtuple
Card = namedtuple('Card', 'suit value')

def partition(A,p,r):
    x = A[r]
    i = p
    for j in range(p,r):
        if A[j].value <= x.value:
            A[i],A[j] = A[j],A[i]
            i += 1
    A[i],A[r] = A[r],A[i]
    return i

def quickSort(A,p,r):
    if p < r:
        q = partition(A,p,r)
        quickSort(A,p,q-1)
        quickSort(A,q+1,r)

def checkStable(C0, C1):
    result = True
    num = {}
    for c in C0: num[c.value] = c.value
    for i in num.keys():
        f0 = [x.suit for x in list(filter(lambda c: c.value==i,C0))]
        f1 = [x.suit for x in list(filter(lambda c: c.value==i,C1))]
        if f0!=f1:
            result = False
    return result

if __name__=='__main__':
    n = int(input()) 
    Co = list(map(lambda X: Card(X[0],int(X[1])), [input().split() for _ in range(n)]))
    Cs = Co[:]
    quickSort(Cs,0,n-1)
    print("Stable" if checkStable(Co,Cs) else "Not stable")
    for c in Cs: print(c.suit,c.value)

### FIXED CODE ###

from collections import namedtuple
Card = namedtuple('Card', 'suit value')

def partition(A,p,r):
    x = A[r]
    i = p
    for j in range(p,r):
        if A[j].value <= x.value:
            A[i],A[j] = A[j],A[i]
            i += 1
    A[i],A[r] = A[r],A[i]
    return i

def quickSort(A,p,r):
    if p < r:
        q = partition(A,p,r)
        quickSort(A,p,q-1)
        quickSort(A,q+1,r)

def isStable(Co,Cs):
    C = Cs[:]
    for ci in Co:
        j = C.index(ci)
        if j > 0:
            if Cs[j-1].value == ci.value:
                return False
        del C[j]
    return True

if __name__=='__main__':
    n = int(input()) 
    Co = list(map(lambda X: Card(X[0],int(X[1])), [input().split() for _ in range(n)]))
    Cs = Co[:]
    quickSort(Cs,0,n-1)
    print("Stable" if isStable(Co,Cs) else "Not stable")
    for c in Cs: print(c.suit,c.value)
### BUGGY CODE ###

n = int(input())

# i = format(n, 'b')[::-1].find('1')
i = 0
while True:
  n //=2
  i += 1
  if n == 1:
    break


ans = 0
for j in range(i+1):
  ans += 2**j

print(ans)

### FIXED CODE ###

n = int(input())

# i = format(n, 'b')[::-1].find('1')
ans = 0
k = 1
while True:
  n //=2
  ans += k
  k *= 2
  if n == 1:
    print(ans+k)
    break
  elif n < 1:
    print(ans)
    break
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))

ans = 1
for i in A:
    ans *= i

if 10 ** 18 < ans:
    print("-1")
else:
    print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))

if 0 in A:
    print(0)
    exit()

ans = 1
for i in A:
    ans *= i
    if 10 ** 18 < ans:
        print("-1")
        exit()

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

n = int(input())
dictionary = {}
for i in range(n) :
    new_word = input()
    if new_word in dictionary.keys() :
        dictionary[new_word] += 1
    else :
        dictionary[new_word] = 1

max_word_list = [k for k, v in dictionary.items() if v == max(dictionary.values())]

max_word_list.sort()

for word in max_word_list :
    print(word)

### FIXED CODE ###

n = int(input())
dictionary = {}
for i in range(n) :
    new_word = input()
    if new_word in dictionary.keys() :
        dictionary[new_word] += 1
    else :
        dictionary[new_word] = 1

max_val = max(dictionary.values())
keys_of_max_val = [key for key in dictionary if dictionary[key] == max_val]

keys_of_max_val.sort()

for word in keys_of_max_val :
    print(word)
### BUGGY CODE ###

def main():
    import heapq
    def root(index):
        if tree[index][0]==index:
            return index
        else:
            tree[index][0]=root(tree[index][0])
            return tree[index][0]

    def unite(index1,index2):
        r1=root(index1)
        r2=root(index2)
        if r1!=r2:
            d1,d2=tree[r1][1],tree[r2][1]
            if d1<=d2:
                tree[r1][0]=r2
                tree[r2][1]=max(d1+1,d2)
            else:
                tree[r2][0]=r1
                tree[r1][1]=max(d2+1,d1)

    def same(index1,index2):
        return root(index1)==root(index2)
    
    n=int(input())
    xy=[list(map(int,input().split())) for _ in [0]*n]
    xyz=[xy[i]+[i] for i in range(n)]
    x_sort=sorted(xyz,key=lambda x:x[0])
    y_sort=sorted(xyz,key=lambda x:x[1])
    
    tree=[[i,1] for i in range(n)]#root,depth
    g=[]
    heapq.heapify(g)
    for i in range(n-1):
        heapq.heappush(g,[abs(x_sort[i+1][0]-x_sort[i][0]),x_sort[i][2],x_sort[i+1][2]])
    for i in range(n-1):
        heapq.heappush(g,[abs(y_sort[i+1][1]-y_sort[i][1]),y_sort[i][2],y_sort[i+1][2]])

    cnt=0
    while g:
        d,i,j=heapq.heappop(g)
        if same(i,j)==False:
            cnt+=d
            unite(i,j)
    print(cnt)
main()

### FIXED CODE ###

def main():
    import heapq
    def root(index):
        if tree[index][0]==index:
            return index
        else:
            tree[index][0]=root(tree[index][0])
            return tree[index][0]

    def unite(index1,index2):
        r1=root(index1)
        r2=root(index2)
        if r1!=r2:
            d1,d2=tree[r1][1],tree[r2][1]
            if d1<=d2:
                tree[r1][0]=r2
                tree[r2][1]=max(d1+1,d2)
            else:
                tree[r2][0]=r1
                tree[r1][1]=max(d2+1,d1)

    def same(index1,index2):
        return root(index1)==root(index2)
    
    n=int(input())
    xy=[list(map(int,input().split())) for _ in [0]*n]
    xyz=[xy[i]+[i] for i in range(n)]
    x_sort=sorted(xyz,key=lambda x:x[0])
    y_sort=sorted(xyz,key=lambda x:x[1])
    
    tree=[[i,1] for i in range(n)]#root,depth
    g=[]
    heapq.heapify(g)
    for i in range(n-1):
        heapq.heappush(g,[abs(x_sort[i+1][0]-x_sort[i][0]),x_sort[i][2],x_sort[i+1][2]])
    for i in range(n-1):
        heapq.heappush(g,[abs(y_sort[i+1][1]-y_sort[i][1]),y_sort[i][2],y_sort[i+1][2]])

    cnt=0
    while g:
        d,i,j=heapq.heappop(g)
        if same(i,j)==False:
            cnt+=d
            unite(i,j)
    print(cnt)
main()
### BUGGY CODE ###

k,s=(int(x) for x in input().split())
ans=0
for i in range(k+1):
  for ii in range(k+1):
    for iii in range(k+1):
      if i+ii+iii==s:
        ans+=1
print(ans)

### FIXED CODE ###

k,s=(int(x) for x in input().split())
ans=0
for i in range(k+1):
  for ii in range(k+1):
    if 0<=s-i-ii<=k:
        ans+=1
print(ans)
### BUGGY CODE ###

def dist(r, c):
    return min(r, H - r - 1, c, W - c - 1)

H, W, K = map(int, input().split())
A = [list(input()) for _ in range(H)]

for r in range(H):
    for c in range(W):
        if A[r][c] == 'S':
            sr = r
            sc = c

dxy = [(1, 0), (0, -1), (-1, 0), (0, 1)]
pos = [(sr, sc)]
dic = {(sr, sc): K}
cnt = 0
ans = H * W
while 0 < len(pos):
    r0, c0 = pos[0]
    pos = pos[1:]
    d0 = dist(r0, c0)
    ans = min(ans, (d0 + K - 1) // K + 1)
    m0 = dic[(r0, c0)]
    if 0 < m0:
        m = m0 - 1
        for (dx, dy) in dxy:
            r = r0 + dy
            c = c0 + dx
            d = dist(r, c)
            if 0 <= r < H and 0 <= c < W and A[r][c] != '#' and (r, c) not in dic:
                pos.append((r, c))
                dic[(r, c)] = m

print(ans)

### FIXED CODE ###

def dist(r, c):
    return min(r, H - r - 1, c, W - c - 1)

H, W, K = map(int, input().split())
A = [list(input()) for _ in range(H)]

for r in range(H):
    for c in range(W):
        if A[r][c] == 'S':
            sr = r
            sc = c

dxy = [(1, 0), (0, -1), (-1, 0), (0, 1)]
pos = [(sr, sc)]
dic = {(sr, sc): K}
cnt = 0
ans = H * W
i = 0
while i < len(pos):
    r0, c0 = pos[i]
    d0 = dist(r0, c0)
    ans = min(ans, (d0 + K - 1) // K + 1)
    m0 = dic[(r0, c0)]
    if 0 < m0:
        m = m0 - 1
        for (dx, dy) in dxy:
            r = r0 + dy
            c = c0 + dx
            d = dist(r, c)
            if 0 <= r < H and 0 <= c < W and A[r][c] != '#' and (r, c) not in dic:
                pos.append((r, c))
                dic[(r, c)] = m
    i += 1

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

N,P=list(map(int,input().split()))

ans=1
if N==1:
    ans=P
else:
    for i in range(1,P):
        if P % (i**N)==0:
            ans=i
        elif P < i**N:
            break
print(ans)

### FIXED CODE ###

N,P=list(map(int,input().split()))

ans=1
if N==1:
    ans=P
elif N>10**6:
    pass
else:
    for i in range(1,P):
        if P % (i**N)==0:
            ans=i
        elif P < i**N:
            break
print(ans)
### BUGGY CODE ###

n = int(input())
z = []
pre = 0
for _ in range(n):
    i = int(input())
    if i != pre:
        z.append(i)
    pre = i
n = len(z)
dp = [1] * (n+1)
place = [[] for _ in range(2 * 10 ** 5)]
for i in range(n):
    dp[i+1] = dp[i]
    for p in place[z[i] - 1]:
        dp[i+1] += dp[p]
    place[z[i] - 1].append(i)
    dp[i+1] %= 10 ** 9 + 7
print(dp[n])

### FIXED CODE ###

n = int(input())
z = []
pre = 0
for _ in range(n):
    i = int(input())
    if i != pre:
        z.append(i)
    pre = i
n = len(z)
dp = [1] * (n+1)
dpp = [0] * 2 * 10 ** 5
for i in range(n):
    dp[i+1] = dp[i] + dpp[z[i]-1]
    dpp[z[i]-1] += dp[i]
    dp[i+1] %= 10 ** 9 + 7
print(dp[n])
### BUGGY CODE ###

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

ans = 0
for x in range(N):
  for y in range(x+1,N+1):
    _ = sum(An[x:y])
    if _%M == 0:
      ans += 1

print(ans)

### FIXED CODE ###

import numpy as np
from collections import Counter

N,M = map(int, input().split())
An = [0] + list(map(int, input().split()))
An = np.array(An)

_ = Counter(np.cumsum(An%M) % M)
ans = 0
for i in _.values():
  ans += i*(i-1)//2

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

n=int(input())
s=1
f=0
x=[int(x) for x in input().split()]
if x.count(0)>0:
    print(0)
else:
    for i in range(len(x)):
        s=s*x[i]
    if s>10**18:
        print(-1)
    else:print(s)

### FIXED CODE ###

n=int(input())
s=1
f=0
x=[int(x) for x in input().split()]
if x.count(0)>0:
    print(0)
else:
    for i in range(len(x)):
        s=s*x[i]
        if s>10**18:
            f=1
            break
    if f:
        print(-1)
    else:print(s)
### BUGGY CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))
l = []

for i in range(n-k+1):
    num = 0
    for j in range(k):
        num += p[i+j]
    l.append(num)

print((max(l)+k)/2)


### FIXED CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))
l = []

num = 0
for j in range(k):
    num += p[j]
l.append(num)

for i in range(n-k):
    l.append(l[i]-p[i]+p[i+k])

print((max(l)+k)/2)
### BUGGY CODE ###

def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)

def dp():
    n,=list(map(int,input().split()))
    l=list(map(int,input().split()))
    lcm=1
    for i in l:
        lcm=(lcm*i)//gcd(lcm,i)
    ans=0
    mod=1000000007
    for i in l:
        ans=(ans+(lcm//i))%mod
    print(ans)

if __name__ == "__main__":
    dp()

### FIXED CODE ###

def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)

def Lcm(a,b):
    return (a*b)//gcd(a,b)

def dp():
    n=int(input())
    l=list(map(int,input().split()))
    lcm=l[0]
    for i in range(n):
        lcm=Lcm(lcm,l[i])
    ans=0
    mod=1000000007
    for i in range(n):
        ans+=lcm//l[i]
    print(ans%mod)

if __name__ == "__main__":
    dp()
### BUGGY CODE ###

n, k = map(int, input().strip().split())
h = list(map(int, input().strip().split()))

dp=[10**9]*n

dp[0]=0
for i in range(n):
    # for j in range(1,k+1):
    #     if i+j>n-1:
    #         break
    for j in range(1,min(k+1,n-i)):
        dp[i+j]=min(dp[i+j], dp[i]+abs(h[i+j]-h[i]))
print(dp[-1])

### FIXED CODE ###

n, k = map(int, input().strip().split())
h = list(map(int, input().strip().split()))

dp=[10**9]*n

dp[0]=0
for i in range(n):
    # for j in range(1,k+1):
    #     if i+j>n-1:
    #         break
    for j in range(1,min(k+1,n-i)):
        dp[i+j]=min(dp[i+j], dp[i]+abs(h[i+j]-h[i]))
print(dp[-1])
### BUGGY CODE ###

import numpy as np

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

maze01 = np.array([[int(x=='.') for x in input()] for _ in range(H)]) 

u = np.zeros((H, W), dtype=np.int32)
d = np.zeros((H, W), dtype=np.int32)
r = np.zeros((H, W), dtype=np.int32)
l= np.zeros((H, W), dtype=np.int32)


u[0] = maze01[0]
d[H - 1] = maze01[H - 1]
for hh in range(1,H):
    u[hh] = u[hh-1] + maze01[hh]
    u[hh] = [x * y for x, y in zip(u[hh], maze01[hh])]
    d[H - hh - 1] = d[H - hh] + maze01[H - hh - 1]
    d[H - hh - 1] *= maze01[H - hh - 1]

l[:, 0] = maze01[:, 0]
r[:, W - 1] = maze01[:, W - 1]
for ww in range(1, W):
    l[:, ww] = l[:, ww -1] + maze01[:, ww]
    l[:, ww] *= maze01[:, ww]
    r[:, W - ww -1] = r[:, W - ww] + maze01[:, W - ww - 1]
    r[:, W - ww -1] *= maze01[:, W - ww - 1]

cnt = r + l + u + d - 3

print(max([max(cnt[i]) for i in range(H)]))


### FIXED CODE ###

import numpy as np

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

maze01 = np.array([[int(x=='.') for x in input()] for _ in range(H)]) 

u = np.zeros((H, W), dtype=np.int32)
d = np.zeros((H, W), dtype=np.int32)
r = np.zeros((H, W), dtype=np.int32)
l= np.zeros((H, W), dtype=np.int32)


u[0] = maze01[0]
d[H - 1] = maze01[H - 1]
for hh in range(1,H):
    u[hh] = u[hh-1] + maze01[hh]
    u[hh] *= maze01[hh]
    d[H - hh - 1] = d[H - hh] + maze01[H - hh - 1]
    d[H - hh - 1] *= maze01[H - hh - 1]

l[:, 0] = maze01[:, 0]
r[:, W - 1] = maze01[:, W - 1]
for ww in range(1, W):
    l[:, ww] = l[:, ww -1] + maze01[:, ww]
    l[:, ww] *= maze01[:, ww]
    r[:, W - ww -1] = r[:, W - ww] + maze01[:, W - ww - 1]
    r[:, W - ww -1] *= maze01[:, W - ww - 1]

cnt = r + l + u + d - 3

print(max([max(cnt[i]) for i in range(H)]))
### BUGGY CODE ###

n = int(input())
ans = 1
for i in range(1,n+1):
  ans = ans * i
print(ans%(10**9+7))

### FIXED CODE ###

n = int(input())
ans = 1
for i in range(1,n+1):
  ans = (ans * i)%(10**9+7)
print(ans)
### BUGGY CODE ###

buffer = list(input())
S = [int(n) for n in buffer]
N = len(S)
i = 0
count = 0
while(1):
    if(S == [] or N == 1):
        break
    elif((S[i] + S[i + 1]) == 1):
        S.pop(i)
        S.pop(i)
        i = 0
        count += 2
        N = len(S)
    else:
        i += 1
        if(i == (N - 1)):
            break
print(count)

### FIXED CODE ###

S = list(input())
count_bule = S.count('0')
count_red = S.count('1')
count_min = min(count_bule, count_red)
print(2 * count_min)
### BUGGY CODE ###

import math
#試し割法
def trial_division(n):
    #素因数を格納するリスト
    factor = []
    #2から√n以下の数字で割っていく
    # c = 0
    tmp = math.sqrt(n) + 1
    tmp = int(tmp)
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    #リストが空ならそれは素数
    if not factor:
        return 'prime number'
    else:
        factor.append(n)
        return factor


N = int(input())
A = list(map(int, input().split()))

ans = 0
for i in range(N):
    if A[i] == 2:
        ans += 1
    buff = trial_division(A[i])
    for el in buff:
        if el == 2:
            ans += 1

print(ans)



### FIXED CODE ###

def gu(x):
    counter = 0
    while x % 2 == 0 and x != 0:
        x /= 2
        counter += 1
    return counter


N = int(input())
A = list(map(int, input().split()))

ans = 0
for i in range(N):
    if A[i] % 2 == 0:
        ans += gu(A[i])

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

neighbor = lambda c, w, h: filter(
    lambda b: 0 <= b[0] <= w and 0 <= b[1] <= h,
    [
        (c[0]-1, c[1]),
        (c[0]+1, c[1]),
        (c[0], c[1]-1),
        (c[0], c[1]+1)
    ]
)

t = raw_input()
W, H = map(int, t.split(' '))
p, q = [], []
for i in xrange(W):
    p.append(int(raw_input()))
for j in xrange(H):
    q.append(int(raw_input()))

has = [[False for i in xrange(H+1)] for j in xrange(W+1)]
has[0][0] = True
Next = [(1, 0), (0, 1)]

cost = 0
for i in xrange(W*H+W+H):
    Min = 100000005
    choose = None
    for each in Next:
        if each[0] > 0:
            if p[each[0]-1] < Min:
                choose = each
                Min = p[each[0]-1]
        if each[1] > 0:
            if q[each[1]-1] < Min:
                choose = each
                Min = q[each[1]-1]
    has[choose[0]][choose[1]] = True
    Next.remove(choose)
    cost += Min
    for every in neighbor(choose, W, H):
        # print every
        if not has[every[0]][every[1]] and every not in Next:
            Next.append(every)
print cost

### FIXED CODE ###


import bisect
cost = 0
t = raw_input()
W, H = map(int, t.split(' '))
p, q = [], []
sum_p = []
for i in xrange(W):
    tmp = int(raw_input())
    p.append((i, tmp))
p.sort(key=lambda a: a[1])
pp = [each[1] for each in p]
for i in xrange(W):
    if not sum_p:
        sum_p.append(pp[i])
    else:
        sum_p.append(sum_p[-1]+pp[i])
cost += sum(pp)
for j in xrange(H):
    new = int(raw_input())
    cost += new
    minus = bisect.bisect_right(pp, new)
    cost += (W-minus) * new
    cost += sum_p[minus-1] if minus > 0 else 0

print cost
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def main():
    n, m, l = map(int, input().split())
    inf = 1001001001
    dist = [[inf] * n for _ in range(n)]
    for _ in range(m):
        a, b, c = map(int, input().split())
        a, b = a - 1, b - 1
        dist[a][b] = dist[b][a] = c
    for w in range(n):
        for u in range(n):
            for v in range(n):
                dist[u][v] = min(dist[u][v], dist[u][w] + dist[w][v])
    dist2 = [[inf] * n for _ in range(n)]
    for u in range(n):
        for v in range(n):
            if dist[u][v] <= l: dist2[u][v] = 1
    for w in range(n):
        for u in range(n):
            for v in range(n):
                dist2[u][v] = min(dist2[u][v], dist2[u][w] + dist2[w][v])

    q = int(input())
    for _ in range(q):
        s, t = map(lambda x: int(x) - 1, input().split())
        ans = dist2[s][t]
        if ans == inf:
            print(-1)
        else:
            print(ans - 1)

main()


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def main():
    n, m, l = map(int, input().split())
    inf = 1001001001
    dist = [[inf] * n for _ in range(n)]
    for _ in range(m):
        a, b, c = map(int, input().split())
        a, b = a - 1, b - 1
        dist[a][b] = dist[b][a] = c
    for w in range(n):
        for u in range(n):
            for v in range(n):
                dist[u][v] = min(dist[u][v], dist[u][w] + dist[w][v])
    dist2 = [[inf] * n for _ in range(n)]
    for u in range(n):
        for v in range(n):
            if dist[u][v] <= l: dist2[u][v] = 1
    for w in range(n):
        for u in range(n):
            for v in range(n):
                dist2[u][v] = min(dist2[u][v], dist2[u][w] + dist2[w][v])

    q = int(input())
    for _ in range(q):
        s, t = map(lambda x: int(x) - 1, input().split())
        ans = dist2[s][t]
        if ans == inf:
            print(-1)
        else:
            print(ans - 1)

main()
### BUGGY CODE ###

import math
from fractions import gcd

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

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

  return 1
  
a, b = map(int, input().split())
max_d = gcd(a, b)
ans = 0
for i in range(1, max_d + 1):
  if i > 7 and (i % 2 == 0 or i % 3 == 0 or i % 5 == 0 or i % 7 == 0):
    pass
  else:
    if a % i == 0 and b % i == 0:
      ans += is_prime(i)
    
print(ans)
    


### FIXED CODE ###

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table
  
a, b = map(int, input().split())
la = prime_decomposition(a)
lb = prime_decomposition(b)
la_lb_and = list(set(la) & set(lb))
    
print(len(la_lb_and) + 1)
### BUGGY CODE ###

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 ###

k,s = map(int, input().split())

cnt = 0

for i in range(k+1):
  for j in range(k+1):
    if 0<= s -i -j <= k:
      cnt +=1
print(cnt)
### BUGGY CODE ###

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

for i in range(n):
    print(A.count(i+1))

### FIXED CODE ###

n = int(input())
A = list(map(int,input().split()))
ans = [0]*(n+1)
for i in range(n-1):
    ans[A[i]]+=1

for i in range(1,n+1):
    print(ans[i])
### BUGGY CODE ###

from operator import itemgetter

N = int(input())
finish = [False] * N
As, Bs = [], []
A_,B_ = [],[]
for i in range(N):
    a,b = map(int, input().split())
    As.append((a,b,i))
    Bs.append((b,a,i))

cnt = 0
As.sort(reverse=True)
Bs.sort(reverse=True)

p_a = 0
p_b = 0
while sum(finish)<N:
    # 高橋くんのターン
    while True:
        a,_,i = As.pop()
        if not finish[i]:
            p_a += a
            finish[i] = True
            cnt += 1
            break
    # 青木
    while True and cnt < N:
        b,_,i = Bs.pop()
        if not finish[i]:
            p_b += b
            finish[i] = True
            cnt += 1
            break
    # print(cnt,p_a,p_b)

print(p_a-p_b)


### FIXED CODE ###

N = int(input())
ABs = []
sum_B = 0
for i in range(N):
    a,b = map(int, input().split())
    ABs.append(a+b)
    sum_B += b 
ABs.sort(reverse=True)
ans = sum(ABs[::2])-sum_B
print(ans)
### BUGGY CODE ###

N = int(input())
P = list(map(int, input().split()))

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


### FIXED CODE ###

def main():
  N = int(input())
  P = list(map(int, input().split()))

  ans = 1
  min_val = P[0]
  for i in range(1,N):
    if P[i] < min_val:
      ans += 1
      min_val = P[i]
    if min_val == 1:
      break

  print(ans)

if __name__ == "__main__":
	main()