Emuskald is addicted to Codeforces, and keeps refreshing the main page not to miss any changes in the "recent actions" list. He likes to read thread conversations where each thread consists of multiple messages.

Recent actions shows a list of n different threads ordered by the time of the latest message in the thread. When a new message is posted in a thread that thread jumps on the top of the list. No two messages of different threads are ever posted at the same time.

Emuskald has just finished reading all his opened threads and refreshes the main page for some more messages to feed his addiction. He notices that no new threads have appeared in the list and at the i-th place in the list there is a thread that was at the a_{i}-th place before the refresh. He doesn't want to waste any time reading old messages so he wants to open only threads with new messages.

Help Emuskald find out the number of threads that surely have new messages. A thread x surely has a new message if there is no such sequence of thread updates (posting messages) that both conditions hold:   thread x is not updated (it has no new messages);  the list order 1, 2, ..., n changes to a_1, a_2, ..., a_{n}. 


-----Input-----

The first line of input contains an integer n, the number of threads (1 ≤ n ≤ 10^5). The next line contains a list of n space-separated integers a_1, a_2, ..., a_{n} where a_{i} (1 ≤ a_{i} ≤ n) is the old position of the i-th thread in the new list. It is guaranteed that all of the a_{i} are distinct.


-----Output-----

Output a single integer — the number of threads that surely contain a new message.


-----Examples-----
Input
5
5 2 1 3 4

Output
2

Input
3
1 2 3

Output
0

Input
4
4 3 2 1

Output
3



-----Note-----

In the first test case, threads 2 and 5 are placed before the thread 1, so these threads must contain new messages. Threads 1, 3 and 4 may contain no new messages, if only threads 2 and 5 have new messages.

In the second test case, there may be no new messages at all, since the thread order hasn't changed.

In the third test case, only thread 1 can contain no new messages.

Difficulty: interview

Starter code:

Solutions:
n, ar = int(input()), [int(x) for x in input().split()][::-1]
ans = 0
for i in range(1, n):
  if ar[i] > ar[i - 1]: 
    ans = n - i
    break

print(ans)



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

i = n - 1
while t[i] > t[i - 1]: i -= 1
print(i)

__author__ = 'asmn'

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

for i in range(1,len(a)):
    if a[i]>a[i-1]:
        print(len(a)-i)
        break
else:
    print(0)


n=int(input())
temp=0
c=0
a=input().split()
for i in range(0,n):
    if(temp-int(a[i])>0):
        c=i+1
    temp=int(a[i])
if(c!=0):
    print(c-1)
else:
    print(0)


n=int(input())
temp=0
c=0
a=list(map(int,input().split()))
for i in range(0,n):
    if(temp-a[i]>0):
        c=i+1
    temp=a[i]
if(c!=0):
    print(c-1)
else:
    print(0)


n = int(input())
inStr = input()

pos = [int(x) for x in inStr.split()]
min = n
ans = 0
for i in range(n-1, -1, -1):
    if pos[i]>min:
       ans = i+1
       break
    elif pos[i]<min:
        min = pos[i]

print(ans)

n = int(input())
l = [int(x) for x in input().split()]
l.reverse()
for i in range(1, n):
	if l[i] > l[i - 1]:
		print(n - i)
		return
print(0)


input()
t=[int(x) for x in input().split()]
m=[True]+[t[i]>t[i+1] for i in range(len(t)-1)]
print(len(m)-1-list(reversed(m)).index(True))

import re, sys, string, operator, functools, fractions, collections
from random import *
sys.setrecursionlimit(10**7)
dX= [-1, 1, 0, 0,-1, 1,-1, 1]
dY= [ 0, 0,-1, 1, 1,-1,-1, 1]
RI=lambda: list(map(int,input().split()))
RS=lambda: input().rstrip().split()
mod=1e9+7
eps=1e-6
#################################################
n=RI()[0]
a=RI()
ans=1
for i in range(n-1,0,-1):
    if a[i-1]>a[i]:
        break
    ans+=1
print(n-ans)


def main():
    n = int(input())
    aa = list(map(int, input().split()))
    m = aa[-1]
    for i in range(n - 2, -2, -1):
        a = aa[i]
        if m < a:
            break
        m = a
    print(i + 1)


def __starting_point():
    main()

__starting_point()

n=int(input(""))
a=[int(x) for x in input("").split(' ')]
output = 0
cache = 0
for x in range(n-1):
    if a[x] > a[x+1]:
        output+=1+cache
        cache=0
    else:
        cache+=1
print(output)


n = int(input())
a = (str(input())).split(' ')
ma=0
output = 0
for i in range(n-1):
    if int(a[i])<int(a[i+1]):
        ma+=1
    else:
        output+=1+ma
        ma=0
print(output)


n = int(input())
a = [int(x) for x in input().split()]

answer = 0
last = a[-1]
for v in reversed(a):
    if v > last:
        break
    answer += 1
    last = v

print(len(a) - answer)

R=input
I=lambda:map(int,R().split())
n=int(R())
a=list(I())[::-1]+[999999]
for i in range(n):
	if a[i+1]>a[i]:print(n-i-1);break

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

i = n - 1
while t[i] > t[i - 1]: i -= 1
print(i)

n = int(input())

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



i = n - 1

while t[i] > t[i - 1]: i -= 1

print(i)



# Made By Mostafa_Khaled


n=input()
arr=input().split(" ")

asc=1
x=int(arr[0])
for i in range(1,int(n)):
    if int(arr[i])>x:
        asc+=1
    else:
        asc=1
    x=int(arr[i])
print(int(n)-asc)



n = int(input())

a = list(map(int, input().split()))[::-1]
c = 0
for i in range(1, n):
  if a[i] > a[i-1]:
    c = n-i
    break
print(c)


n = int(input())
arr = list(map(int, input().split()))
i = n - 1
while arr[i] > arr[i - 1]: i -= 1
print(i)


n=int(input())
l=[int(i) for i in input().split()]
ans=0 
f=0 
#l.insert0(10000000000000,0)
for i in range(n-1,0,-1):
    if l[i]<l[i-1]:
        print(i)
        f=1 
        break 
if not f:
    print(f)

num = int(input())
arr = list(map(int,input().split()))
i = num-1
while arr[i] > arr[i-1]:
    i -= 1
print(i)


n = int(input())
t = list(map(int , input().split()))
i=n-1
while t[i] > t[i-1] : i=i-1
print (i)

n=int(input())
a=list(map(int,input().split()))
ans=n-1
for i in range(n-1,0,-1):
    if(a[i-1]>a[i]):
        break
    ans-=1
print(ans)



t=int(input())
arr=list(map(int,input().split()))

i=t-1

while( i>0 and arr[i] > arr[i-1] ):
    i-=1
    
print(i)

n = int(input())
arr = list(map(int,input().split()))
ans = n-1
for i in range(-1,-n,-1):
    if arr[i]>arr[i-1]:
        ans-=1
    else:
        break
print(ans)