#include using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (n); i++) #define ALL(x) (x).begin(), (x).end() #define SZ(x) (int)(x).size() ll gcd(ll a, ll b) { return (b == 0 ? a : gcd(b, a % b)); } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } int main() { ll N, a, b, c; cin >> N >> a >> b >> c; ll ans = 0; ans += N / a + N / b + N / c; ans -= N / lcm(a, b) + N / lcm(b, c) + N / lcm(a, c); ans += N / lcm(a, lcm(b, c)); cout << ans << endl; return 0; }