import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long n = sc.nextLong(); long a = sc.nextLong(); long b = sc.nextLong(); long c = sc.nextLong(); long k1 = n / a; long k2 = n / b; long k3 = n / c; long g1 = gcd(a, b); long g2 = gcd(a, c); long g3 = gcd(b, c); long g4 = gcd(a, g3); long l1 = g1 * (a / g1) * (b / g1); long l2 = g2 * (a / g2) * (c / g2); long l3 = g3 * (b / g3) * (c / g3); long g5 = gcd(l1, c); long l4 = g5 * (l1 / g5) * (c / g5); long h1 = n / l1; long h2 = n / l2; long h3 = n / l3; long h4 = n / l4; long ans = k1 + k2 + k3 - h1 - h2 - h3 + h4; System.out.println(ans); } public static long gcd(long a, long b) { if(b == 0) return a; return gcd(b, (a % b)); } }