import java.io.*; import java.util.StringTokenizer; /** * Date: 2025/1/22 14:05 */ public class Main { public static void main(String[] args) { long n = sc.nextInt(); long[] a = new long[3]; for (int i = 0; i < 3; i++) { a[i] = sc.nextLong(); } long ans = 0; for (int s = 1; s < 1 << 3; s++) { long v = 1; int bit = Integer.bitCount(s); for (int i = 0; i < 3; i++) { if ((s >> i & 1) == 1) v =getLCM(v,a[i]); } if (bit % 2 == 1) ans += n / v; else ans -= n / v; } out.println(ans); out.close(); } //求 a 和 b 的最大公约数,做法:辗转相除法 static long getGCD(long a, long b) { if (b == 0) return a; if (a % b == 0) return b; return getGCD(b, a % b); } //求 a 和 b 的最小公倍数, lcm * gcd = a * b static long getLCM(long a, long b) { return a * b / getGCD(a, b); } static Kattio sc = new Kattio(); static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); static class Kattio { static BufferedReader r; static StringTokenizer st; public Kattio() { r = new BufferedReader(new InputStreamReader(System.in)); } public String next() { try { while (st == null || !st.hasMoreTokens()) { st = new StringTokenizer(r.readLine()); } return st.nextToken(); } catch (Exception e) { return null; } } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } } }