#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int k2, k3, k5, k6, a, b;
  cin >> k2 >> k3 >> k5 >> k6;
  if (k2 < k5) {
    if (k2 < k6) {
      a = k2;
    } else {
      a = k6;
    }
  } else {
    if (k5 < k6) {
      a = k5;
    } else {
      a = k6;
    }
  }
  k2 -= a;
  if (k3 < k2) {
    b = k3;
  } else {
    b = k2;
  }
  cout << a * 256 + b * 32;
}
