//https://yukicoder.me/problems/891 #include #include #include #include #include #include #include #include #include #define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++) #define rep(i,n) reps(i,0,n) using namespace std; using ll = long long; using pii = pair; using vi = vector ; using vl = vector; //区間(1,n)においてaの倍数がいくつあるか調べる、 ll count(ll n,ll a){ return n/a; } ll gcd(ll a,ll b){ if(a % b == 0) return b; return gcd(b,a%b); } ll lcm(ll a, ll b){ return a*b/gcd(a,b); } int main(){ ll n; vector a(3); cin >> n; //cin >> a >> b >> c; rep(i,3){ cin >> a[i]; } sort(a.begin(),a.end(),less()); ll ans = 0; ll tmp1,tmp2; if(a[1] % a[0] == 0 && a[2] % a[0] ==0){ ans = count(n,a[0]); }else if(a[1] % a[0] == 0){ tmp1 = count(n,a[0]) + count(n,a[2]); tmp2 = count(n,lcm(a[0],a[2])); ans = tmp1-tmp2; }else if(a[2] % a[0] == 0 || a[2] % a[1] == 0){ tmp1 = count(n,a[0]) + count(n,a[1]); tmp2 = count(n,lcm(a[0],a[1]) ); ans = tmp1-tmp2; }else{ tmp1 = count(n,a[0]) + count(n,a[1]) + count(n,a[2]); tmp2 = count(n,lcm(a[0],a[1]) ) + count(n,lcm(a[1],a[2])) + count(n,lcm(a[0],a[2])); ll tmp3 = lcm(a[0],a[1]); tmp3 = lcm(tmp3,a[2]); ans = tmp1 - tmp2 + count(n,tmp3); } cout << ans << endl; return 0; }