using System; using System.Collections.Generic; using System.Text; using System.Linq; class Program { public void Proc() { Reader.IsDebug = false; long maxNum = long.Parse(Reader.ReadLine()); long[] num = Reader.ReadLine().Split(' ').Select(a=>long.Parse(a)).ToArray(); long numA = num[0]; long numB = num[1]; long numC = num[2]; long numAB = this.LCM(numA, numB); long numBC = this.LCM(numB, numC); long numAC = this.LCM(numA, numC); long numABC = this.LCM(numAB, numC); long valA = maxNum / numA; long valB = maxNum / numB; long valC = maxNum / numC; long valAB = maxNum / numAB; long valBC = maxNum / numBC; long valAC = maxNum / numAC; long valABC = maxNum / numABC; long ans = valA + valB + valC - valAB - valBC - valAC + valABC; Console.WriteLine(ans); } private long LCM(long a, long b) { long num1 = Math.Max(a,b); long num2 = Math.Min(a,b); while (num1 % num2 > 0) { long num3 = num1 % num2; num1 = num2; num2 = num3; } long ans = (a / num2) * (b / num2) * num2; return ans; } public class Reader { public static bool IsDebug = true; private static String PlainInput = @" 83359640 3304 9805 9945 "; private static System.IO.StringReader Sr = null; public static string ReadLine() { if (IsDebug) { if (Sr == null) { Sr = new System.IO.StringReader(PlainInput.Trim()); } return Sr.ReadLine(); } else { return Console.ReadLine(); } } } static void Main() { Program prg = new Program(); prg.Proc(); } }