#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<ll> VL; typedef vector<VL> VVL; typedef pair<int, int> PII; #define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i) #define REP(i, n) FOR(i, 0, n) #define ALL(x) x.begin(), x.end() #define MOD 1000000007 #define INF (1LL<<25) //33554432 #define PI 3.14159265359 #define EPS 1e-12 #define int ll signed main(void) { int n, a, b, c; cin >> n >> a >> b >> c; bool bb = true, cc = true; if(b%a == 0) bb = false; if(c%a == 0) cc = false; if(c%b == 0) cc = false; if(bb && cc) { int t1 = a, t2 = b, t3 = b, t4 = c, t5 = a, t6 = c; while(t1 != 0) {int tmp = t1; t1 = t2 % t1; t2 = tmp;} while(t3 != 0) {int tmp = t3; t3 = t4 % t3; t4 = tmp;} while(t5 != 0) {int tmp = t5; t5 = t6 % t5; t6 = tmp;} int tt = a*b/t2, t7 = min(tt, c), t8 = max(tt, c); while(t7 != 0) {int tmp = t7; t7 = t8 % t7; t8 = tmp;} //cout << t2 << " " << t4 << " " << t6 << " " << t8 << endl; //cout << n/a << " " << n/b << " " << n/c << endl; //cout << n/(a*b/t2) << " " << (n/t4)/((b/t4)*(c/t4)) << " " << (n/t6)/((c/t6)*(a/t6)) << " " << (n/t8)/((a/t8)*(b/t8)*(c/t8)) << endl; cout << n/a + n/b + n/c - n/(a*b/t2) - n/(b*c/t4) - n/(c*a/t6) + n/(tt*c/t8) << endl; } else if(bb && !cc) { int t1 = a, t2 = b; while(t1 != 0) {int tmp = t1; t1 = t2 % t1; t2 = tmp;} n /= t2; a /= t2; b /= t2; cout << n/a + n/b - n/(a*b) << endl; } else if(!bb && cc) { int t1 = a, t2 = c; while(t1 != 0) {int tmp = t1; t1 = t2 % t1; t2 = tmp;} n /= t2; a /= t2; c /= t2; cout << n/a + n/c - n/(a*c) << endl; } else if(!bb && !cc) { cout << n/a << endl; } else { assert(false); } return 0; }