#include using namespace std; int main() { long long A, B, C, D, E; cin >> A >> B >> C >> D >> E; int ab = A + B; int cd = C + D; int lcm = ab / __gcd( ab, cd ) * cd; vector v( lcm ); for( int i = 0; i < lcm; i++ ) { if( i % ab < A ) v[i] = 1; } for( int i = 0; i < lcm; i++ ) { if( i % cd < C ) v[i] &= 1; else v[i] = 0; } int cnt = 0; for( int i = 0; i < lcm; i++ ) { if( v[i] ) cnt++; } int ans = E / lcm * cnt; int r = E % lcm; vector vv( r ); for( int i = 0; i < r; i++ ) { if( i % ab < A ) vv[i] = 1; } for( int i = 0; i < r; i++ ) { if( i % cd < C ) vv[i] &= 1; else vv[i] = 0; } cnt = 0; for( int i = 0; i < r; i++ ) { if( vv[i] ) cnt++; } ans += cnt; cout << ans << endl; }