#include using namespace std; #if __has_include("atcoder/all") #include using namespace atcoder; #endif #define int long long #define rep1(a) for (int i = 0; i < a; i++) #define rep2(i, a) for (int i = 0; i < a; i++) #define rep3(i, a, b) for (int i = a; i < b; i++) #define rep4(i, a, b, c) for (int i = a; i < b; i += c) #define overload4(a, b, c, d, e, ...) e #define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) #define fore(i, a) for (auto &i : a) #define all(n) n.begin(), n.end() #define pb push_back #define UNIQUE(x) sort(all(x)), x.erase(unique(all(x)), x.end()) #define SIZE(c) (int)(c).size() #ifndef _LOCAL #pragma GCC optimize("-O3") #pragma GCC target("avx2") #pragma GCC optimize("unroll-loops") #endif #define ryes return yes(); #define rno return no(); template pair operator-(const pair &x, const pair &y) { return pair(x.fi - y.fi, x.se - y.se); } template pair operator+(const pair &x, const pair &y) { return pair(x.fi + y.fi, x.se + y.se); } template ostream &operator<<(ostream &os, const pair &p) { os << "(" << p.first << ", " << p.second << ")" << endl; return os; } inline void yes() { cout << "Yes" << endl; } inline void no() { cout << "No" << endl; } inline void yneos(bool f) { if (f) yes(); else no(); } typedef pair pii; typedef vector vi; typedef vector> vvi; /*vector input*/ template istream &operator>>(istream &is, vector &v) { for (auto &e : v) is >> e; return is; } /*---- 出力系 -----*/ // print vector template ostream &operator<<(ostream &os, const vector &v) { for (auto it = begin(v); it != end(v); ++it) { if (it == begin(v)) os << *it; else os << " " << *it; } return os; } // print 2d vector template ostream &operator<<(ostream &os, const vector> &v) { for (auto it = begin(v); it != end(v); ++it) { os << *it; if (it != end(v) - 1) { cout << endl; } } return os; } // chmin template inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); } // chmax template inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); } // bin search template long long bin_search(long long ok, long long ng, const F &f) { while (abs(ok - ng) > 1) { long long mid = (ok + ng) >> 1; (f(mid) ? ok : ng) = mid; } return ok; } /*------ 累積和 ------*/ template inline vector cumulative_sum(vector &A) { vector res; int s = 0; res.pb(0); for (T a : A) { s += a; res.pb(s); } return res; } template inline vector> cumulative_sum_2d(vector> &A) { vector> res; int w = SIZE(A[0]) + 1; res.pb(vector(w, 0)); for (vector &a : A) { res.pb(cumulative_sum(a)); } rep(i, 1, SIZE(res)) { rep(j, w) { res[i][j] += res[i - 1][j]; } } return res; } // vector decrement template vector &operator++(vector &v) { for (auto &e : v) e++; return v; } template vector &operator--(vector &v) { for (auto &e : v) e--; return v; } /* const value */ const int INF = (1 << 30) + (1LL << 60) - 2; const int MOD = 998244353; /* directions */ int dx[] = {1, 0, -1, 0, 1, 1, -1, -1}; int dy[] = {0, 1, 0, -1, -1, 1, 1, -1}; void solve() { /*This is main.*/ int N; cin >> N; int a, b, c; cin >> a >> b >> c; cout << (N / a + N / b + N / c) - N / lcm(a, b) - N / lcm(b, c) - N / lcm(c, a) + (N / lcm(a, lcm(b, c))) << endl; } signed main(void) { std::cin.tie(0)->sync_with_stdio(0); cout << fixed << setprecision(15); int T = 1; // cin>>T; rep(T) solve(); return 0; }