a=int(input())
f=[]
b=list(map(int,input().split()[:a]))
c=list(map(int,input().split()))
d=b.index(c[0])
e=b.index(c[1])
if(d<e):
  for i in range(d,e):
    f.append(i)
  print(len(f))
else:
  for i in range(e,d):
    f.append(i)
  print(len(f))

fc8904c224c7011bc2f5f093b15ee78ecbdd1d33
<mask token>

<mask token>
if d < e:
    for i in range(d, e):
        f.append(i)
    print(len(f))
else:
    for i in range(e, d):
        f.append(i)
    print(len(f))

a = int(input())
f = []
b = list(map(int, input().split()[:a]))
c = list(map(int, input().split()))
d = b.index(c[0])
e = b.index(c[1])
if d < e:
    for i in range(d, e):
        f.append(i)
    print(len(f))
else:
    for i in range(e, d):
        f.append(i)
    print(len(f))

a=int(input())
f=[]
b=list(map(int,input().split()[:a]))
c=list(map(int,input().split()))
d=b.index(c[0])
e=b.index(c[1])
if(d<e):
  for i in range(d,e):
    f.append(i)
  print(len(f))
else:
  for i in range(e,d):
    f.append(i)
  print(len(f))
