#include using namespace std; #define int long long #define stoi stoll using pii = pair; using vi = vector; using vvi = vector; using vb = vector; using vvb = vector; template using heap = priority_queue, greater>; #define all(c) begin(c), end(c) #define rall(c) rbegin(c), rend(c) #define fore(x, c) for (auto &&x : c) #define rep(i, a, n) for (int i = (int)(a), i##len = (int)(n); i < i##len; ++i) #define rrep(i, a, n) for (int i = (int)(n - 1); i >= a; --i) #define pb push_back #define eb emplace_back #define dump(...) const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL; const int DX[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0}, DY[9] = {-1, 0, 1, 0, -1, 1, 1, -1, 0}; template int sz(const C &c) { return (int)c.size(); } template bool contains(const C &c, const T &v) { return c.find(v) != c.end(); } template bool inseg(const T &l, const T &x, const T &r) { return l <= x && x < r; } template ostream &operator<<(ostream &os, const pair &p) { return os << p.first << " " << p.second; } template istream &operator>>(istream &is, pair &p) { return is >> p.first >> p.second; } template ostream &ostream_container_impl(ostream &os, const C &v) { if (v.empty()) return os; auto itr = begin(v), prv = prev(end(v)); while (itr != prv) os << *itr++ << " "; return os << *prv; } template ostream &operator<<(ostream &os, const vector &v) { return ostream_container_impl(os, v); } template ostream &operator<<(ostream &os, const deque &v) { return ostream_container_impl(os, v); } template ostream &operator<<(ostream &os, const set &v) { return ostream_container_impl(os, v); } template istream &operator>>(istream &is, vector &v) { for (auto &x : v) is >> x; return is; } template bool chmax(T &a, const U &b) { return a < b ? a = b, 1 : 0; } template bool chmin(T &a, const U &b) { return a > b ? a = b, 1 : 0; } template void psum(T &c) { partial_sum(begin(c), end(c), begin(c)); } template void decrement(T &x) { x -= 1; } template void decrement(pair &p) { decrement(p.first); decrement(p.second); } template void decrement(vector &v) { for (auto &x : v) decrement(x); } template void increment(T &x) { x += 1; } template void incrment(pair &p) { increment(p.first); increment(p.second); } template void increment(vector &v) { for (auto &x : v) increment(x); } #if defined(LOCAL) void dump_impl(string s) { assert(s.empty()); } template void dump_impl(string s, const H &head, const T &...tail) { int par = 0; rep(i, 0, sz(s)) { char ch = s[i]; if (ch == ',' && par == 0) { cerr << " = " << head << ","; dump_impl(s.substr(i + 1), tail...); return; } else { cerr << ch; if (ch == '(') par++; if (ch == ')') par--; } } } #ifdef dump #undef dump #endif #define dump(...) \ do { \ cerr << "\x1b[33;1m"; \ dump_impl(#__VA_ARGS__ ",", __VA_ARGS__); \ cerr << "\x1b[0m" << endl; \ } while (0) #endif struct before_main_function { before_main_function() { #if defined(LOCAL) && defined(int) cerr << "\x1b[7m" << "'int' is 'long long'" << "\x1b[m" << endl; #endif cin.tie(nullptr); ios::sync_with_stdio(false); cout << setprecision(15) << fixed; } } before_main_function; //------------------8<------------------------------------8<-------------------- int gcd(int a, int b) { return a ? gcd(b % a, a) : b; } int lcm(int a, int b) { return a / gcd(a, b) * b; } signed main() { int A, B, C, D, E; cin >> A >> B >> C >> D >> E; int L = lcm(A + B, C + D); int M = E % L; int ans = 0; rep(t, 0, L) { int c = 0; if (t % (A + B) < A) c++; if (t % (C + D) < C) c++; if (c == 2) ans++; } ans = E / L * ans; rep(t, 0, M) { int c = 0; if (t % (A + B) < A) c++; if (t % (C + D) < C) c++; dump(t, c); if (c == 2) ans++; } cout << ans << endl; }