#include long int yakusu(int a,int b){ long int c; c = b%a; while(c!=0){ b = a; a = c; c = b%a; } return a; } int main(void){ long long int n,ans; long long int a,b,c; long long int abbaisu; scanf("%lld%lld%lld%lld",&n,&a,&b,&c); abbaisu = a*b/yakusu(a,b); ans = n/a + n/b + n/c - (n/(a*b/yakusu(a,b)) + n/(b*c/yakusu(b,c)) + n/(a*c/yakusu(a,c))) + n/(abbaisu*c/yakusu(abbaisu,c)); printf("%lld\n",ans); return 0; }