from copy import copy from collections import defaultdict,deque v1,v2,v3,v4,n = map(int,input().split()) volume = [v1,v2,v3,v4] tmp = [v1,0,0,0] dp = [-1 for _ in range((v1+1) ** 3)] def convert(x,y,z,X,Y,Z): return X * Y *z + X * y + x def ch(List): v1,v2,v3,v4 = List return convert(v1,v2,v3,volume[0]+1,volume[0]+1,volume[0]+1) q = deque() q.append((tmp,0)) dp[ch(tmp)] = 0 memo = [] cycle = -1 while q: board,t = q.popleft() memo.append(board) new = copy(board) co = volume[(t+1)%4] -new[(t+1) % 4] new[(t+1) % 4] += min(new[t%4],co) new[t%4] -= min(new[t%4],co) if dp[ch(new)] >= 0: cycle = dp[ch(new)] break q.append((new,t+1)) dp[ch(new)] = dp[ch(board)] +1 doubling = [[-1] * len(memo) for _ in range(61)] for i in range(len(memo)): if i == len(memo) -1: doubling[0][i] = cycle else: doubling[0][i] = i + 1 for k in range(60): for i in range(len(memo)): doubling[k+1][i] = doubling[k][doubling[k][i]] now = 0 for k in range(60): if (n>>k) & 1: now = doubling[k][now] n-= (1<