using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace No316 { class MainClass { private static long Pow(long value, long pow){ long result = 1; for (int i = 0; i < pow; i++) { result *= value; } return result; } private static long Multiply(Dictionary first, Dictionary second){ long value = 1; var firstCopy = new Dictionary (first); var secondCopy = new Dictionary (second); foreach (var keyValue in firstCopy) { long mul = keyValue.Value; if(secondCopy.ContainsKey(keyValue.Key)){ mul = Math.Max(mul, secondCopy[keyValue.Key]); secondCopy.Remove (keyValue.Key); } value *= Pow (keyValue.Key, mul); } foreach (var keyValue in secondCopy) { value *= Pow (keyValue.Key, keyValue.Value); } return value; } private static Dictionary Split(long value) { var cache = value; Dictionary dic = new Dictionary (); for (long i = 2; i * i <= cache; i++) { while (value % i == 0) { if (!dic.ContainsKey (i)) { dic.Add (i, 0); } dic [i]++; value /= i; } } if (value != 1) { dic.Add (value, 1); } return dic; } public static void Main (string[] args) { var n = Convert.ToInt64(Console.ReadLine ()); var keys = Console.ReadLine ().Split(' ').Select(a=>Convert.ToInt64(a)).ToList(); var aCount = n / keys [0]; var bCount = n / keys [1]; var cCount = n / keys [2]; var aFactor = Split (keys [0]); var bFactor = Split (keys [1]); var cFactor = Split (keys [2]); var ab = Multiply (aFactor, bFactor); var bc = Multiply (bFactor, cFactor); var ca = Multiply (cFactor, aFactor); var abCount = n / ab; var bcCount = n / bc; var caCount = n / ca; var caFactor = Split (ca); var abc = Multiply (bFactor, caFactor); var abcCount = n / abc; var sum = aCount + bCount + cCount - abCount - bcCount - caCount + abcCount; Console.WriteLine(sum.ToString()); } } }