def gcd(a,b): while b!=0: a,b=b,a%b return a def lcm(a,b): return a*b//gcd(a,b) m=int(input()) a,b,c=sorted(list(map(int, input().split()))) s=0 s+=int(m/a) s+=int(m/b) s+=int(m/c) lcmbc=lcm(b,c) s-=int(m/lcm(a,b)) s-=int(m/lcm(a,c)) s-=int(m/lcmbc) s+=int( m/( lcm(a,lcmbc) )) print(s)