#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long int k2, k3, k5, k6, mn1, mn2, i, arr[5], arr1[2], ans;
  unsigned long long int K1 = 2, K3 = 3, K5 = 5, K6 = 6;
  cin >> k2 >> k3 >> k5 >> k6;
  arr[0] = k2;
  arr[1] = k5;
  arr[2] = k6;
  mn1 = arr[0];
  for (i = 0; i < 3; i++) {
    if (mn1 > arr[i]) mn1 = arr[i];
  }
  k2 = k2 - mn1;
  if (k2 > 0) {
    arr1[0] = k2;
    arr1[1] = k3;
    mn2 = arr1[0];
    for (i = 0; i < 2; i++) {
      if (mn2 > arr1[i]) mn2 = arr1[i];
    }
  } else
    mn2 = 0;
  ans = mn1 * 256 + mn2 * 32;
  cout << ans << endl;
  return 0;
}
