#include using namespace std; using i64 = long long; #define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++) #define all(x) x.begin(),x.end() i64 gcd(i64 a,i64 b){ if(b == 0) return a; return gcd(b,a % b); } int main(){ i64 n,m; cin >> n; m = 3; vector a(m); rep(i,0,m - 1) cin >> a[i]; i64 res = 0; for(int i = 1;i < (1 << m);i++){ i64 LCM = 1; for(int j = 0;j < m;j++){ if(i & (1 << j)){ LCM = LCM / gcd(LCM , a[j]) * a[j]; } if(LCM > n) break; } if(__builtin_popcount(i) & 1) res += n / LCM; else res -= n / LCM; } cout << res << endl; }