#include <bits/stdc++.h>
using namespace std;
int mini(int k2, int k5, int k6) {
  if (k2 < k5 && k2 < k6)
    return k2;
  else if (k5 < k6)
    return k5;
  else
    return k6;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int k2, k3, k5, k6, sum1 = 0, sum2 = 0;
  cin >> k2 >> k3 >> k5 >> k6;
  if (k2 == 1 && k3 == 1 && k5 == 1 && k6 == 1) {
    cout << 256;
    return 0;
  } else if (k2 == 0 && k3 == 0 && k5 == 0 && k6 == 0) {
    cout << 0;
    return 0;
  }
  int min = mini(k2, k5, k6);
  sum1 = min * 256;
  k2 = k2 - min;
  if (k2 < k3)
    sum2 = k2 * 32;
  else
    sum2 = k3 * 32;
  cout << sum1 + sum2;
  return 0;
}
