#include <cstdio> #include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #include <map> #include <utility> #include <ctime> #include <set> #include <iostream> #include <memory> #include <string> #include <cstring> #include <vector> #include <algorithm> #include <functional> #include <fstream> #include <sstream> #include <complex> #include <stack> #include <queue> #include <cstring> #include <numeric> #include <cassert> using namespace std; typedef long long ll; #define rep(i,n) for(int i=0;i<n;i++) #define rev(i,n) for(int i=n-1;i>=0;i--) #define all(a) a.begin(),a.end() #define mp(a,b) make_pair(a,b) #define pb(a) push_back(a) #define SS stringstream #define DBG1(a) rep(_X,sz(a)){printf("%d ",a[_X]);}puts(""); #define DBG2(a) rep(_X,sz(a)){rep(_Y,sz(a[_X]))printf("%d ",a[_X][_Y]);puts("");} #define bitcount(b) __builtin_popcount(b) #define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i) #define gcd(a,b) (__gcd(a,b)) #define lcm(a,b) (a/__gcd(a,b)*b) #define lcm3(a,b,c) lcm(lcm(a,b),c) int main(){ long long N; cin >> N; long long a,b,c; cin >> a >> b >> c; cout << N/a+N/b+N/c-N/(lcm(a,b))-N/(lcm(c,b))-N/(lcm(a,c))+N/(lcm3(a,b,c)) << endl; }