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