import sys
#sys.stdin = open("a.in","r")
#sys.stdout = open("a.out","w")
s = int(input())
cnt = 0
b = int(input())
m = int(input())
n = int(input())
u = int(input())
for i in range(sn):
    if (m>b) or (n>m and n<b) or (u>n and u<m):
        cnt = cnt + 1
    elif n>b or (u>m and u<b):
        cnt = cnt + 2
    else:
        cnt = cnt + 3
print(cnt)
#sys.stdin.close()
#sys.stdin.close()