#include #define rep(i, p, n) for (ll i = p; i < (ll)(n); i++) #define rep2(i, p, n) for(ll i = p; i >= (ll)(n); i-- ) using namespace std; using ll = long long; double pi=3.141592653589793; const long long inf=2*1e9; const long long linf=8*1e18; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } //atcoder #include #include using namespace atcoder; using mint1 = modint1000000007; using mint2 = modint998244353; int main() { ll N, A, B, C; cin >> N >> A >> B >> C; ll ans=0; ans+=N/A; ans+=N/B; ans+=N/C; ll D=B*C/gcd(B, C); ans-=N/D; D=B*A/gcd(B, A); ans-=N/D; D=A*C/gcd(A, C); ans-=N/D; D=D*B/gcd(B, D); ans+=N/D; cout << ans; }