#include #include using namespace std; using namespace atcoder; using ll = long long; using ld = long double; int calc(int a, int b, int c, int d, int e) { int cnt = 0; for (int i = 0; i < e; i++) { if (i % (a + b) < a && i % (c + d) < c) cnt++; } return cnt; } int main() { int a, b, c, d, e; cin >> a >> b >> c >> d >> e; int lim = (a + b) * (c + d); int ans = 0; if (e > lim) { int ans0 = calc(a, b, c, d, lim); ans += ans0 * (e / lim); e %= lim; } ans += calc(a, b, c, d, e); cout << ans << endl; return 0; }