#include #define REP(x,y,z) for(int x=y;x<=z;x++) #define FORD(x,y,z) for(int x=y;x>=z;x--) #define MSET(x,y) memset(x,y,sizeof(x)) #define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++) #define F first #define S second #define MP make_pair #define PB push_back #define SZ size() #define M void RI(){} template void RI( int& head, T&... tail ) { scanf("%d",&head); RI(tail...); } using namespace std; typedef long long LL; int n,a,b,c; int main() { RI(n,a,b,c); LL ans = (LL)n/a + n/b + n/c; LL x = (LL)a*b / __gcd(a,b); ans -= n/x; x = (LL)a*c / __gcd(a,c); ans -= n/x; x = (LL)b*c / __gcd(b,c); ans -= n/x; x = x*a / __gcd(x,(LL)a); ans += n/x; printf("%lld\n",ans); return 0; }