#include using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #define _GLIBCXX_DEBUG #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { int a, b, c, d, e; cin >> a >> b >> c >> d >> e; int l = lcm(a + b, c + d); vector tmp(l, 0); for (int t = 0; t < l; t++) { if (t % (a + b) < a) tmp[t]++; if (t % (c + d) < c) tmp[t]++; } int cnt = 0; for (int t = 0; t < l; t++) if (tmp[t] == 2) cnt++; int rem = 0; for (int t = 0; t < e % l; t++) if (tmp[t] == 2) rem++; cout << e / l * cnt + rem << endl; return 0; }