#include #include #include #include #include #include #include #include #include #define ALL(obj) (obj).begin(),(obj).end() #define RALL(obj) (obj).rbegin(),(obj).rend() #define P pair #define MOD 1000000007 #define INF 1012345678 #define NINF (-2147483647-1) #define LLINF 9223372036854775807 using ll = long long; using namespace std; //gcd(long long) ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } int main() { ll N, a, b, c; ll ans = 0; cin >> N >> a >> b >> c; ans += N / a + N / b + N / c; ll d = a * b / gcd(a, b); ans -= N / d; ans -= N / (b * c / gcd(b, c)); ans -= N / (c * a / gcd(c, a)); ans += N / (d * c / gcd(d, c)); cout << ans << endl; getchar(); getchar(); return 0; }