#include #include const long long max = 10e9; std::bitset f; long long calc(long long n, long long N) { long long cnt = 0; for (int i = n; i <= N; i += n) { if (f[i] == 0) { cnt += 1; f[i] = 1; } } return cnt; } int main() { long long N; long long n[3]; long long cnt = 0; std::cin >> N; std::cin >> n[0]; std::cin >> n[1]; std::cin >> n[2]; for (int i = 0; i < 3; i++) { if (n[i] == 0) { std::cout << -1 << std::endl; return 0; } if (n[i] == 1) { std::cout << N << std::endl; return 0; } } f.reset(); cnt += calc(n[0], N); cnt += calc(n[1], N); cnt += calc(n[2], N); std::cout << cnt << std::endl; return 0; }