N=input() (A,B,C)=map(int,raw_input().split()) def g(p,q):return p if q==0 else g(q,p%q) def l(p,q):return p/g(p,q)*q print N/A+N/B+N/C-N/l(A,B)-N/l(B,C)-N/l(C,A)+N/l(l(A,B),C)