import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); long N = scan.nextInt(); long a = scan.nextInt(); long b = scan.nextInt(); long c = scan.nextInt(); scan.close(); if(b % a == 0 && c % a == 0) { long ans = N / a; System.out.println(ans); }else if(b % a == 0) { long k1 = N / a; long k2 = N / c; long k3 = N / lcm(a, c); long ans = k1 + k2 - k3; System.out.println(ans); }else if(c % a == 0) { long k1 = N / a; long k2 = N / b; long k3 = N / (a * b); long ans = k1 + k2 - k3; System.out.println(ans); }else { long k1 = N / a; long k2 = N / b; long k3 = N / c; long k4 = N / lcm(a, b); long k5 = N / lcm(b, c); long k6 = N / lcm(c, a); long k7 = N / lcm(lcm(a, b), c); long ans = k1 + k2 + k3 - (k4 + k5 + k6) + k7; System.out.println(ans); } } static long gcd(long m, long n) { if(m < n) { return gcd(n , m); } if(n == 0) { return m; } return gcd(n, m % n); } static long lcm(long m, long n) { return m * n / gcd(m, n); } }