#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a, b, c, d, x, y, t, z;
  cin >> a >> b >> c >> d;
  z = min(a, c);
  x = min(z, d);
  y = min(b, a - x);
  t = (x * 256) + (y * 32);
  cout << t << endl;
}
