#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; // 最大公約数 long long gcd(long long a, long long b){ while(b != 0){ long long tmp = a % b; a = b; b = tmp; } return a; } // 最小公倍数 long long lcm(long long a, long long b){ return a / gcd(a, b) * b; } int main() { int n; cin >> n; vector a(3); for(int i=0; i<3; ++i) cin >> a[i]; long long ans = 0; for(int i=1; i<(1<<3); ++i){ bitset<3> bs(i); long long x = 1; for(int j=0; j<3; ++j){ if(bs[j]) x = lcm(x, a[j]); } if(bs.count() % 2 == 0) ans -= n / x; else ans += n / x; } cout << ans << endl; return 0; }