#include #include using namespace std; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } long long lcm(long long a, long long b) { return a / gcd(a, b) * b; } int main() { long long n, a, b, c; cin >> n >> a >> b >> c; long long ans = n / a + n / b + n / c; ans -= n / lcm(a, b) + n / lcm(b, c) + n / lcm(c, a); ans += n / lcm(a, lcm(b, c)); cout << ans << endl; return 0; }