#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(n) begin(n), end(n)
using ll = long long;

ll lcm(ll a, ll b){
    return a/__gcd(a,b) * b;
}

ll solve(ll n, ll *a){
    ll res = 0;
    rep(s,8){
        if(s == 0) continue;
        int sign = __builtin_popcount(s) & 1 ? 1 : -1;
        ll l = 1;
        rep(i,3) if(s >> i & 1) l = lcm(l, a[i]);
        res += sign*(n/l);
    }
    return res;
}

int main(){
    ll n, a[3];
    while(cin >> n){
        rep(i,3) cin >> a[i];
        cout << solve(n,a) - solve(0,a) << endl;
    }
}