#include #include #include #include #include #include #include #include #include #include #include typedef long long ll; typedef unsigned int uint; using namespace std; ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; } int main() { ll n, a, b, c; cin >> n >> a >> b >> c; ll ret = n/a + n/b + n/c; ret -= n / lcm(a, b) + n / lcm(b, c) + n / lcm(c, a); ret += n / lcm(a, lcm(b, c)); cout << ret << "\n"; return 0; }