#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define FOR(I,A,B) for(int I = (A); I < (B); ++I) typedef long long ll; //最大公約数 ll gcd(ll a, ll b) { while (a && b) { if (a >= b) a %= b; else b %= a; } return a + b; } //最小公倍数 ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b;} int main() { ll N,a,b,c; cin>>N>>a>>b>>c; ll ans = 0; ans += N / a + N / b + N / c; ans -= N / lcm(a, b); ans -= N / lcm(b, c); ans -= N / lcm(c, a); ans += N / lcm(lcm(a,b),c); cout << ans << endl; return 0; }