#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; int gcd(int a, int 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; cout << ans << endl; return 0; }