#include // clang-format off #include using namespace std; using namespace atcoder; #define rep(i,n) for(int i=0;i<(n);i++) templateinline bool chmax(T &a,const S &b) {return (ainline bool chmin(T &a,const S &b) {return (a>b? a=b,1:0);} templateinline T floor(T a,S b) {if(b<0)a=-a,b=-b;return a>=0?a/b:(a+1)/b-1;} templateinline T ceil(T a,S b) {if(b<0)a=-a,b=-b;return a>0?(a-1)/b+1:a/b;} constexpr int dx[8]={1,0,-1,0,1,-1,1,-1},dy[8]={0,1,0,-1,1,-1,-1,1}; using ll = long long; // clang-format on #ifdef LOCAL #include #else #define debug(...) static_cast(0) #endif 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() { ios::sync_with_stdio(false); cin.tie(nullptr); ll n; cin >> n; vector A(3); rep(i, 3) cin >> A[i]; ll ans = 0; rep(bit, 1 << 3) { if (bit == 0) continue; ll x = 1; rep(i, 3) { if (bit >> i & 1) x = lcm(x, A[i]); } if (__builtin_popcount(bit) % 2) ans += n / x; else ans -= n / x; } cout << ans << '\n'; return 0; }