using System; using System.Collections.Generic; using System.Linq; class Program { static void Main() { long n = long.Parse(Console.ReadLine()); long[] abc = Console.ReadLine().Split().Select(long.Parse).ToArray(); long lcm = Lcm(Lcm(abc[0], abc[1]), abc[2]); long ans = 0; if (lcm < n) { HashSet hit = new HashSet(); foreach (int i in abc) { for (int j = i; j <= lcm; j += i) { hit.Add(j); } } ans += hit.Count * (n / lcm); } long m = n % lcm; HashSet hit2 = new HashSet(); foreach (int i in abc) { for (int j = i; j <= m; j += i) { hit2.Add(j); } } ans += hit2.Count; Console.WriteLine(ans); } // 最小公倍数 出典: http://qiita.com/gushwell/items/f08d0e71fa0480dbb396 public static long Lcm(long a, long b) { return a * b / Gcd(a, b); } // ユークリッドの互除法 public static long Gcd(long a, long b) { if (a < b) // 引数を入替えて自分を呼び出す return Gcd(b, a); while (b != 0) { var remainder = a % b; a = b; b = remainder; } return a; } }