#include <bits/stdc++.h>
int main() {
  long long int k1, k2, k3, k4, x, y, t = 0, s = 0, S = 0, n;
  scanf("%lld %lld %lld %lld", &k1, &k2, &k3, &k4);
  if (k3 < k4)
    x = k3;
  else
    x = k4;
  if (x <= k1) {
    s = x * 256;
    if (s != 0) k1 = k1 - x;
  } else {
    s = k1 * 256;
    if (s != 0) k1 = 0;
  }
  if (k1 != 0) {
    if (k1 >= k2)
      S = k2 * 32;
    else
      S = k1 * 32;
  }
  t = S + s;
  printf("%lld", t);
  return 0;
}
