#include using namespace std; typedef long long ll; ll gcd(ll n, ll m) { if (n < m) { ll c = n; n = m; m = c; } if (n%m == 0) { return m; } else { return gcd(m, n%m); } } int main() { ll n, a, b, c; cin >> n >> a >> b >> c; ll ans = 0; ans += n / a + n / b + n / c; ll ab = a * b / gcd(a, b); ll bc = b * c / gcd(b, c); ll ca = c * a / gcd(c, a); ans -= n / ab + n / bc + n / ca; ll gcd_abc = gcd(a, gcd(b, c)); ll abc = a * b*c / gcd_abc / gcd_abc; ans += n / abc; cout << ans << endl; return 0; }