#include using namespace std; using ll = long long; int main() { ll N, a, b, c; cin >> N >> a >> b >> c; ll A = N / a; ll B = N / b; ll C = N / c; ll AB = N / lcm(a, b); ll BC = N / lcm(b, c); ll CA = N / lcm(c, a); ll ABC = N / lcm(lcm(a, b), c); ll ans = A + B + C - AB - BC - CA + ABC; cout << ans << endl; return 0; }