#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1073741824")
using namespace std;
const int T = 3, N = 45, P = 2;
int t[T][T];
long long int d[N][T][T];
int main() {
#pragma warning(disable : 4996)
  for (int i = 0; i < 3 * T; i++) scanf("%d", (*t + i));
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    for (int a = 0; a < T; a++) {
      for (int b = 0; b < T; b++) {
        if (a == b) continue;
        int r = T - a - b;
        d[i][a][b] = min(d[i - 1][a][r] + d[i - 1][r][b] + t[a][b],
                         d[i - 1][a][b] + t[a][r] + d[i - 1][b][a] + t[r][b] +
                             d[i - 1][a][b]);
      }
    }
  }
  printf("%lld", d[n][0][2]);
  return 0;
}
