#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  long long total = 0;
  if (c > d) {
    if (d < a) {
      total = 256 * d;
      a = a - d;
    } else {
      cout << 256 * a << endl;
      return 0;
    }
  } else {
    if (a > c) {
      total = 256 * c;
      a = a - c;
    } else {
      cout << 256 * a << endl;
      return 0;
    }
  }
  if (b > a) {
    total += 32 * a;
  } else {
    total += 32 * b;
  }
  cout << total << endl;
}
