#include #include #include using namespace std; inline long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; } int main() { long long n; cin >> n; vector a(3); for (int &ai: a) cin >> ai; long long ans = 0; for (int mask = 1; mask < 1 << 3; mask++) { long long _lcm = 1; for (int i = 0; i < 3; i++) if (mask >> i & 1) _lcm = lcm(_lcm, a[i]); if (__builtin_parity(mask)) { ans += n / _lcm; } else { ans -= n / _lcm; } } cout << ans << endl; return 0; }