using System; public class Hello { public static int a, b, c, d, e; static void Main() { string[] line = Console.ReadLine().Trim().Split(' '); a = int.Parse(line[0]); b = int.Parse(line[1]); c = int.Parse(line[2]); d = int.Parse(line[3]); e = int.Parse(line[4]); var s = new bool[20]; getAns(); } static void putA (bool[] s, int x, int y) { var sL = s.Length; var p = 0; while (p < sL) { for (int i = 0; i < x; i++) s[p++] = true; p += y; } } static void getAns () { var gcd = Gcd(a+b, c+d); var lcm = (a + b) * (c + d) / gcd; var t0 = e % lcm; var t1 = e / lcm; var s0 = new bool[lcm]; var s1 = new bool[lcm]; putA(s0, a, b); putA(s1, c, d); var count = 0; for (int i = 0; i < t0; i++) { if (s0[i] && s1[i]) count++; } var countb = 0; for (int i = 0; i < lcm; i++) { if (s0[i] && s1[i]) countb++; } Console.WriteLine(countb * t1 + count); } static int Gcd(int a, int b) { if (a < b) return Gcd(b, a); while (b != 0) { var w = a % b; a = b; b = w; } return a; } }