#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair Pr; ll n, a, b, c; ll gcd(ll a, ll b) { while (b != 0) { a = a % b; swap(a, b); } return a; } ll lcm(ll x, ll y) { return x*y / gcd(x, y); } int main() { cin >> n >> a >> b >> c; ll A = n / a; ll B = n / b; ll C = n / c; ll AB = n / lcm(a,b); ll BC = n / lcm(b,c); ll CA = n / lcm(c,a); ll ABC = n / lcm(lcm(a,b),c); ll ans = A + B + C - AB - BC - CA + ABC; printf("%lld\n",ans); return 0; }