#include #include #include #include #include #include #include #include #define ll long long long gcd(long a, long b) { if (a < b) { long tmp = a; a = b; b = tmp; } while(b > 0) { long r = a % b; a = b; b = r; } return a; } long lcm(long a, long b) { return a * b / gcd(a,b); } long lcm(long a, long b, long c) { long LCM = lcm(a,b); return LCM * c / gcd(LCM,c); } int main() { ll N,a,b,c; std::cin >> N >> a >> b >> c; long ac = N / a; long bc = N / b; long cc = N / c; long lcmAB = lcm(a,b); long lcmAC = lcm(a,c); long lcmBC = lcm(b,c); long lcmABC = lcm(a,b,c); long abc = N / (lcmAB); long acc = N / (lcmAC); long bcc = N / (lcmBC); long abcc = N / (lcmABC); std::cout << (( ac + bc + cc + abcc - abc - acc - bcc )) << std::endl; }