#include typedef long long dlong; dlong gcd(dlong a, dlong b) { if (a < b) { dlong tmp = b; b = a; a = tmp; } while (true) { dlong mod = a % b; if (mod == 0) break; a = b; b = mod; } return b; } dlong lcm(dlong a, dlong b) { return a * b / gcd(a, b); } int main(int argc, char const* argv[]) { dlong n; std::cin >> n; dlong a, b, c; std::cin >> a >> b >> c; dlong gcd_ab = lcm(a, b); dlong gcd_bc = lcm(b, c); dlong gcd_ca = lcm(c, a); dlong gcd_abc = lcm(gcd_ab, c); dlong ans = n /a + n / b + n / c - n /gcd_ab - n /gcd_bc - n / gcd_ca + n / gcd_abc; std::cout << ans << std::endl; return 0; }