#include "bits/stdc++.h" using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a%b); } long long lcm(long long a, long long b) { long long g = gcd(a, b); return a / g * b; } int main() { long long n, a, b, c; cin >> n >> a >> b >> c; cout << n / a + n / b + n / c - n / lcm(a, b) - n / lcm(a, c) - n / lcm(b, c) + n / lcm(a, lcm(b, c)) << endl; }