#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; } int main() { cin >> n >> a >> b >> c; ll A = n / a; ll B = n / b; ll C = n / c; ll AB = n / ((a*b) / gcd(a, b)); ll BC = n / ((c*b) / gcd(c, b)); ll CA = n / ((a*c) / gcd(a, c)); ll ABC = n / ((a*b*c)/(gcd((a*b) / gcd(a, b), c))); ll ans = A + B + C - AB - BC - CA + ABC; printf("%lld\n",ans); return 0; }