#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); auto lcm = [&](vector v){ ll ret = v[0]; for(int i = 1; i < (int)v.size(); i++){ ret = ret / __gcd(ret, v[i]) * v[i]; } return ret; }; auto f = [&](ll N, ll X){ return N / X; }; ll n; cin >> n; ll m = 3; vector a(m); rep(i,m) cin >> a[i]; ll ans = 0; rep(i,1< vals; rep(j,m) if(i & (1 << j)) vals.push_back(a[j]); int bcnt = __builtin_popcount(i); if(vals.empty()) continue; if(bcnt & 1){ ans += f(n, lcm(vals)); }else{ ans -= f(n, lcm(vals)); } } cout << ans << endl; }