#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a[4], sum = 0;
  for (int i = 0; i < 4; i++) cin >> a[i];
  long long t = min(a[0], min(a[3], a[2]));
  sum += t * 256;
  if (t == a[0]) {
    sum += 0 * 32;
  } else {
    long long k = min(a[1], (a[0] - t));
    sum += k * 32;
  }
  cout << sum << endl;
  return 0;
}
