using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); public static void Main() { Solve(); } static void Solve() { var p = NList; var (a, b, c, d, e) = (p[0], p[1], p[2], p[3], p[4] - 1); var lcm = LCM(a + b, c + d); var dp = new int[lcm]; for (var i = 0; i < dp.Length; ++i) { if (i > 0) dp[i] += dp[i - 1]; if (i % (a + b) < a && i % (c + d) < c) ++dp[i]; } WriteLine(e / lcm * dp[^1] + dp[e % lcm]); } static int LCM(int a, int b) { var gcd = GCD(a, b); return a / gcd * b; } static int GCD(int a, int b) { if (a < b) return GCD(b, a); if (a % b == 0) return b; return GCD(b, a % b); } }