Recently Anton found a box with digits in his room. There are k_2 digits 2, k_3 digits 3, k_5 digits 5 and k_6 digits 6.

Anton's favorite integers are 32 and 256. He decided to compose this integers from digits he has. He wants to make the sum of these integers as large as possible. Help him solve this task!

Each digit can be used no more than once, i.e. the composed integers should contain no more than k_2 digits 2, k_3 digits 3 and so on. Of course, unused digits are not counted in the sum.


-----Input-----

The only line of the input contains four integers k_2, k_3, k_5 and k_6 — the number of digits 2, 3, 5 and 6 respectively (0 ≤ k_2, k_3, k_5, k_6 ≤ 5·10^6).


-----Output-----

Print one integer — maximum possible sum of Anton's favorite integers that can be composed using digits from the box.


-----Examples-----
Input
5 1 3 4

Output
800

Input
1 1 1 1

Output
256



-----Note-----

In the first sample, there are five digits 2, one digit 3, three digits 5 and four digits 6. Anton can compose three integers 256 and one integer 32 to achieve the value 256 + 256 + 256 + 32 = 800. Note, that there is one unused integer 2 and one unused integer 6. They are not counted in the answer.

In the second sample, the optimal answer is to create on integer 256, thus the answer is 256.

Source: codeforces | Difficulty: EASY
Tags: Mathematics

Complete search

Implementation

Greedy algorithms


Solutions:
(amountOfTwo, amountOfThree, amountOfFive, amountOfSix) = [int(i) for i in input().split(' ')]
possible256 = min(amountOfTwo, amountOfFive, amountOfSix)
possible32 = min(amountOfTwo - possible256, amountOfThree)
print(256 * possible256 + 32 * possible32)


(k2, k3, k5, k6) = (int(x) for x in input().split())
tmp = min(k2, k5, k6)
ans = tmp * 256
k2 -= tmp
k5 -= tmp
k6 -= tmp
print(ans + min(k3, k2) * 32)


(k2, k3, k5, k6) = map(int, input().split())
ans = 0
min_256 = 0
if k2 < k5:
	min_256 = k2
else:
	min_256 = k5
if k6 < min_256:
	min_256 = k6
ans = 256 * min_256
if k2 > min_256:
	k2 = k2 - min_256
else:
	k2 = 0
if k2 < k3:
	ans = ans + k2 * 32
else:
	ans = ans + k3 * 32
print(ans)


k = list(map(int, input().split()))
n256 = min(k[0], k[2], k[3])
print(n256 * 256 + min(k[0] - n256, k[1]) * 32)


ans = 0
(a, b, c, d) = map(int, input().split())
ans += min(a, c, d) * 256
a -= min(a, c, d)
a = max(a, 0)
ans += min(a, b) * 32
print(ans)


(k2, k3, k5, k6) = (int(i) for i in input().split())
sum = 0
k = min(k2, k5, k6)
sum += k * 256
k2 = k2 - k
k = min(k2, k3)
sum = sum + k * 32
print(sum)


(k2, k3, k5, k6) = map(int, input().split())
cnt_256 = min(k2, k5, k6)
k2 -= cnt_256
k5 -= cnt_256
k6 -= cnt_256
cnt_32 = min(k2, k3)
total_sum = 256 * cnt_256 + 32 * cnt_32
print(total_sum)


(a, b, c, d) = map(int, input().split())
mx = min(a, c, d)
ans = mx * 256 + min(a - mx, b) * 32
print(ans)


(a, b, c, d) = map(int, input().split())
x = min(a, c, d)
(a, c, d) = (a - x, c - x, d - x)
y = min(a, b)
print(256 * x + 32 * y)


(k2, k3, k5, k6) = map(int, input().split())
kmin = min(k2, k5, k6)
res = 256 * kmin + 32 * min(k2 - kmin, k3)
print(res)


(k1, k2, k3, k4) = list(map(int, input().split()))
tot = 0
x = True
min256 = min(k1, k3, k4)
(k1, k3, k4) = (k1 - min256, k3 - min256, k4 - min256)
min32 = min(k1, k2)
(k1, k2) = (k1 - min32, k2 - min32)
tot = 256 * min256 + 32 * min32
print(tot)


(k2, k3, k5, k6) = map(int, input().split())
minimal256 = min(k6, k5, k2)
sum = 256 * minimal256
k2 -= minimal256
minimal32 = min(k3, k2)
sum += minimal32 * 32
print(sum)


(k2, k3, k5, k6) = map(int, input().split(' '))
ans = 0
while k2 != 0 and k5 != 0 and (k6 != 0):
	ans += 256
	k2 -= 1
	k5 -= 1
	k6 -= 1
while k3 != 0 and k2 != 0:
	ans += 32
	k3 -= 1
	k2 -= 1
print(ans)


(k2, k3, k5, k6) = map(int, input().split())
min_no = min(k2, min(k5, k6))
k2 = k2 - min_no
min_no2 = min(k2, k3)
print(256 * min_no + 32 * min_no2)


(k2, k3, k5, k6) = [int(i) for i in input().split()]
print(min(k2, k5, k6) * 256 + min(k2 - min(k2, k5, k6), k3) * 32)


(k2, k3, k5, k6) = map(int, input().split())
k5 = min(k5, k6)
if k2 >= k3 + k5:
	print(k5 * 256 + k3 * 32)
elif k2 >= k5:
	print(k5 * 256 + (k2 - k5) * 32)
else:
	print(256 * k2)


(k2, k3, k5, k6) = map(int, input().split())
ans = min(k2, k5, k6)
print(ans * 256 + min(k2 - ans, k3) * 32)


(a, b, c, d) = map(int, input().split())
p = min(a, c, d)
res = 0
res = res + p * 256
q = a - p
r = min(b, q)
res = res + r * 32
print(res)


from math import *
import sys, random

def nextInt():
	return int(input())

def nextStrs():
	return input().split()

def nextInts():
	return list(map(int, nextStrs()))

def can(i, j, k):
	if i + j > k:
		return True
	return False

def main():
	t = 1
	while t > 0:
		(k2, k3, k5, k6) = nextInts()
		n256 = min(k2, k5, k6)
		k2 -= n256
		n32 = min(k2, k3)
		res = 256 * n256 + 32 * n32
		print(res)
		t -= 1
exit(main())


(k2, k3, k5, k6) = map(int, input().split())
sums = 0
fm = min(k6, k5, k2)
sums += fm * 256
k2 -= fm
sums += min(k2, k3) * 32
print(sums)


def max_sum(d2, d3, d5, d6):
	bigger_numbers = min(d2, d5, d6)
	smaller_numbers = min(d2 - bigger_numbers, d3)
	return bigger_numbers * 256 + smaller_numbers * 32
(d2, d3, d5, d6) = map(int, input().split())
print(max_sum(d2, d3, d5, d6))


n = list(map(int, input().split()))
t = min(n[0], n[2], n[3])
su = t * 256
if t == n[0]:
	print(su)
else:
	m = min(n[0] - t, n[1])
	print(su + m * 32)


(k2, k3, k5, k6) = map(int, input().split())
sum = 0
sum += 256 * min(k2, k5, k6)
if k2 - min(k2, k5, k6) > 0:
	sum += min(k2 - min(k2, k5, k6), k3) * 32
print(sum)


l = list(map(int, input().split()))
total = 0
b = min(l[0], l[2], l[3])
total += b * 256
l[0] = l[0] - b
l[2] = l[2] - b
l[3] = l[3] - b
total += min(l[0], l[1]) * 32
print(total)


(k2, k3, k5, k6) = [int(elem) for elem in input().split()]
summ = min(k2, k5, k6) * 256 + min(k3, k2 - min(k2, k5, k6)) * 32
print(summ)


print(*[256 * e + 32 * min(b, a - e) for (a, b, c, d) in [map(int, input().split())] for e in [min(a, c, d)]])


(k2, k3, k5, k6) = list(map(int, input().split()))
s = min(k2, k5, k6) * 256
k2 -= min(k2, k5, k6)
s += min(k2, k3) * 32
print(s)


(k1, k2, k3, k4) = map(int, input().split())
p = min(k1, k3, k4)
c = p * 256
a = k1 - p
q = min(k2, a)
d = 32 * q
s = c + d
print(s)


(k1, k2, k3, k4) = [int(x) for x in input().split()]
num256 = min(k1, k3, k4)
k1 = max(k1 - num256, 0)
num32 = min(k1, k2)
output = 256 * num256 + 32 * num32
print(output)


x = input
(a, b, c, d) = map(int, input().split())
p = min(a, c, d)
t = min(a - p, b)
print(p * 256 + t * 32)


(a, b, c, d) = map(int, input().split())
e = min(a, c, d)
f = min(a - e, b)
print(256 * e + 32 * f)


(w, x, y, z) = map(int, input().split())
tfs_sum = min(w, y, z)
sum1 = tfs_sum * 256 + min(w - tfs_sum, x) * 32
print(sum1)


(k2, k3, k5, k6) = map(int, input().split())
temp = min(k2, k5, k6)
k2 -= temp
k5 -= temp
k6 -= temp
total_ = temp * 256
temp1 = min(k2, k3)
total_ += 32 * temp1
print(total_)


inp = input().split()
inp = list(map(int, inp))
a2 = inp[0]
a3 = inp[1]
a5 = inp[2]
a6 = inp[3]
n256 = min(a2, a5, a6)
a2 = a2 - n256
n32 = min(a2, a3)
val = n256 * 256 + n32 * 32
print(val)


(k2, k3, k5, k6) = list(map(int, input().split()))
j = min(k2, k5, k6)
k2 = k2 - j
k = min(k2, k3)
print(256 * j + 32 * k)


(k2, k3, k5, k6) = map(int, input().split())
a = min(k2, k5, k6)
b = min(k2 - a, k3)
print(a * 256 + b * 32)


(k2, k3, k5, k6) = map(int, input().split())
m1 = min(k2, k5, k6)
s = m1 * 256
k2 -= m1
m2 = 0
if k2 > 0 and k3 > 0:
	m2 = min(k2, k3)
s += m2 * 32
print(s)


(k2, k3, k5, k6) = map(int, input().split())
x = min(k5, k6)
s = 0
y = 0
if k2 >= x:
	y = 256 * x
elif k2 < x:
	y = y + 256 * k2
w = k2 - x
if w > 0:
	z = min(w, k3)
	s = s + 32 * z
print(s + y)


from sys import stdin
_input = stdin.readline
(_range, _int) = (range, int)

def solution():
	tmpl_256 = [1, 0, 1, 1]
	tmpl_32 = [1, 1, 0, 0]
	arr = [_int(i) for i in _input().split()]
	ans = 0
	while arr[0] > 0 and arr[2] > 0 and (arr[3] > 0):
		ans += 256
		for i in _range(4):
			arr[i] -= tmpl_256[i]
	while arr[0] > 0 and arr[1] > 0:
		ans += 32
		for i in _range(4):
			arr[i] -= tmpl_32[i]
	print(ans)
solution()


(k2, k3, k5, k6) = input().split()
k2 = int(k2)
k3 = int(k3)
k5 = int(k5)
k6 = int(k6)
m256 = min(k2, k5, k6)
m32 = min(k2 - m256, k3)
ans = 256 * m256 + 32 * m32
print(ans)


a = input().split()
b = int(a[0])
c = int(a[1])
d = int(a[2])
e = int(a[3])
x = min(b, d, e)
y = x * 256
r = b - x
l = min(c, r)
z = l * 32
v = y + z
print(v)


def anton_digits(k2, k3, k5, k6):
	n1 = min(k2, k5, k6)
	n2 = min(k3, k2 - n1)
	print(256 * n1 + 32 * n2)

def main():
	(k2, k3, k5, k6) = map(int, input().split())
	anton_digits(k2, k3, k5, k6)
main()


(k2, k3, k5, k6) = map(int, input().split())
count_256 = min(k2, k5, k6)
count_32 = min(k3, k2 - count_256)
print(256 * count_256 + 32 * count_32)


(k2, k3, k5, k6) = map(int, input().split())
n1 = min(k2, k5, k6)
n2 = min(k2 - n1, k3)
print(n1 * 256 + n2 * 32)


(k2, k3, k5, k6) = map(int, input().split())
x = min(k2, k5, k6)
k2 -= x
y = min(k2, k3)
print(256 * x + 32 * y)


import math
import sys
a = list(map(int, input().split()))
b = min(a[0], a[2], a[3])
c = 0
c = b * 256
a[0] = a[0] - b
d = min(a[0], a[1])
c += d * 32
print(c)


l = list(map(int, input().split()))
i = min(l[2], l[0], l[3])
su = i * 256
j = l[0] - i
i = min(l[1], j)
su += i * 32
print(su)


a = list(map(int, input().split()))
m = min(a[0], a[2], a[3])
c = 0
c += 256 * m
a[0] = a[0] - m
m = min(a[0], a[1])
c += 32 * m
print(c)


(k2, k3, k5, k6) = map(int, input().split())
no256 = min(k2, k5, k6)
k2 = k2 - no256
no32 = min(k2, k3)
print(256 * no256 + 32 * no32)


(a, b, c, d) = list(map(int, input().split()))
min1 = min(a, c, d)
p = 0
for i in range(min1):
	p += 256
a = a - min1
c = c - min1
d = d - min1
q = 0
for i in range(min(a, b)):
	q += 32
print(p + q)


lst = list(map(int, input().split()))
x = min(lst[0], lst[2], lst[3])
lst[0] -= x
y = min(lst[0], lst[1])
print(x * 256 + y * 32)


(a, b, c, d) = map(int, input().split())
s = min(a, c, d) * 256
a = a - min(a, c, d)
s = s + min(a, b) * 32
print(s)


l = list(map(int, input().split()))
n1 = min(l[0], l[2], l[3])
s1 = n1 * 256
l[0] = l[0] - n1
n2 = min(l[0], l[1])
s1 = s1 + n2 * 32
l[0] = l[0] + n1
n1 = min(l[0], l[1])
s2 = n1 * 32
l[0] = l[0] - n1
n2 = min(l[0], l[2], l[3])
s2 = s2 + n2 * 256
print(max(s1, s2))


(k2, k3, k5, k6) = tuple([int(x) for x in input().split(' ')])
result = min(k2, k5, k6) * 256
k2 -= min(k2, k5, k6)
result += min(k2, k3) * 32
print(result)


(k2, k3, k5, k6) = map(lambda i: int(i), input('').split())
n2 = min(k5, k6)
n1 = min(k2 - n2, k3)
if n1 < 0:
	n1 = 0
	n2 = k2
print(32 * n1 + 256 * n2)


(a2, a3, a5, a6) = map(int, input().split())
m = min(a2, a5, a6)
n = min(a2 - m, a3)
ans = 256 * m + 32 * n
print(ans)


def main():
	[k2, k3, k5, k6] = [int(x) for x in input().split()]
	print(solver(k2, k3, k5, k6))

def solver(k2, k3, k5, k6):
	x256 = min(k2, k5, k6)
	x32 = min(k2 - x256, k3)
	return x256 * 256 + x32 * 32
main()


(two, three, five, six) = map(int, input().strip().split())
maxSum = int()
min256 = min(two, five, six)
maxSum += min256 * 256
two -= min256
maxSum += min(two, three) * 32
print(maxSum)


(k2, k3, k5, k6) = map(int, input().split())
x = min(k5, k6)
if k2 >= x + k3:
	print(x * 256 + k3 * 32)
else:
	y = min(x, k2)
	k2 = k2 - y
	if k2 > 0:
		z = min(k2, k3)
		print(y * 256 + z * 32)
	else:
		print(y * 256)


(k2, k3, k5, k6) = map(int, input().split())
n256 = min([k2, k5, k6])
k2 -= n256
n32 = min(k3, k2)
print(256 * n256 + 32 * n32)


nums = input().split(' ')
for i in range(len(nums)):
	nums[i] = int(nums[i])
minn = min(nums[0], nums[2], nums[3])
total = minn * 256
for i in range(len(nums)):
	if i == 1:
		continue
	else:
		nums[i] -= minn
minn = min(nums[0], nums[1])
total += minn * 32
print(total)


(a, b, c, d) = map(int, input().split())
m = min(a, c, d)
ret = m * 256
a -= m
c -= m
d -= m
ret += min(a, b) * 32
print(ret)


from math import ceil, log, floor, sqrt
import math
k = 1

def mod_expo(n, p, m):
	result = 1
	while p != 0:
		if p % 2 == 1:
			result = result * n % m
		p //= 2
		n = n * n % m
	return result

def is_prime(n):
	m = 2
	while m * m <= n:
		if n % m == 0:
			return False
		m += 1
	return True

def find_sum(n, a):
	a.insert(0, 0)
	for i in range(1, n + 1):
		prev = a[i] & a[i - 1]
		cur = a[i] | a[i - 1]
		a[i - 1] = prev
		a[i] = cur
	return sum((m * m for m in a))

def prin_abc(x, y, z):
	l = [x, y, z]
	l.sort()
	if l[1] < l[2]:
		print('NO')
		return
	a = b = l[0]
	c = l[2]
	print('YES')
	print(a, b, c)

def get_scores(n, vals):
	l = 0
	r = n - 1
	turn = 0
	sereja = 0
	dima = 0
	while l <= r:
		if vals[l] > vals[r]:
			cur = vals[l]
			l += 1
		else:
			cur = vals[r]
			r -= 1
		if turn == 0:
			sereja += cur
		else:
			dima += cur
		turn = not turn
	print(sereja, dima)

def count_lamps(n, m):
	return (n * m + 1) // 2

def find_sum(k2, k3, k5, k6):
	a = [k2, k5, k6]
	mn = min(a)
	res = mn * 256
	a[:] = [value - mn for value in a]
	res += min(a[0], k3) * 32
	return res
t = 1
while t:
	t = t - 1
	points = []
	(k2, k3, k5, k6) = map(int, input().split())
	print(find_sum(k2, k3, k5, k6))


import math, fractions
(k2, k3, k5, k6) = [int(x) for x in input().split()]
k256 = min(k2, k5, k6)
k2 -= k256
k32 = min(k3, k2)
print(256 * k256 + 32 * k32)


(k2, k3, k5, k6) = [int(x) for x in input().split()]
m = min(k2, k5, k6)
s = m * 256
k2 = k2 - m
n = min(k2, k3)
s = s + 32 * n
print(s)


s = list(map(int, input().split()))
k = {}
k[2] = s[0]
k[3] = s[1]
k[5] = s[2]
k[6] = s[3]
a = min(k[2], k[5], k[6])
b = min(k[3], k[2] - a)
print(a * 256 + b * 32)


(two, three, five, six) = (int(x) for x in input().split())
answer = 0
while two > 0:
	if five > 0 and six > 0:
		howmany = min(two, five, six)
		answer += 256 * howmany
		five -= howmany
		six -= howmany
		two -= howmany
	elif three > 0:
		howmany = min(two, three)
		answer += 32 * howmany
		two -= howmany
		three -= howmany
	else:
		break
print(answer)


(a, b, c, d) = map(int, input().split())
n = min(a, c, d)
sum = n * 256
a -= n
c -= n
d -= n
x = min(a, b)
sum = sum + x * 32
print(sum)


l = list(map(int, input().strip().split()))
n = min(l[0], l[2], l[3])
m = min(l[0] - n, l[1])
print(m * 32 + n * 256)


n = input().split()
d = {}
result = 0
d[2] = int(n[0])
d[3] = int(n[1])
d[5] = int(n[2])
d[6] = int(n[3])
x = min(d[2], d[5], d[6])
result += 256 * x
d[2] -= x
d[5] -= x
d[6] -= x
y = min(d[2], d[3])
result += 32 * y
print(result)


(a, b, c, d) = [int(x) for x in input().split()]
x = min(c, d, a)
y = min(b, a - x)
print(256 * x + 32 * y)


digits = list(map(int, input().split()))
nigoro = min(digits[0], digits[2], digits[3])
for i in [0, 2, 3]:
	digits[i] -= nigoro
print(min(digits[0], digits[1]) * 32 + nigoro * 256)


ch = input()
l = ch.split()
j = []
j.append(int(l[0]))
j.append(int(l[2]))
j.append(int(l[3]))
s = 0
k = []
s = 256 * min(j)
k.append(j[0] - min(j))
k.append(int(l[1]))
s = s + 32 * min(k)
print(s)


(a, b, c, d) = tuple(map(int, input().split()))
amount = 0
x = min(min(a, c), d)
a -= x
amount += x * 256
amount += min(a, b) * 32
print(amount)


usrInput = input()
usrInput = str(usrInput)
theList = usrInput.split()
twos = int(theList[0])
threes = int(theList[1])
sixes = int(theList[2])
fives = int(theList[3])
a = min(twos, sixes, fives)
answer = a * 256
twos = twos - a
fives = fives - a
sixes = sixes - a
a = min(threes, twos)
answer = answer + 32 * a
print(answer)


try:
	(a, b, c, d) = list(map(int, input().split()))
	e = min(a, c, d)
	ans = 256 * e
	f = a - e
	g = min(f, b)
	s = 32 * g
	print(ans + s)
except:
	pass


(a, b, c, d) = map(int, input().split())
s = 0
m = min(a, c, d)
a = a - m
s = s + m * 256
m2 = min(a, b)
s = s + m2 * 32
print(s)


nums = [int(num) for num in input().split()]

def num256(nums):
	return min(nums[0], *nums[2:])

def num32(nums):
	return min(nums[:2])
n256 = num256(nums)
nums[0] -= n256
n32 = num32(nums)
print(n256 * 256 + n32 * 32)


(k2, k3, k5, k6) = map(int, input().split())
b = min(k2, k5, k6)
print(256 * b + 32 * (0 if b == k2 else min(k2 - b, k3)))


(k1, k2, k3, k4) = map(int, input().split())
ewl = min(k3, k4)
zd = min(k1, ewl)
d = k1 - ewl
zs = 0
if d > 0:
	zs = min(d, k2)
print(zd * 256 + zs * 32)


def main():
	(k2, k3, k5, k6) = [int(x) for x in input().split()]
	tfs = min(k2, k5, k6)
	k2 -= tfs
	tt = min(k2, k3)
	print(tfs * 256 + tt * 32)
main()


s = input().split()
s = [int(i) for i in s]
min256 = min(s[0], s[2], s[3])
(s[0], s[2], s[3]) = (s[0] - min256, s[2] - min256, s[3] - min256)
summa = 256 * min256 + 32 * min(s[0], s[1])
print(summa)


(k1, k2, k3, k4) = map(int, input().split())
num256 = min(k1, k3, k4)
k1 -= min(k1, k3, k4)
num32 = min(k1, k2)
print(num256 * 256 + num32 * 32)


l = [int(n) for n in input().split()]
t256 = min(l[0], l[2], l[3])
t32 = min(l[1], l[0] - t256)
print(t256 * 256 + t32 * 32)


def main():
	[k2, k3, k5, k6] = [int(_) for _ in input().split()]
	k256 = min(k2, k5, k6)
	k2 -= k256
	k32 = min(k3, k2)
	print(256 * k256 + 32 * k32)
main()


import sys
(k2, k3, k5, k6) = map(int, input().split())
num1 = min(k2, k5, k6)
num2 = min(k2 - num1, k3)
res = 256 * num1 + 32 * num2
print(res)


n = list(map(int, input().split()))
x = min(n[0], n[2], n[3])
print(x * 256 + min(n[0] - x, n[1]) * 32)


k = list(map(int, input('').split(' ')))
i = [2, 3, 5, 6]
x = min(k[0], k[2], k[3])
count = 256 * x
(k[0], k[2], k[3]) = (k[0] - x, k[2] - x, k[3] - x)
y = min(k[0], k[1])
count += y * 32
print(count)


n = list(map(int, input().split()))
k2 = n[0]
k3 = n[1]
k5 = n[2]
k6 = n[3]
a = min(k2, k5, k6)
b = min(k2 - a, k3)
print(a * 256 + b * 32)


n = input().split()
my_list = []
result = 0
my_list.append('2 ' * int(n[0]))
my_list.append('3 ' * int(n[1]))
my_list.append('5 ' * int(n[2]))
my_list.append('6 ' * int(n[3]))
str1 = ''.join(my_list)
count2 = str1.count('2')
count3 = str1.count('3')
count5 = str1.count('5')
count6 = str1.count('6')
x = min(count2, count5, count6)
result += x * 256
z = count2 - x
y = min(z, count3)
if y > 0:
	result += y * 32
print(result)


(v2, v3, v5, v6) = map(int, input().split())
num_256 = min(v2, v5, v6)
num_32 = min(v2 - num_256, v3)
print(256 * num_256 + 32 * num_32)


a = list(map(int, input().split()))
i = min(a[0], a[2], a[3])
a[0] -= i
l = min(a[0], a[1])
print(i * 256 + l * 32)


(num_twos, num_threes, num_fives, num_sixes) = (int(num) for num in input().split())
print(256 * min(num_twos, num_fives, num_sixes) + 32 * min(num_twos - min(num_twos, num_fives, num_sixes), num_threes))


(a, b, c, d) = map(int, input().split())
m = min(a, c, d)
k = 256 * m
if a > m:
	a = a - m
	m1 = min(a, b)
	h = 32 * m1
else:
	h = 0
print(k + h)


(a, b, c, d) = list(map(int, input().split()))
s1 = min(a, c, d) * 256
a -= min(a, c, d)
s1 += min(a, b) * 32
print(s1)


p = input()
p = list(map(int, p.split()))
m = 0
m = min(p[0], p[2], p[3])
p[0] -= m
n = 0
if p[0] > 0:
	n = min(p[0], p[1])
c = 256 * m + 32 * n
print(c)


num = [int(i) for i in input().split()]
n = min(num[0], num[2], num[3])
print(n * 256 + 32 * min(num[1], num[0] - n))


(k2, k3, k5, k6) = map(int, input().split())
m = min(k2, k5, k6)
k2 -= m
r = m * 256
m = min(k2, k3)
r += m * 32
print(r)


from typing import Tuple

def parse_input() -> Tuple[int, int, int, int]:
	(k2, k3, k5, k6) = [int(x) for x in input().split()]
	return (k2, k3, k5, k6)

def solve(k2: int, k3: int, k5: int, k6: int) -> int:
	k256 = min(k2, k5, k6)
	k32 = min(k3, k2 - k256)
	return k256 * 256 + k32 * 32
(k2, k3, k5, k6) = parse_input()
print(solve(k2, k3, k5, k6))


(k2, k3, k5, k6) = map(int, input().split())
sm = min(k2, k5, k6)
ks = k2 - sm
sm1 = min(k3, ks)
print(sm * 256 + sm1 * 32)


l = [int(i) for i in input().split()]
t = 0
m = min(l[0], l[2], l[3])
t += m * 256
l[0] -= m
t += min(l[0], l[1]) * 32
print(t)


def antonAndDigits():
	n = list(map(int, input().split()))
	value = min(n[0], min(n[2], n[3]))
	n[0] -= value
	n[2] -= value
	n[3] -= value
	result = min(n[0], n[1])
	print(value * 256 + result * 32)
antonAndDigits()


(k2, k3, k5, k6) = map(int, input().split())
n256 = min(k2, k5, k6)
ans = n256 * 256
k2 -= n256
if k2 > 0:
	ans += min(k2, k3) * 32
print(ans)


(k2, k3, k5, k6) = map(int, input().split())
min256 = min(k2, k5, k6)
mmin256 = min256 * 256
if min256 == k2:
	k2 = 0
else:
	k2 -= min256
min32 = 0
if k2 == 0:
	min32 = 0
else:
	min32 = min(k2, k3)
mmin32 = min32 * 32
print(mmin256 + mmin32)


a = list(map(int, input().split()))
l = min(a[0], a[2], a[3])
p = 256 * l
a[0] = a[0] - l
m = min(a[0], a[1])
p = p + 32 * m
print(p)


def fun(ls):
	a = ls[0]
	b = ls[1]
	c = ls[2]
	d = ls[3]
	val256 = min(a, c, d)
	a -= val256
	c -= val256
	d -= val256
	val32 = min(b, a)
	print(val256 * 256 + val32 * 32)
T = 1
for i in range(T):
	ls = list(map(int, input().split()))
	fun(ls)


a = input().split()
a = [int(x) for x in a]
(a[0], a[1]) = (a[1], a[0])
d = min(a[1:])
print(d * 256 + max(0, min(a[0], a[1] - d)) * 32)


(k2, k3, k5, k6) = [int(x) for x in input().split()]
c1 = min(k2, k5, k6)
ans = c1 * 256
k2 -= c1
if k2 > 0:
	ans += 32 * min(k2, k3)
print(ans)


(k2, k3, k5, k6) = tuple(map(int, input().split(' ')))
count1 = min(k2, k5, k6)
count2 = min(k3, k2 - count1)
print(count1 * 256 + count2 * 32)


(k2, k3, k5, k6) = map(int, input().split())
t = min(k2, k5, k6)
k2 = k2 - t
th = min(k2, k3)
print(t * 256 + th * 32)


(two, three, five, six) = list(map(int, input().split()))
mini = min(two, five, six)
sum = 0
if mini > 0:
	for i in range(mini):
		sum += 256
two -= mini
mini = min(two, three)
if mini > 0:
	for i in range(mini):
		sum += 32
print(sum)


(a, b, c, d) = map(int, input().split())
t = min(a, c, d)
sum = t * 256
a = a - t
sum = sum + min(a, b) * 32
print(sum)


(d, t, p, c) = map(int, input().split())
n = min(d, p, c)
s = n * 256
d = abs(n - d)
t = min(d, t)
t = t * 32
print(s + t)


xs = list(map(int, input().split()))
cnt_256 = min(xs[0], xs[2], xs[3])
cnt_32 = min(xs[0] - cnt_256, xs[1])
print(cnt_256 * 256 + cnt_32 * 32)


(k2, k3, k5, k6) = map(int, input().split())
mn256 = min(k2, k5, k6)
mn32 = min(k2 - mn256, k3)
print(mn32 * 32 + mn256 * 256)


x = 4
z = input()
b = []
sum = 0
a = z.split(' ')
for g in range(x):
	b.append(int(a[g]))
(a, e, c, d) = b
r = min(a, c, d)
sum = sum + r * 256
a = a - r
q = min(a, e)
sum = sum + q * 32
print(sum)


(a, b, c, d) = map(int, input().split())
s = 0
x = min(a, c, d)
k = a - x
y = min(k, b)
s = x * 256 + 32 * y
print(s)


import time
(k2, k3, k5, k6) = (int(i) for i in input().split())
start = time.time()
n = min(k2, k5, k6)
m = min(k3, k2 - n)
ans = 256 * n + 32 * m
print(ans)
finish = time.time()


x = [int(p) for p in input().split(' ')]
c = min(x[0], x[2], x[3])
x[0] = x[0] - c
x[2] = x[2] - c
x[3] = x[3] - c
d = min(x[0], x[1])
print(256 * c + 32 * d)


l = [*map(int, input().split())]
SUM = min(l[0], l[2], l[3]) * 256
print(min(l[0] - SUM // 256, l[1]) * 32 + SUM)


(two, three, five, six) = input().strip().split(' ')
(two, three, five, six) = [int(two), int(three), int(five), int(six)]
ans1 = min(two, five, six)
two = two - ans1
ans2 = min(two, three)
print(ans2 * 32 + ans1 * 256)


def min(x, y):
	if x < y:
		return x
	else:
		return y
k = [int(i) for i in input().split()]
k2 = k[0]
k3 = k[1]
k5 = k[2]
k6 = k[3]
tot = 0
tot = min(min(k2, k5), min(k5, k6))
k2 = k2 - tot
sum = tot * 256
tot = min(k2, k3)
sum = sum + tot * 32
print(sum)


(k2, k3, k5, k6) = map(int, input().split())
no_of_256 = min(k2, k5, k6)
k2 -= no_of_256
k5 -= no_of_256
k6 -= no_of_256
no_of_32 = min(k3, k2)
print(256 * no_of_256 + 32 * no_of_32)


(w, e, t, y) = [int(x) for x in input().split()]
num = 0
a = min(w, t, y)
num += a * 256
w -= a
b = min(e, w)
num += b * 32
print(num)


(k2, k3, k5, k6) = map(int, input().split())
z = min(k2, k5, k6)
l = min(k3, k2 - z)
print(z * 256 + l * 32)


(k2, k3, k5, k6) = map(int, input().split())
d = min(k2, min(k5, k6))
m = abs(d - k2)
p = min(m, k3)
print(d * 256 + p * 32)


n = [int(x) for x in input().split()]
a = 256 * min(n[0], n[2], n[3])
(n[0], n[2], n[3]) = (n[0] - min(n[0], n[2], n[3]), n[2] - min(n[0], n[2], n[3]), n[3] - min(n[0], n[2], n[3]))
b = 32 * min(n[0], n[1])
print(a + b)


(a, b, c, d) = map(int, input().split())
l = [a, c, d]
m = min(l)
c = m * 256
a = a - m
if a > b:
	c = c + b * 32
else:
	c = c + a * 32
print(c)


(_2, _3, _5, _6) = map(int, input().split())
t = min(_2, min(_5, _6))
ans = 256 * t
_2 -= t
_5 -= t
_6 -= t
t = min(_2, _3)
ans += 32 * t
print(ans)


def main():
	(k2, k3, k5, k6) = map(int, input().split())
	n = min([k2, k5, k6])
	k2 -= n
	m = min([k2, k3])
	print(n * 256 + m * 32)
main()


(k2, k3, k5, k6) = input().split(' ')
(k2, k3, k5, k6) = (int(k2), int(k3), int(k5), int(k6))
num256 = min(k2, k5, k6)
k2 -= num256
k5 -= num256
k6 -= num256
num32 = min(k2, k3)
print(256 * num256 + 32 * num32)


def anton_digits(n):
	bigest_sum = 0
	n_256 = min(n[0], n[2], n[3])
	bigest_sum += n_256 * 256
	n[0] -= n_256
	n[2] -= n_256
	n[3] -= n_256
	n_32 = min(n[0], n[1])
	print(bigest_sum + n_32 * 32)
n = [int(el) for el in input().split()]
anton_digits(n)


(a2, a3, a5, a6) = list(map(int, input().split()))
a = min(a2, a5, a6)
b = min(a2 - a, a3)
print(a * 256 + b * 32)


from math import *
from copy import *
from string import *
from random import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
import math

def bin1(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = k ** mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin1(mid + 1, r, k, t, b, val, ans)
		else:
			return bin1(l, mid - 1, k, t, b, val, ans)

def bin2(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = t * k ** mid + b * mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin2(l, mid - 1, k, t, b, val, ans)
		else:
			return bin2(mid + 1, r, k, t, b, val, ans)

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	l = []
	for i in range(2, n + 1):
		if prime[i]:
			l.append(i)
	return l

def bin(l, r, ll, val):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		if val >= ll[mid][0] and val <= ll[mid][1]:
			return mid
		elif val < ll[mid][0]:
			return bin(l, mid - 1, ll, val)
		else:
			return bin(mid + 1, r, ll, val)

def deci(n):
	s = ''
	while n != 0:
		if n % 2 == 0:
			n = n // 2
			s = '0' + s
		else:
			n = n // 2
			s = '1' + s
	return s

def diff(s1, s2):
	if len(s1) < len(s2):
		v = len(s1)
		while v != len(s2):
			s1 = '0' + s1
			v = v + 1
	else:
		v = len(s2)
		while v != len(s1):
			s2 = '0' + s2
			v = v + 1
	c = 0
	for i in range(len(s1)):
		if s1[i:i + 1] != s2[i:i + 1]:
			c = c + 1
	return c
from sys import stdin, stdout

def fac(a, b):
	v = a
	while a != b:
		v *= a - 1
		a = a - 1
	return v

def bino(l, r, n):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		val1 = math.log(n / mid + 1, 2)
		val2 = int(val1)
		if val1 == val2:
			return val1
		elif val1 < 1.0:
			return bino(l, mid - 1, n)
		else:
			return bino(mid + 1, r, n)

def binary(l, r, ll, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		if ll[mid] <= val:
			ans = mid
			return binary(mid + 1, r, ll, val, ans)
		else:
			return binary(l, mid - 1, ll, val, ans)
(a, b, c, d) = map(int, stdin.readline().split(' '))
ans = min(min(a, c), d) * 256
a = a - min(min(a, c), d)
ans += min(a, b) * 32
print(ans)


import sys

def write_to_stdout(res):
	sys.stdout.write('%d\n' % res)

def read_input():
	return [int(_) for _ in input().rstrip().split()]

def get_answer(numbers):
	(n_2, n_3, n_5, n_6) = numbers
	n_256 = min(n_2, n_5, n_6)
	n_32 = min(n_3, n_2 - n_256)
	return n_32 * 32 + n_256 * 256

def main():
	numbers = read_input()
	answer = get_answer(numbers)
	write_to_stdout(answer)
main()


class CodeforcesTask734BSolution:

	def __init__(self):
		self.result = ''
		self.kkkk = []

	def read_input(self):
		self.kkkk = [int(x) for x in input().split(' ')]

	def process_task(self):
		c256 = min(self.kkkk[0], self.kkkk[2], self.kkkk[3])
		self.kkkk[0] -= c256
		c32 = min(self.kkkk[0], self.kkkk[1])
		self.result = str(c256 * 256 + c32 * 32)

	def get_result(self):
		return self.result
Solution = CodeforcesTask734BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


from sys import stdin
k = [int(i) for i in stdin.readline().split(' ')]
print(256 * min(k[0], k[2], k[3]) + 32 * min(k[1], k[0] - min(k[0], k[2], k[3])))


k = input().split()
for i in range(4):
	k[i] = int(k[i])
k256 = min(k[0], k[2], k[3])
k32 = min(k[0] - k256, k[1])
print(k256 * 256 + k32 * 32)


(k2, k3, k5, k6) = map(int, input().split())
k256 = min(k2, k5, k6)
k32 = min(k3, k2 - k256)
print(k256 * 256 + k32 * 32)


l = list(map(int, input().split()))
l1 = l[:1] + l[2:4]
x = min(l1) * 256
l[0] = l[0] - min(l1)
l2 = l[:2]
x = x + min(l2) * 32
print(x)


ch = input()
A = ch.split()
L = [int(i) for i in A]
s = 0
while 1:
	if (L[0] != 0) & (L[2] != 0) & (L[3] != 0):
		s += 256
		L[0] = L[0] - 1
		L[2] = L[2] - 1
		L[3] = L[3] - 1
	elif (L[0] != 0) & (L[1] != 0) & (L[2] == 0 or L[3] == 0):
		s += 32
		L[0] -= 1
		L[1] -= 1
	else:
		break
print(s)


w = input().split()
k2 = int(w[0])
k3 = int(w[1])
k5 = int(w[2])
k6 = int(w[3])
numSum = 0
num256 = min(k2, k5, k6)
num32 = min(k2 - num256, k3)
numSum = num256 * 256 + num32 * 32
print(numSum)


(q, w, e, r) = map(int, input().split())
m = min(q, e, r)
n = min(q - m, w)
print(m * 256 + n * 32)


(two, three, five, six) = map(int, input().split())
ans = min(two, five, six) * 256
two -= min(two, five, six)
ans += 32 * min(two, three)
print(ans)


a = input().split()
d2 = int(a[0])
d3 = int(a[1])
d5 = int(a[2])
d6 = int(a[3])
jumlah = 0
lst256 = [d2, d5, d6]
if min(d2, d3, d5, d6) == d2:
	jumlah += 256 * d2
elif min(d2, d3, d5, d6) == d3:
	jumlah += 256 * min(d2, d5, d6)
	d2 -= min(d2, d5, d6)
	jumlah += 32 * min(d3, d2)
else:
	a = min(d2, d3, d5, d6)
	jumlah += 256 * a
	d2 -= a
	jumlah += 32 * min(d3, d2)
print(jumlah)


(k2, k3, k5, k6) = map(int, input().split())
sum = 0
min_n_256 = min(k2, k5, k6)
new_sum = min_n_256 * 256
k2 -= min_n_256
min_n_32 = min(k3, k2)
new_sum2 = min_n_32 * 32
print(new_sum + new_sum2)


(a2, a3, a5, a6) = input().split()
(a2, a3, a5, a6) = (int(a2), int(a3), int(a5), int(a6))
k = 1
sum = 0
am = min(a2, a5, a6)
a2 -= am
a5 -= am
a6 -= am
sum += am * 256
am1 = min(a2, a3)
a2 -= am1
a3 -= am1
sum += am1 * 32
print(sum)


(two, three, five, six) = list(map(int, input().split()))
minX = min(two, five, six)
result = minX * 256
minY = min(two - minX, three)
print(result + minY * 32)


giris = input().split(' ')
k2 = int(giris[0])
k3 = int(giris[1])
k5 = int(giris[2])
k6 = int(giris[3])
ikiBesAlti = min(k2, k5, k6)
k2 -= ikiBesAlti
ucIki = min(k3, k2)
print(ikiBesAlti * 256 + ucIki * 32)


a = list(map(int, input().split()))
count = 0
T = a[1]
del a[1]
for i in range(min(a)):
	count += 256
if a[0] - min(a) > 0:
	if T > a[0] - min(a):
		c = a[0] - min(a)
	if T <= a[0] - min(a):
		c = T
	for i in range(c):
		count += 32
print(count)


li = [int(i) for i in input().split()]
c3 = li[1]
li.remove(c3)
k = min(li)
tot = 256 * k
c2 = li[0] - k
c4 = min(c2, c3)
tot += c4 * 32
print(tot)


(p1, p2, p3, p4) = map(int, input().split())
q = min(p1, p3, p4)
z = 256 * q
p1 -= q
z += 32 * min(p1, p2)
print(z)


(k2, k3, k5, k6) = list(map(int, input().split()))
k56 = min(k5, k6)
print(min(k56, k2) * 256 + max(0, min(k2 - k56, k3)) * 32)


(k2, k3, k5, k6) = map(int, input().split())
s = 0
temp = min(k2, k5, k6)
s += 256 * min(k2, k5, k6)
k2 -= min(k2, k5, k6)
k5 -= min(k2, k5, k6)
k6 -= min(k2, k5, k6)
s += 32 * min(k2, k3)
print(str(s), end='')


a = list(map(int, input().split()))
sum = min(a[0:1] + a[2:]) * 256
sum += min(a[0] - min(a[0:1] + a[2:]), a[1]) * 32
print(sum)


(two, three, five, six) = map(int, input().split())
b = min(two, five, six)
two = two - b
s = min(three, two)
print(b * 256 + 32 * s)


def smaller(x, y):
	if x < y:
		return x
	return y
(K2, K3, K5, K6) = map(int, input().split())
count256 = smaller(K2, smaller(K5, K6))
K2 -= count256
K5 -= count256
K6 -= count256
count32 = smaller(K2, K3)
print(256 * count256 + 32 * count32)


(n2, n3, n5, n6) = input().split(' ')
(n2, n3, n5, n6) = (int(n2), int(n3), int(n5), int(n6))
total = 0
min_256 = min(n2, n5, n6)
n2 = n2 - min_256
total += 256 * min_256
total += 32 * min(n3, n2)
print(total)


(k2, k3, k5, k6) = list(map(int, input().split()))
large = min(k2, k5, k6)
t = 256 * large
k2 -= large
small = max(0, min(k2, k3))
t += 32 * small
print(t)


ls = [int(i) for i in input().split()]
no_of_256 = min(ls[0], ls[2], ls[3])
no_of_32 = min(ls[1], ls[0] - no_of_256)
print(256 * no_of_256 + 32 * no_of_32)


(k3, k2, k5, k6) = map(int, input().split())
f1 = k2
f2 = min(k5, k6)
if f2 >= k3:
	print(256 * k3)
else:
	res = 256 * f2
	k3 -= f2
	k3 = min(k2, k3)
	res += k3 * 32
	print(res)


k = input().split()
for i in range(0, len(k)):
	k[i] = int(k[i])
s = 0
while True:
	if k[2] and k[3] and k[0]:
		_min = min(k[2], k[3], k[0])
		k[2] -= 1 * _min
		k[3] -= 1 * _min
		k[0] -= 1 * _min
		s += 256 * _min
	elif k[0] and k[1]:
		_min = min(k[0], k[1])
		k[0] -= 1 * _min
		k[1] -= 1 * _min
		s += 32 * _min
	else:
		break
print(s)


f = lambda : map(int, input().split())
(k2, k3, k5, k6) = f()
s = 0
s += 256 * min(k2, k5, k6)
k2 -= min(k2, k5, k6)
print(s + 32 * min(k2, k3))


(k2, k3, k5, k6) = map(int, input().split())
n = min(k2, k5, k6)
s = n * 256
k2 -= n
if k2 > 0:
	s += min(k2, k3) * 32
print(s)


l = []
l = [int(x) for x in input().split()]
s = 0
small = -1
if l[0] > 0 and l[2] > 0 and (l[3] > 0):
	if l[0] < l[2] and l[0] < l[3]:
		small = l[0]
	elif l[2] < l[3]:
		small = l[2]
	else:
		small = l[3]
	s = s + small * 256
	l[0] = l[0] - small
	l[2] = l[2] - small
	l[3] = l[3] - small
if l[0] > 0 and l[1] > 0:
	if l[0] < l[1]:
		small = l[0]
	else:
		small = l[1]
	s = s + small * 32
	l[0] = l[0] - small
	l[1] = l[1] - small
print(s)


n = [int(i) for i in input().split()]
k = [n[0], n[2], n[3]]
for i in range(3):
	for j in range(i, 3):
		if k[i] > k[j]:
			(k[i], k[j]) = (k[j], k[i])
if k[0] == n[0]:
	n[0] = 0
else:
	n[0] = n[0] - k[0]
if n[1] >= n[0]:
	l = n[0]
	n[1] = n[1] - n[0]
else:
	l = n[1]
	n[0] = n[0] - n[1]
print(k[0] * 256 + l * 32)


(k2, k3, k5, k6) = [int(i) for i in input().split()]
lno = min(k2, min(k5, k6))
ans = 256 * lno
if k2 - lno > 0:
	sno = min(k2 - lno, k3)
	ans += 32 * sno
print(ans)


l = list(input().split())
k2 = int(l[0])
k3 = int(l[1])
k5 = int(l[2])
k6 = int(l[3])
sum = 0
i = min(k2, k5, k6)
sum += i * 256
j = min(k3, k2 - i)
sum += j * 32
print(sum)


(k2, k3, k5, k6) = map(int, input().split())
m1 = min(k2, k5, k6)
k2 -= m1
k5 -= m1
k6 -= m1
m2 = min(k2, k3)
print(256 * m1 + 32 * m2)


(k2, k3, k5, k6) = map(int, input().split())
first_num = min(k2, k5, k6)
k2 -= first_num
num_sum = first_num * 256
num_sum += min(k2, k3) * 32
print(num_sum)


def solve():
	k = [int(s) for s in input().split()]
	ans = min(k[0], k[2], k[3])
	if ans == k[0]:
		print(ans * 256)
	else:
		print(ans * 256 + min(k[0] - ans, k[1]) * 32)
solve()


(k2, k3, k5, k6) = [int(el) for el in input().split()]
k256 = min(k2, k5, k6)
k2 -= k256
k32 = min(k2, k3)
ans = 256 * k256 + 32 * k32
print(ans)


z = list(map(int, input().split(' ')))
a = min(z[0], z[2], z[3])
print(256 * a + min(z[0] - a, z[1]) * 32)


[k2, k3, k5, k6] = [int(x) for x in input().split()]
twofivesix = min(k2, k5, k6)
k2 -= twofivesix
k5 -= twofivesix
k6 -= twofivesix
value = twofivesix * 256
threetwo = min(k2, k3)
value += threetwo * 32
print(value)


x = list(map(int, input().split()))
m = min(x[0], x[2], x[3])
x[0] -= m
p = min(x[0], x[1])
print(256 * m + p * 32)


n = list(map(int, input().split()))
(k2, k3, k5, k6, sum) = (n[0], n[1], n[2], n[3], 0)
while k2 and k5 and k6:
	k2 -= 1
	k5 -= 1
	k6 -= 1
	sum += 256
while k2 and k3:
	k2 -= 1
	k3 -= 1
	sum += 32
print(sum)


(a, b, c, d) = [int(i) for i in input().split()]
print(min(a, c, d) * 256 + min(a - min(a, c, d), b) * 32)


d = list(map(int, input().split()))
t256 = min(d[0], d[2], d[3])
ans = t256 * 256
d[0] -= t256
t32 = min(d[0], d[1])
ans += 32 * t32
print(ans)


(k2, k3, k5, k6) = map(int, input().split())
s = 0
if k6 >= k2 <= k5:
	s += 256 * k2
elif k2 >= k6 <= k5:
	s += 256 * k6
	s += 32 * (k2 - k6) if k3 > k2 - k6 else 32 * k3
elif k2 >= k5 <= k6:
	s += 256 * k5
	s += 32 * (k2 - k5) if k3 > k2 - k5 else 32 * k3
print(s)


def can_compose_256(k2, k5, k6):
	return 0 not in (k2, k5, k6)

def can_compose_32(k3, k2):
	return 0 not in (k3, k2)
(k2, k3, k5, k6) = map(int, input().split())
total = 0
while can_compose_256(k2, k5, k6):
	total += 256
	(k2, k5, k6) = map(lambda x: x - 1, [k2, k5, k6])
while can_compose_32(k3, k2):
	total += 32
	(k3, k2) = map(lambda x: x - 1, [k3, k2])
print(total)


x = input()
(a, b, c, d) = map(int, x.split())
p = min(c, d)
if a > p:
	tot = 256 * p
	a = a - p
	tot += 32 * min(a, b)
else:
	tot = 256 * a
print(tot)


(k2, k3, k5, k6) = [int(x) for x in input().split()]
d = 0
for i in range(min(k2, k5, k6)):
	d += 256
for j in range(min(k3, k2 - min(k2, k5, k6))):
	d += 32
print(d)


(v1, v2, v3, v4) = map(int, input().split())
number = {2: v1, 3: v2, 5: v3, 6: v4}
(num_256, num_32) = (0, 0)
min_number = min(number[2], number[5], number[6])
number[2] -= min_number
number[5] -= min_number
number[6] -= min_number
num_256 += min_number
if number[2] > 0:
	min_number = min(number[2], number[3])
	num_32 += min_number
print(256 * num_256 + 32 * num_32)


def main():
	(a, b, c, d) = map(int, input().split())
	ans = 256 * min(a, c, d) + 32 * min(a - min(a, c, d), b)
	print(ans)
main()


(a, b, c, d) = map(int, input().split())
m = min(a, c, d)
if a != m:
	n = min(a - m, b)
else:
	n = 0
print(256 * m + 32 * n)


(k2, k3, k5, k6) = list(map(int, input().split()))
b = min(k2, min(k5, k6))
result = 0
k2 -= b
k5 -= b
k6 -= b
result += 256 * b
c = min(k2, k3)
result += 32 * c
print(result)


(a, b, c, d) = map(int, input().split())
ma25 = min(a, c, d)
ma32 = min(a - ma25, b)
m32 = min(a, b)
m25 = min(a - m32, c, d)
print(max(ma25 * 256 + ma32 * 32, m25 * 256 + m32 * 32))


(k2, k3, k5, k6) = map(int, input().split())
r1 = min(k2, min(k5, k6))
r2 = min(k2 - r1, k3)
t = 256 * r1 + 32 * r2
print(t)


(k2, k3, k5, k6) = map(int, input().split())
o = [k2, k6, k5]
w_256 = min(o)
k2 -= w_256
p = [k2, k3]
j = min(p)
print(w_256 * 256 + j * 32)


(k, l, m, n) = map(int, input().split())
k = str(2) * k
l = str(3) * l
m = str(5) * m
n = str(6) * n
t = min(len(k), len(m), len(n))
k = str(2) * (len(k) - t)
d = min(len(k), len(l))
print(256 * t + 32 * d)


(c2, c3, c5, c6) = map(int, input().split())
least = 1
ans = 0
if c2 < c5 and c2 < c6:
	least = c2
elif c5 < c6:
	least = c5
else:
	least = c6
ans = least * 256
c2 = c2 - least
if c2 > c3:
	ans += c3 * 32
else:
	ans += c2 * 32
print(ans)


k = input().split()
k2 = int(k[0])
k3 = int(k[1])
k5 = int(k[2])
k6 = int(k[3])
min_256 = min(k2, k5, k6)
k2 -= min_256
k5 -= min_256
k6 -= min_256
min_32 = min(k2, k3)
print('{}'.format(256 * min_256 + 32 * min_32))


p = input().rstrip().split(' ')
k2 = int(p[0])
k3 = int(p[1])
k5 = int(p[2])
k6 = int(p[3])
A = min(k2, k5, k6)
S = k2 - A
B = min(k3, S)
print(256 * A + 32 * B)


(k2, k3, k5, k6) = map(int, input().split())
result = int(0)
tmp = min(k2, k5, k6)
result += tmp * 256
k2 -= tmp
k5 -= tmp
k6 -= tmp
tmp = min(k2, k3)
result += tmp * 32
k2 -= tmp
k3 -= tmp
print(result)


a = list(map(int, input().split()))
b = a[:]
del b[1]
c = min(b)
sums = 0
for i in range(1, c + 1):
	sums += 256
	a[0] = a[0] - 1
	a[2] = a[2] - 1
	a[3] = a[3] - 1
d = min(a[0], a[1])
for j in range(1, d + 1):
	sums += 32
print(sums)


(k2, k3, k5, k6) = list(map(int, input().split()))
mn_56 = min(k5, k6)
mn_256 = min(mn_56, k2)
rest_k2 = k2 - mn_256
k32 = min(k3, rest_k2)
print(mn_256 * 256 + k32 * 32)


(a, b, c, d) = map(int, input().split())
h = min(a, d, c)
a = max(a - h, 0)
r = min(a, b)
a = h * 256 + r * 32
print(a)


(k1, k2, k3, k4) = map(int, input().split())
kolvo = min(k1, k3, k4)
k1 -= kolvo
k3 -= kolvo
k4 -= kolvo
kolvo *= 256
kolvo += min(k1, k2) * 32
print(kolvo)


def method1(a):
	r = min([a[0], a[2], a[3]])
	z = r * 256
	s = 32 * min([a[0] - r, a[1]])
	return z + s

def method2(b):
	r = min([b[0], b[1]])
	z = r * 32
	s = 256 * min([b[0] - r, b[2], b[3]])
	return z + s
l = list(map(int, input().split()))
m = l.copy()
x = method1(l)
y = method2(m)
if x >= y:
	print(x)
else:
	print(y)


l = list(map(int, input().split()))
mi = min(l[0], l[2], l[3])
su = 256 * mi
(l[0], l[2], l[3]) = (l[0] - mi, l[2] - mi, l[3] - mi)
mi = min(l[0], l[1])
su += 32 * mi
print(su)


def Five():
	(k2, k3, k5, k6) = list(map(int, input().split()))
	tfs = min(k2, k5, k6)
	k2 -= tfs
	tt = min(k2, k3)
	print(tfs * 256 + tt * 32)
Five()


(a, b, c, d) = map(int, input().split())
p = [a, c, d]
x = min(p)
l = a - x
if l <= b:
	ttl = 256 * x + l * 32
else:
	ttl = 256 * x + b * 32
print(ttl)


(k2, k3, k5, k6) = map(int, input().split())
fk256 = min(k2, k5, k6)
fk32 = min(k2 - fk256, k3)
sk32 = min(k2, k3)
sk256 = min(k2 - sk32, k5, k6)
print(max(32 * fk32 + 256 * fk256, 32 * sk32 + 256 * sk256))


(a2, a3, a5, a6) = map(int, input().split())
c = 0
m = min(a2, min(a5, a6))
M = min(a2 - m, a3)
print(m * 256 + M * 32)


a = input().split()
dizio = {'2': 0, '3': 0, '5': 0, '6': 0}
cont = 0
l = []
for x in dizio:
	dizio[x] = int(a[cont])
	cont += 1
for x in dizio:
	if x != '3':
		l.append(dizio[x])
somma = 0
minimo = min(l)
somma += 256 * minimo
dizio['2'] -= minimo
l2 = []
for x in dizio:
	if x != '5' and x != '6':
		l2.append(dizio[x])
minimo = min(l2)
somma += 32 * minimo
print(somma)


inp = list(map(int, input().split()))
k2 = inp[0]
k3 = inp[1]
k5 = inp[2]
k6 = inp[3]
sum = 0
sum += 256 * min(k2, k5, k6)
k2 = k2 - min(k2, k5, k6)
k5 = k5 - min(k2, k5, k6)
k6 = k6 - min(k2, k5, k6)
sum += 32 * min(k2, k3)
print(sum)


from __future__ import division, print_function
import itertools, os, sys, threading
from collections import deque, Counter, OrderedDict, defaultdict
import heapq
from math import ceil, floor, log, sqrt, factorial, pow, pi, gcd

def ii():
	return int(input())

def si():
	return str(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
graph = defaultdict(list)
visited = [0] * 1000000
col = [-1] * 1000000

def dfs(v, c):
	if visited[v]:
		if col[v] != c:
			print('-1')
			exit()
		return
	col[v] = c
	visited[v] = 1
	for i in graph[v]:
		dfs(i, c ^ 1)

def bfs(d, v):
	q = []
	q.append(v)
	visited[v] = 1
	while len(q) != 0:
		x = q[0]
		q.pop(0)
		for i in d[x]:
			if visited[i] != 1:
				visited[i] = 1
				q.append(i)
		print(x)
	print(l)

def make_graph(e):
	d = {}
	for i in range(e):
		(x, y) = mi()
		if x not in d.keys():
			d[x] = [y]
		else:
			d[x].append(y)
		if y not in d.keys():
			d[y] = [x]
		else:
			d[y].append(x)
	return d

def gr2(n):
	d = {}
	for i in range(n):
		(x, y) = mi()
		if x not in d.keys():
			d[x] = [y]
		else:
			d[x].append(y)
	return d

def connected_components(graph):
	seen = set()

	def dfs(v):
		vs = set([v])
		component = []
		while vs:
			v = vs.pop()
			seen.add(v)
			vs |= set(graph[v]) - seen
			component.append(v)
		return component
	ans = []
	for v in graph:
		if v not in seen:
			d = dfs(v)
			ans.append(d)
	return ans
l = li()
x = min(l[0], l[2], l[3])
y = x * 256
l[0] -= x
l[2] -= x
l[3] -= x
z = min(l[0], l[1])
y += z * 32
print(y)


from sys import stdin, stdout
import bisect

def st():
	return list(stdin.readline())

def inp():
	return int(stdin.readline())

def li():
	return list(map(int, stdin.readline().split()))

def mp():
	return map(int, stdin.readline().split())

def pr(n):
	stdout.write(str(n) + '\n')

def soe(limit):
	l = [1] * (limit + 1)
	prime = []
	for i in range(2, limit + 1):
		if l[i]:
			for j in range(i * i, limit + 1, i):
				l[j] = 0
	for i in range(2, limit + 1):
		if l[i]:
			prime.append(i)
	return prime

def segsoe(low, high):
	limit = int(high ** 0.5) + 1
	prime = soe(limit)
	n = high - low + 1
	l = [0] * (n + 1)
	for i in range(len(prime)):
		lowlimit = low // prime[i] * prime[i]
		if lowlimit < low:
			lowlimit += prime[i]
		if lowlimit == prime[i]:
			lowlimit += prime[i]
		for j in range(lowlimit, high + 1, prime[i]):
			l[j - low] = 1
	for i in range(low, high + 1):
		if not l[i - low]:
			if i != 1:
				print(i)

def power(a, n):
	r = 1
	while n:
		if n & 1:
			r = r * a
			n = n - 1
		else:
			a = a * a
			n = n >> 1
	return r

def solve():
	(a, b, c, d) = mp()
	f = min(a, c, d)
	d = 256 * f
	a -= f
	fk = min(a, b)
	d += 32 * fk
	pr(d)
solve()


(a, b, c, d) = (int(i) for i in input().split())
k = min(c, d)
n1 = 256
s = n1 * min(k, a)
a -= min(k, a)
if a > 0:
	s += 32 * min(a, b)
print(s)


z = list(map(int, input().split()))
arr = []
while z[0] > 0 and z[2] > 0 and (z[3] > 0):
	arr.append(256)
	z[0] -= 1
	z[2] -= 1
	z[3] -= 1
while z[0] > 0 and z[1] > 0:
	arr.append(32)
	z[0] -= 1
	z[1] -= 1
print(sum(arr))


(k1, k2, k3, k4) = map(int, input().split())
j = min(k1, k3, k4)
count = 0
k1 -= j
count += j * 256
if k2 > 0:
	l = min(k1, k2)
	count += l * 32
print(count)


(two, three, five, six) = map(int, input().split())
biggest = min(two, five, six)
result = biggest * 256
two -= biggest
smallest = min(two, three)
result += smallest * 32
print(result)


(a, b, c, d) = input().split()
a = int(a)
b = int(b)
c = int(c)
d = int(d)
k = min(a, c, d)
a = a - k
k1 = min(a, b)
print(k * 256 + k1 * 32)


(a, b, c, d) = list(map(int, input().split()))
u = min([a, c, d])
t = u * 256
t += min([b, a - u]) * 32
print(t)


(k2, k3, k5, k6) = [int(w) for w in input().split()]
m256 = min(k2, k5, k6)
m32 = min(k3, k2 - m256)
print(256 * m256 + 32 * m32)


(k2, k3, k5, k6) = map(int, input().split())
m = min(k2, k5, k6)
ans = 0
ans += m * 256
n = min(k2 - m, k3)
ans += n * 32
print(ans)


inp = input().split(' ')
inp = [int(inp[i]) for i in range(4)]
two = int(inp[0])
three = int(inp[1])
five = int(inp[2])
six = int(inp[3])
num256 = min(two, five, six)
two -= num256
num32 = min(two, three)
print(num256 * 256 + num32 * 32)


(a2, a3, a5, a6) = map(int, input().split())
s256 = min(a2, a5, a6)
a2 -= s256
a5 -= s256
a6 -= s256
s32 = min(a2, a3)
print(s256 * 256 + s32 * 32)


s = [int(n) for n in input().split()]
k = min(s[0], s[2], s[3])
m = k * 256
s[0] -= k
s[2] -= k
s[3] -= k
j = min(s[0], s[1])
m += j * 32
print(m)


(a, b, c, d) = map(int, input().split())
s = 0
s1 = 0
cnt = min(a, c, d)
s1 += 256 * cnt
a -= cnt
c -= cnt
d -= cnt
if a > 0:
	s1 += 32 * min(a, b)
print(s1)


(a, b, c, d) = list(map(int, input().split()))
m = min(a, c, d)
a -= m
c -= m
d -= m
ans = 256 * m
ans += 32 * min(a, b)
print(ans)


import math
(k2, k3, k5, k6) = list(map(int, input().split()))
if min(k2, k5, k6) == k2:
	n256 = k2
	n32 = 0
elif min(k2, k5, k6) == k5:
	n256 = k5
	n32 = min(k2 - k5, k3)
else:
	n256 = k6
	n32 = min(k2 - k6, k3)
sum = n32 * 32 + n256 * 256
print(sum)


l = list(map(int, input().split()))
sub256 = min(l[0], l[2], l[3])
l[0] = abs(l[0] - sub256)
l[2] = abs(l[2] - sub256)
l[3] = abs(l[3] - sub256)
sub32 = min(l[0], l[1])
ans1 = 0
ans2 = 0
for i in range(sub256):
	ans1 += 256
for i in range(sub32):
	ans2 += 32
print(ans1 + ans2)


l = list(map(int, input().split()))
s1 = min(l[0], l[2], l[3]) * 256
s2 = min(l[0] - min(l[0], l[2], l[3]), l[1]) * 32
print(s1 + s2)


(tw, th, fv, sx) = map(int, input().split())
print(min(tw, fv, sx) * 256 + min(th, tw - min(tw, fv, sx)) * 32)


d = input().split()
d = [int(x) for x in d]
(k2, k3, k5, k6) = (d[0], d[1], d[2], d[3])
S = min(k2, k6, k5) * 256
k2 -= min(k2, k6, k5)
k6 -= min(k2, k6, k5)
k5 -= min(k2, k6, k5)
S += min(k2, k3) * 32
print(S)


k = list(map(int, input().split()))
t = min(k[0], k[2], k[3])
k[0] = k[0] - t
c = 0
s = min(k[0], k[1])
for j in range(t):
	c = c + 256
for i in range(s):
	c = c + 32
print(c)


(k2, k3, k5, k6) = map(int, input().split())
total = 0
total += min(k2, k5, k6) * 256
k2 -= min(k2, k5, k6)
total += min(k2, k3) * 32
print(total)


def main():
	(k2, k3, k5, k6) = map(int, input().split(' '))
	x = min(k2, k5, k6)
	s = 0
	s += 256 * x
	k2 -= x
	k5 -= x
	k6 -= x
	y = min(k2, k3)
	s += 32 * y
	return s
print(main())


a = input().split()
a = [int(x) for x in a]
temp = [a[0]]
temp2 = a[2]
temp.append(a[2])
temp.append(a[3])
min_temp = min(temp)
res = 256 * min_temp
if a[0] == min_temp:
	print(res)
else:
	a[0] = a[0] - min_temp
	print(res + min(a[0], a[1]) * 32)


inp = list(map(int, input().rstrip().split()))
result = 0
k2 = inp[0]
k3 = inp[1]
k5 = inp[2]
k6 = inp[3]
m = min(k2, k5, k6)
k2 -= m
result += m * 256
m = min(k2, k3)
result += m * 32
print(result)


(k2, k3, k5, k6) = input().split()
(k2, k3, k5, k6) = [int(k2), int(k3), int(k5), int(k6)]
a256 = min(k2, k5, k6) * 256
a32 = 0
if min(k2, k5, k6) < k2:
	k2 = k2 - min(k2, k5, k6)
	a32 = min(k2, k3) * 32
print(a256 + a32)


from sys import stdin
from sys import stdout
(k2, k3, k5, k6) = (int(x) for x in stdin.readline()[:-1].split(' '))
k256 = min(min(k2, k5), k6)
k2 -= k256
k32 = min(k2, k3)
stdout.write(str(k256 * 256 + k32 * 32))


def read_tokens():
	return input().strip().split(' ')

def read_ints():
	return [int(s) for s in read_tokens()]

def compute(arr):
	curr_sum = 0
	count_of_256 = min(arr[0], arr[2], arr[3])
	for (idx, el) in enumerate(arr):
		if idx != 1:
			arr[idx] -= count_of_256
	curr_sum += 256 * count_of_256
	count_of_32 = min(arr[0], arr[1])
	curr_sum += 32 * count_of_32
	return curr_sum
arr = read_ints()
ans = compute(arr)
print(ans)


(t, th, fi, si) = map(int, input().split())
ma = min(t, min(fi, si))
count = 256 * ma
t = t - ma
ma = min(t, th)
count += 32 * ma
print(count)


digits = [2, 3, 5, 6]
string = input()
numbers = string.split(' ')
for x in range(4):
	numbers[x] = int(numbers[x])
maximum = min([numbers[0], numbers[2], numbers[3]])
numbers[0] -= maximum
maximum *= 256
maximum += min([numbers[0], numbers[1]]) * 32
print(maximum)


(e, s, w, l) = map(int, input().split())
k = min(w, l)
if e <= k:
	print(256 * e)
else:
	e = e - k
	if e <= s:
		print(256 * k + 32 * e)
	else:
		print(256 * k + 32 * s)


q = list(map(int, input().split()))
e = min(q[0], q[2], q[3])
f = min(q[0] - e, q[1])
print((e << 8) + (f << 5))


(a, b, c, d) = map(int, input().split())
f = min(a, c, d)
print(32 * (8 * f + min(a - f, b)))


def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())
l = inlt()
a = l[0]
b = l[1]
c = l[2]
d = l[3]
p = min(c, d, a)
a -= p
res = 256 * p
res += 32 * min(a, b)
print(res)


(k2, k3, k5, k6) = map(int, input().split())
s = min(k2, k5, k6)
m = 256 * s
k2 -= s
k5 -= s
k6 -= s
if k3 > 0 and k2 > 0:
	k = min(k3, k2)
	m += 32 * k
print(m)


a = [int(i) for i in input().split()]
b = min(a[0], a[2], a[3])
c = min(a[0] - b, a[1])
sum = b * 256 + c * 32
print(sum)


lst = input().split()
lst = [int(i) for i in lst]
amount_256 = min(lst[0], lst[2], lst[3])
lst[0] -= amount_256
lst[2] -= amount_256
lst[3] -= amount_256
amount_32 = min(lst[0], lst[1])
result = amount_256 * 256 + amount_32 * 32
print(result)


[twos, threes, fives, sixes] = [int(i) for i in input().split()]
minimum_256 = min(twos, fives, sixes)
twos = twos - minimum_256
totalSum = minimum_256 * 256 + min(threes, twos) * 32
print(totalSum)


(a, b, c, d) = map(int, input().split())
(dict, dict1, A) = ({}, {}, 9999999)
dict1.update({3: b})
dict.update({2: a})
dict.update({5: c})
dict.update({6: d})
for (key, values) in dict.items():
	A = min(A, values)
if dict1[3] <= dict[2] - A:
	H = dict1[3]
else:
	H = dict[2] - A
print(256 * A + H * 32)


l = list(map(int, input().split()))
(c256, c32) = (0, 0)
if l[0] > 0 and l[2] > 0 and (l[3] > 0):
	m = min(l[0], l[2], l[3])
	(l[0], l[2], l[3]) = (l[0] - m, l[2] - m, l[3] - m)
	c256 = m
if l[0] > 0 and l[1] > 0:
	m1 = min(l[0], l[1])
	c32 = m1
ans = 256 * c256 + 32 * c32
print(ans)


(k2, k3, k5, k6) = map(int, input().split())
s = 0
c = min(k5, k6, k2)
s += c * 256
k2 -= c
s += min(k2, k3) * 32
print(s)


(k2, k3, k5, k6) = map(int, input().split())
sum = int()
i256 = int()
i32 = int()
i256 = min(k2, k5, k6)
k2 -= i256
k5 -= i256
k6 -= i256
i32 = min(k2, k3)
sum = i256 * 256 + i32 * 32
print(sum)


(a, b, c, d) = map(int, input().split())
S = 0
S = 256 * min(a, c, d)
a = a - min(a, c, d)
c = c - min(a, c, d)
d = d - min(a, c, d)
S = S + 32 * min(a, b)
print(S)


i = input()
info = i.split(' ')
info = [int(i) for i in info]
total = 0
min1 = int(min([info[0]] + info[2:]))
total += 256 * min1
info[0] -= 1 * min1
info[2:] = [a - 1 * min1 for a in info[2:]]
min2 = int(min([info[0]] + [info[1]]))
total += 32 * min2
print(total)


def main():
	from sys import stdin, stdout
	(a, b, c, d) = map(int, stdin.readline().split())
	min256 = min(a, c, d)
	ksum = 256 * min256
	a -= min256
	min32 = min(a, b)
	ksum += min32 * 32
	stdout.write(str(ksum))
main()


def small_3(num1, num2, num3):
	if num1 <= num2 and num1 <= num3:
		return num1
	elif num2 <= num1 and num2 <= num3:
		return num2
	else:
		return num3

def small_2(num1, num2):
	if num1 < num2:
		return num1
	else:
		return num2
(a, b, c, d) = [int(i) for i in input().split()]
sum = 0
least = small_3(a, c, d)
for i in range(0, least, 1):
	sum += 256
remaining = a - least
thirty_two = small_2(remaining, b)
for i in range(0, thirty_two, 1):
	sum += 32
print(sum)


(a, b, c, d) = map(int, input().split())
tfs = min(a, c, d)
foo = tfs * 256
a -= tfs
foo += min(a, b) * 32
print(foo)


k = [int(s) for s in input().split(' ')]
count = min(k[0], k[2], k[3])
k[0] -= count
k[2] -= count
k[3] -= count
count *= 256
count += 32 * min(k[0], k[1])
print(count)


s = input().split()
lt = [int(i) for i in s]
(a, b, c, d) = (lt[0], lt[1], lt[2], lt[3])
x = min(a, c, d)
(a, c, d) = (a - x, c - x, d - x)
y = min(a, b)
print(x * 256 + y * 32)


(k2, k3, k4, k5) = map(int, input().split())
n256 = min(k4, k5)
n32 = k3
ans = 0
for i in range(n32 + 1):
	if i > k2:
		break
	now = i * 32
	now += min(n256, k2 - i) * 256
	ans = max(ans, now)
print(ans)


(k2, k3, k5, k6) = map(int, input().split())
no_256 = min([k2, k5, k6])
if k2 == min([k2, k5, k6]):
	k5 -= k2
	k6 -= k2
	k2 = 0
elif k5 == min([k2, k5, k6]):
	k2 -= k5
	k6 -= k5
	k5 = 0
else:
	k2 -= k6
	k5 -= k6
	k6 = 0
no_32 = min([k3, k2])
print(no_256 * 256 + no_32 * 32)


(k1, k2, k3, k4) = map(int, input().split(' '))
sum_ = 0
l1 = [k1, k3, k4]
l1 = sorted(l1)
if l1[0] > 0:
	sum_ += 256 * l1[0]
if k1 > l1[0] and k2 > 0:
	l2 = [k1 - l1[0], k2]
	l2 = sorted(l2)
	sum_ += 32 * l2[0]
print(sum_)


(d2, d3, d5, d6) = map(int, input().split())
su = 0
m1 = min(d2, d5, d6)
su += int(m1 * 256)
d2 -= m1
m2 = min(d2, d3)
su += int(m2 * 32)
print(su)


s = str(input())
liste = [int(elt) for elt in s.split(' ')]
somme = 0
while 1:
	if liste[0] > 0 and liste[2] > 0 and (liste[3] > 0):
		liste[0] -= 1
		liste[2] -= 1
		liste[3] -= 1
		somme += 256
	elif liste[0] > 0 and liste[1] > 0:
		liste[0] -= 1
		liste[1] -= 1
		somme += 32
	else:
		break
print(somme)


k = list(map(int, input().split()))
tot = 0
Min = min(k[0], k[2], k[3])
tot += Min * 256
if k[0] > Min:
	Min = min(k[0] - Min, k[1])
else:
	Min = 0
tot += Min * 32
print(tot)


(k2, k3, k5, k6) = map(int, input().split())
ans = 0
cnt1 = min([k2, k5, k6])
ans += 256 * cnt1
k2 -= cnt1
cnt2 = min([k2, k3])
ans += 32 * cnt2
print(ans)


k = list(map(int, input().split()))
num = min(k[0], min(k[2:]))
num2 = min(k[0] - num, k[1])
print(num * 256 + num2 * 32)


n = list(map(int, input().split()))
a = 0
mm = min(min(n[0], n[2]), n[3])
n[0] -= mm
a += 256 * mm
mm = min(n[0], n[1])
a += 32 * mm
print(a)


import sys
(k2, k3, k5, k6) = map(int, sys.stdin.readline().split())
a = min(k2, k5, k6)
b = min(k2 - a, k3)
print(a * 256 + b * 32)


(a, b, c, d) = map(int, input().split())
n_256 = min(a, c, d)
a -= n_256
c -= n_256
d -= n_256
n_32 = min(a, b)
ans = n_256 * 256 + n_32 * 32
print(ans)


import sys, math, string
input = sys.stdin.readline
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split().strip())
M = lambda : map(int, input().split())
(a, b, c, d) = M()
print(min(a, c, d) * 256 + min(a - min(a, c, d), b) * 32)


(k2, k3, k5, k6) = map(int, input().split())
summ = 0
t = min(k2, k5, k6)
summ += t * 256
k2 -= t
t = min(k2, k3)
summ += t * 32
print(summ)


l = list(map(int, input().split()))
s = min(l[0], l[2], l[3])
t = s * 256
l[0] = l[0] - s
l[2] = l[2] - s
l[3] = l[3] - s
q = min(l[1], l[0])
r = 32 * q
print(t + r)


k = input().strip().split()
for (index, item) in enumerate(k):
	k[index] = int(item)
print(256 * min(k[0], k[2], k[3]) + 32 * min(k[1], k[0] - min(k[0], k[2], k[3])))


(n2, n3, n5, n6) = list(map(int, input().strip().split()))
t = min(n2, n5, n6)
n2 = n2 - t
n5 = n5 - t
n6 = n6 - t
c = t * 256
p = min(n2, n3)
c += 32 * p
print(c)


(k2, k3, k5, k6) = list(map(int, input().split()))
sm = 0
sm += 256 * min(k2, k5, k6)
k2 -= min(k2, k5, k6)
k5 -= min(k2, k5, k6)
k6 -= min(k2, k5, k6)
sm += 32 * min(k2, k3)
print(sm)


(twos, threes, fives, sixes) = map(int, input().split(' '))
two_fifty_six = min(twos, fives, sixes)
twos = twos - two_fifty_six
thrity_two = min(twos, threes)
print(256 * two_fifty_six + 32 * thrity_two)


ain = list(input())
a = []
redunt = ''
for item in range(len(ain)):
	if ain[item] == ' ':
		a.append(int(redunt))
		redunt = ''
	else:
		redunt += ain[item]
		if item == len(ain) - 1:
			a.append(int(redunt))
if a[0] <= a[2] and a[0] <= a[3]:
	largest = a[0]
elif a[2] <= a[0] and a[2] <= a[3]:
	largest = a[2]
else:
	largest = a[3]
a[0] = a[0] - largest
if a[0] <= 0:
	print(256 * largest)
elif a[0] <= a[1]:
	scond = a[0]
	print(256 * largest + 32 * scond)
else:
	scond = a[1]
	print(256 * largest + 32 * scond)


(k2, k3, k5, k6) = map(int, input().split())
o = 0
m = min(k2, k5, k6)
o += 256 * m
o += 32 * min(k3, max(0, k2 - m))
print(o)


(k2, k3, k5, k6) = map(int, input().split())
sum256 = 0
sum32 = 0
while k2 > 0 and k5 > 0 and (k6 > 0):
	x = min(k2, k5, k6)
	sum256 += 256 * x
	k2 -= x
	k5 -= x
	k6 -= x
while k2 > 0 and k3 > 0:
	x = min(k2, k3)
	sum32 += 32 * x
	k2 -= x
	k3 -= x
result = sum256 + sum32
print(result)


(d2, d3, d5, d6) = input().split()
d2 = int(d2)
d3 = int(d3)
d5 = int(d5)
d6 = int(d6)
t = min(min(d2, d5), d6)
d2 = d2 - t
d5 = d5 - t
d6 = d6 - t
sum1 = 256 * t
t = min(d2, d3)
sum1 = sum1 + 32 * t
print(sum1)


(a, b, c, d) = list(map(int, input().split()))
e = min(a, c, d)
m = e
f = 256 * e
a = a - m
k = min(a, b)
n = k * 32
print(f + n)


(two, three, five, six) = map(int, input().split())
temp1 = min(two, five, six)
two -= temp1
temp2 = min(three, two)
print(temp1 * 256 + temp2 * 32)


s = input().split()
two = int(s[0])
three = int(s[1])
five = int(s[2])
six = int(s[3])
count = 0
while two > 0 and five > 0 and (six > 0):
	count += 256
	two -= 1
	five -= 1
	six -= 1
while three > 0 and two > 0:
	count += 32
	two -= 1
	three -= 1
print(count)


(n2, n3, n5, n6) = map(int, input().split())
g = min(n2, n5, n6)
ans = 256 * g
p = min(n2 - g, n3)
ans += 32 * p
print(ans)


(digits2, digits3, digits5, digits6) = input().split()
digits2 = int(digits2)
digits3 = int(digits3)
digits5 = int(digits5)
digits6 = int(digits6)
count256 = 0
count32 = 0
if digits2 == digits5 and digits5 == digits6:
	count256 += digits2
	digits2 = 0
if digits2 <= digits5 and digits2 <= digits6 and (digits2 != 0):
	count256 += digits2
	digits2 -= digits2
	digits5 -= digits2
	digits6 -= digits2
if digits5 <= digits2 and digits5 <= digits6 and (digits5 != 0):
	count256 += digits5
	digits2 -= digits5
	digits5 -= digits5
	digits6 -= digits5
if digits6 <= digits2 and digits6 <= digits5 and (digits6 != 0):
	count256 += digits6
	digits2 -= digits6
	digits5 -= digits6
	digits6 -= digits6
if digits2 == digits3:
	count32 += digits2
	digits2 -= digits2
if digits2 < digits3 and digits2 != 0:
	count32 += digits2
if digits3 <= digits2 and digits3 != 0:
	count32 += digits3
if digits2 == digits3:
	count32 += digits2
count256 = count256 * 256
count32 = count32 * 32
wynik = count32 + count256
print(wynik)


(tw, th, f, s) = map(int, input().split())
m = min(tw, f, s)
tw -= m
f -= m
s -= m
n = min(tw, th)
k = m * 256 + n * 32
print(k)


(a, b, c, d) = map(int, input().split())
total = 0
mn = min(a, c, d)
a = a - mn
total += mn * 256
mn = min(a, b)
total += mn * 32
print(total)


(p, q, r, s) = map(int, input().split())
Sum = min(p, r, s)
print(256 * Sum + 32 * min(p - Sum, q))


(a, b, c, d) = list(map(int, input().split()))
Max = min(a, c, d)
a -= Max
Min = min(a, b)
print(256 * Max + 32 * Min)


def main():
	(k2, k3, k5, k6) = map(int, input().split())
	s1 = min(k2, k5, k6)
	k2 = k2 - s1
	s2 = max(0, min(k2, k3))
	s = s1 * 256 + s2 * 32
	print(s)
	return 0
main()


(m, o, n, k) = input().split()
y = min(int(m), int(n), int(k))
x = int(m) - y
z = min(x, int(o))
print(int(256 * y + 32 * z))


(k2, k3, k5, k6) = map(int, input().split())
mn = min(k2, k5, k6)
k2 = k2 - mn
k5 = k5 - mn
k6 = k6 - mn
s = mn * 256
mk = min(k2, k3)
s = s + mk * 32
print(s)


(k2, k3, k5, k6) = map(int, input().split())
number = 0
if k2 >= 1 and k5 >= 1 and (k6 >= 1):
	number = int(str(2) + str(5) + str(6)) * min(k2, k5, k6)
	k2 = k2 - min(k2, k5, k6)
	k5 = k5 - min(k2, k5, k6)
	k6 = k6 - min(k2, k5, k6)
if k2 >= 1 and k3 >= 1:
	number += int(str(3) + str(2)) * min(k2, k3)
	k2 = k2 - min(k2, k3)
	k3 = k5 - min(k2, k3)
print(number)


n = list(map(int, input().split()))
p = min(n[2:])
if n[0] >= p:
	sum = p * 256
	n[0] -= p
	p = min(n[:2])
	sum += p * 32
else:
	sum = n[0] * 256
	n[0] = 0
print(sum)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as c
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
(w, x, y, z) = sp()
answer = 256 * min(w, y, z)
w -= min(w, y, z)
answer += 32 * min(w, x)
out(answer)


def in_ls(name_type, string):
	string = string.split()
	string = map(name_type, string)
	string = list(string)
	return string
k = in_ls(int, input())
k_min = min(k[2], k[3], k[0])
number = k_min * 256
k[0] = k[0] - k_min
k_min = min(k[0], k[1])
number += k_min * 32
print(number)


(a2, a3, a5, a6) = map(int, input().split())
s = 0
for i in range(5 * 10 ** 6 + 5):
	if i <= a2 and i <= a5 and (i <= a6):
		s = max(s, i * 256 + 32 * min(a2 - i, a3))
print(s)


a = [int(s) for s in input().split(' ')]
mn = min(a[0], a[2])
mn = min(mn, a[3])
a[0] -= mn
ans = mn * 256 + min(a[0], a[1]) * 32
print(ans)


(k2, k3, k5, k6) = (int(_) for _ in input().split(' '))
num256 = min(k2, k5, k6)
total = 256 * num256
k2 -= num256
num32 = min(k2, k3)
total += 32 * num32
print(total)


def ii():
	return int(input())

def fi():
	return float(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
import math
(a, b, c, d) = mi()
e = min(a, c, d)
f = min(a - e, b)
ans = e * 256 + f * 32
print(ans)


nums = input()
num = [int(x) for x in nums.split()]
d = [num[0], num[2], num[3]]
a = min(d) * 256
b = 0
if d[0] == min(d):
	b = True
elif d[0] > min(d):
	t = d[0] - min(d)
	if t >= num[1]:
		a += num[1] * 32
	else:
		a += t * 32
print(a)


(k2, k3, k5, k6) = [int(x) for x in input().split()]
min_num = min(k2, k5, k6)
answer = 0
if min_num == k2:
	answer += 256 * k2
	print(answer)
elif min_num == k5:
	answer += 256 * k5
	k2 -= k5
	min_32 = min(k2, k3)
	if k3 > 0 and k2 > 0:
		answer += 32 * min_32
	print(answer)
elif min_num == k6:
	answer += 256 * k6
	k2 -= k6
	min_32 = min(k2, k3)
	if k3 > 0 and k2 > 0:
		answer += 32 * min_32
	print(answer)


a = input().split()
k2 = int(a[0])
k3 = int(a[1])
k5 = int(a[2])
k6 = int(a[3])
min = k2
if k5 < min:
	min = k5
if k6 < min:
	min = k6
k2 -= min
max = k2
if k3 < max:
	max = k3
print(min * 256 + 32 * max)


(two, three, five, six) = map(int, input().split())
m = min(two, five, six)
two = two - m
n = min(two, three)
print(256 * m + 32 * n)


k = list(map(int, input().split()))
a = min(k[0], k[2])
b = min(a, k[3])
k[0] = k[0] - b
k[2] = k[2] - b
k[3] = k[3] - b
c = min(k[0], k[1])
k[0] = k[0] - c
k[1] = k[1] - c
l = []
for _ in range(b):
	l.append(256)
for _ in range(c):
	l.append(32)
print(sum(l))


read = lambda : list(map(int, input().split()))
(k2, k3, k5, k6) = read()
cnt1 = min(k2, k5, k6)
cnt2 = min(k2 - cnt1, k3)
ans = cnt1 * 256 + cnt2 * 32
print(ans)


a = list(map(int, input().rstrip().split()))
m = min(a[0], a[2], a[3])
s = m * 256 + min(a[0] - m, a[1]) * 32
print(s)


(a, b, c, d) = [int(x) for x in input().split()]
three = min(a, c, d)
two = min(b, a - three)
print(three * 256 + two * 32)


(k2, k3, k5, k6) = map(int, input().split())
table = {2: k2, 3: k3, 5: k5, 6: k6}
tot = 0
m_256 = min(table[2], table[5], table[6])
tot += 256 * m_256
table[2] -= m_256
table[5] -= m_256
table[6] -= m_256
m_32 = min(table[2], table[3])
tot += 32 * m_32
table[2] -= m_32
table[3] -= m_32
print(tot)


(k2, k3, k5, k6) = [int(i) for i in input().split()]
minim = min(k2, k5, k6)
ans = minim * 256
k2 -= minim
if k2 >= 1 and k3 >= 1:
	ans += min(k2, k3) * 32
print(ans)


(k2, k3, k5, k6) = map(int, input().split())
p256 = min(k2, k5, k6)
k2 -= p256
p32 = min(k2, k3)
print(256 * p256 + 32 * p32)


l = list(map(int, input().split()))
c = min(l[0], l[2], l[3])
d = c * 256
l[0] -= c
l[2] -= c
l[3] -= c
e = min(l[0], l[1])
f = e * 32
print(f + d)


z = 0
(a, b, c, d) = map(int, input().split())
if a <= d and a <= c:
	z += a * 256
	a = a - a
elif d <= a and d <= c:
	z += d * 256
	a = a - d
else:
	z += c * 256
	a = a - c
if a > 0 and a <= b:
	z += a * 32
elif a > 0 and a > b:
	z += b * 32
print(z)


tmp = input().split(' ')
k2 = int(tmp[0])
k3 = int(tmp[1])
k5 = int(tmp[2])
k6 = int(tmp[3])
ile256 = min(k2, k5, k6)
ile32 = min(k2 - ile256, k3)
wynik = ile256 * 256 + ile32 * 32
print(wynik)


def solve(k2, k3, k5, k6):
	x = min(k6, k5, k2)
	s = 256 * x
	k6 -= x
	k5 -= x
	k2 -= x
	return s + 32 * min(k3, k2)

def main():
	(k2, k3, k5, k6) = list(map(int, input().split()))
	print(solve(k2, k3, k5, k6))
main()


__author__ = 'Think'
(k2, k3, k5, k6) = [int(i) for i in input().split()]
r = min(k5, k6)
if r > k2:
	print(256 * k2)
else:
	print(256 * r + 32 * min(k3, k2 - r))


n = list(map(int, input().split()))
x = n[1]
n.remove(n[1])
z = 256 * min(n)
for i in range(len(n)):
	n[i] = n[i] - min(n)
n.append(x)
n.remove(n[1])
n.remove(n[1])
z = z + 32 * min(n)
print(z)


(k2, k3, k5, k6) = map(int, input().split())
ans1 = min(k2, k5, k6)
k2 -= ans1
k5 -= ans1
k6 -= ans1
sum1 = 0
sum1 += ans1 * 256
ans2 = min(k2, k3)
sum1 += ans2 * 32
print(sum1)


s = input()
count_num = 0
for i in s.split(' '):
	if count_num == 0:
		k1 = int(i)
	if count_num == 1:
		k2 = int(i)
	if count_num == 2:
		k3 = int(i)
	if count_num == 3:
		k4 = int(i)
	count_num += 1
min1 = k1
if k3 < min1:
	min1 = k3
if k4 < min1:
	min1 = k4
count = 256 * min1
k1 -= min1
k3 -= min1
k4 -= min1
min1 = k1
if k2 < min1:
	min1 = k2
count += 32 * min1
print(count)


n = input().split()
m = 5 * 10 ** 6
h = 0
for i in range(4):
	n[i] = int(n[i])
	if m > n[i]:
		if i != 1:
			m = n[i]
h = 256 * m
n[0] -= m
if n[0] > n[1]:
	h += 32 * n[1]
else:
	h += 32 * n[0]
print(h)


(v, x, y, z) = map(int, input().split())
t1 = min(v, y, z)
t2 = min(x, v - t1)
print(256 * t1 + 32 * t2)


(a2, a3, a5, a6) = map(int, input().split())
c = min(a2, a5, a6)
k = c * 256
a2 = a2 - c
z = min(a2, a3)
z = z * 32
print(z + k)


k = list(map(int, input().split()))
q = 0
for i in range(0, min(k[0], k[2], k[3])):
	q += 256
if min(k) == k[0] or (k[0] == 1 and k[1] == 1):
	print(q)
else:
	for w in range(0, min(k[0] - q // 256, k[1])):
		q += 32
	print(q)


(a, b, c, d) = map(int, input().split())
i = min(a, c, d)
a -= i
a = min(b, a)
ans = 256 * i
if a > 0:
	ans += a * 32
print(ans)


s = input()
s = s.split()
for i in range(4):
	s[i] = int(s[i])
k2 = s[0]
k3 = s[1]
k5 = s[2]
k6 = s[3]
x = min([k2, k5, k6])
print(256 * x + 32 * min([k2 - x, k3]))


def anton(ls):
	ls1 = [2, 3, 5, 6]
	c = ls[1]
	ls.pop(1)
	k = min(ls)
	s = k * 256
	ls[0] = ls[0] - k
	m = min(ls[0], c)
	s = s + m * 32
	return s
ls = [int(i) for i in input().split()]
print(anton(ls))


(k2, k3, k5, k6) = [int(x) for x in input().split()]
a1 = min(k2, k5, k6)
k2 -= a1
k5 -= a1
k6 -= a1
a2 = min(k2, k3)
print(a2 * 32 + a1 * 256)


(a, b, c, d) = map(int, input().split())
r = min(a, c, d)
k = min(a - r, b)
print(r * 256 + k * 32)


numbers = list(map(int, input().split()))
minimum = min(numbers[0], numbers[2], numbers[3])
total_sum = 256 * minimum
numbers[0] -= minimum
total_sum += 32 * min(numbers[0], numbers[1])
print(total_sum)


(a, b, c, d) = map(int, input().split())
ans = 0
n256 = min(a, c, d)
ans += 256 * n256
n32 = min(a - n256, b)
ans += n32 * 32
print(ans)


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
(k2, k3, k5, k6) = map(int, input().split())
k256 = min(k2, k5, k6)
k32 = max(0, min(k3, k2 - k256))
print(k32 * 32 + k256 * 256)


(a2, a3, a5, a6) = map(int, input().split())
minimo_256 = min([a2, a5, a6])
res = 0
if minimo_256 > 0:
	for i in range(minimo_256):
		res += 256
minimo_32 = min([a3, a2 - res // 256])
if minimo_32 > 0:
	for i in range(minimo_32):
		res += 32
print(res)


arr = [int(i) for i in input().split(' ')]
n = min([arr[0], arr[2], arr[3]])
if arr[0] == arr[2] == arr[3]:
	max_sum = arr[0] * 256
elif arr[0] == 0:
	max_sum = 0
elif n == 0 and arr[1] >= arr[0]:
	max_sum = arr[0] * 32
elif n == 0 and arr[1] <= arr[0]:
	max_sum = arr[1] * 32
elif n != 0 and arr[1] >= arr[0] - n:
	max_sum = n * 256 + (arr[0] - n) * 32
elif n != 0 and arr[1] <= arr[0] - n:
	max_sum = n * 256 + arr[1] * 32
print(max_sum)


(digit_2, digit_3, digit_5, digit_6) = map(int, input().split())

def smallest_256(digit_2, digit_5, digit_6):
	if digit_2 <= digit_5 and digit_2 <= digit_6:
		return digit_2
	elif digit_5 <= digit_2 and digit_5 <= digit_6:
		return digit_5
	else:
		return digit_6
num_256 = smallest_256(digit_2, digit_5, digit_6)
sum_256 = num_256 * 256
if digit_3 < digit_2 - num_256:
	sum_32 = digit_3 * 32
else:
	sum_32 = (digit_2 - num_256) * 32
print(sum_32 + sum_256)


total_32 = 0
total_256 = 0
data = input('')
den = list(data.split(' '))
den = list(map(int, den))
total = 0
if den[3] == den[2] and den[0] == den[2]:
	total += den[2] * 256
else:
	total_256 = min(den[0], den[2], den[3])
	den[0] -= total_256
	total_32 = min(den[0], den[1])
	total = total_256 * 256 + total_32 * 32
print(total)


(a, d, b, c) = map(int, input().split())
k = c if c < (a if a < b else b) else a if a < b else b
a -= k
k2 = a if a < d else d
print(k * 256 + k2 * 32)


nums = list(map(int, input().split()))
min256 = min([nums[0]] + nums[2:4])
print(min256 * 256 + min(nums[1], nums[0] - min256) * 32)


b = list((int(x) for x in input().split()))
sum = 0
a = min(b[0], b[2], b[3])
b[0] = b[0] - a
b = min(b[0], b[1])
print(256 * a + 32 * b)


from sys import stdin, stderr

def readInts():
	return map(int, stdin.readline().strip().split())

def print_err(*args, **kwargs):
	print(*args, file=stderr, **kwargs)

def run():
	(k2, k3, k5, k6) = readInts()
	count256 = min([k2, k5, k6])
	k2 -= count256
	count32 = min([k2, k3])
	print(count256 * 256 + count32 * 32)
run()


(w, x, y, z) = map(int, input().split())
a = min(w, y, z)
b = a * 256
c = w - a
d = min(x, c) * 32
e = b + d
print(e)


n = list(map(int, input().split()))
k2 = n[0]
k3 = n[1]
k5 = n[2]
k6 = n[3]
n256 = min(k2, min(k5, k6))
n32 = min(k3, k2 - n256)
print(32 * n32 + 256 * n256)


(a, b, c, d) = map(int, input().strip().split())
sum = 0
one = 256
two = 32
m = min(a, c, d)
sum = sum + 256 * m
n = min(b, a - m)
if n >= 0:
	sum = sum + 32 * n
print(sum)


(a2, a3, a5, a6) = map(int, input().split())
m = min(a2, a5, a6)
ans = 0
if m == a2:
	ans += m * 256
elif m == a5 or m == a6:
	ans += m * 256
	a2 -= m
	n = min(a2, a3)
	ans += n * 32
print(ans)


k = input().split()
k2 = int(k[0])
k3 = int(k[1])
k5 = int(k[2])
k6 = int(k[3])
k256 = min(k2, k5, k6)
k32 = min(k3, k2 - k256)
print(k256 * 256 + k32 * 32)


(k2, k3, k5, k6) = [int(x) for x in input().split()]
n256 = min(k2, k5, k6)
k2 -= n256
k5 -= n256
k6 -= n256
n32 = min(k3, k2)
print(256 * n256 + 32 * n32)


a = list(map(int, input().split()))
mn1 = min((a[0], a[2], a[3]))
mn2 = min((a[1], a[0] - mn1))
print(256 * mn1 + 32 * mn2)


(k2, k3, k5, k6) = map(int, input().split())
mn = min([k2, k5, k6])
sum = 256 * mn
sum += min([k2 - mn, k3]) * 32
print(sum)


(k2, k3, k5, k6) = map(int, input().split())
z = 0
while k2 - 500 >= 0 and k5 - 500 >= 0 and (k6 - 500 >= 0):
	k2 -= 500
	k5 -= 500
	k6 -= 500
	z += 128000
	if k2 == 0 or k5 == 0 or k6 == 0:
		break
while k2 - 1 >= 0 and k5 - 1 >= 0 and (k6 - 1 >= 0):
	k2 -= 1
	k5 -= 1
	k6 -= 1
	z += 256
	if k2 == 0 or k5 == 0 or k6 == 0:
		break
while k2 - 500 >= 0 and k3 - 500 >= 0:
	k2 -= 500
	k3 -= 500
	z += 16000
	if k2 == 0 or k3 == 0:
		break
while k2 - 1 >= 0 and k3 - 1 >= 0:
	k2 -= 1
	k3 -= 1
	z += 32
	if k2 == 0 or k3 == 0:
		break
print(z)


a = list(map(int, input().split()))
b = min(a[0], a[2], a[3])
sum = b * 256
a[0] -= b
a[2] -= b
a[3] -= b
c = min(a[0], a[1])
sum += c * 32
print(sum)


(k2, k3, k5, k6) = [int(i) for i in input().split()]
sum = 0
sum += min(k2, k5, k6) * 256
k2 -= min(k2, k5, k6)
if k2 > 0 and k3 > 0:
	sum += min(k2, k3) * 32
print(sum)


(t, th, f, s) = map(int, input().split())
ans = 0
while t != 0 and f != 0 and (s != 0):
	ans += 256
	t -= 1
	f -= 1
	s -= 1
x = min(t, th)
ans += x * 32
print(ans)


(p, q, r, s) = map(int, input().split())
a = min(p, r, s)
c = 256 * a + 32 * min(p - a, q)
print(c)


ks = [int(i) for i in input().split()]
sum1 = 0
min256 = min(ks[0], ks[2], ks[3])
ks[0] = ks[0] - min256 if ks[0] - min256 > 0 else 0
min32 = min(ks[0], ks[1])
print(256 * min256 + 32 * min32)


a = [int(i) for i in input().split()]
number_2 = a[0]
number_3 = a[1]
number_5 = a[2]
number_6 = a[3]
total = min(number_2, number_5, number_6) * 256
number_2 -= min(number_2, number_5, number_6)
print(total + min(number_2, number_3) * 32)


L = [int(i) for i in input('').split()]
print(256 * min(L[0], L[2], L[3]) + 32 * min(L[1], L[0] - min(L[0], L[2], L[3])))


(k2, k3, k5, k6) = [int(i) for i in input().split()]
ans = 0
m = min(k2, k5, k6)
ans += m * 256
k2 -= m
k5 -= m
k6 -= m
m = min(k2, k3)
ans += m * 32
print(ans)


(two, three, five, six) = input().split()
two = int(two)
three = int(three)
five = int(five)
six = int(six)
a = 0
b = 0
a = min(two, min(five, six))
two -= a
if two > 0:
	b = min(two, three)
print(256 * a + 32 * b)


(k2, k3, k5, k6) = map(int, input().strip().split())
sum = 0
i = min(k2, k5, k6)
sum += 256 * i
j = min(k3, k2 - i)
sum += 32 * j
print(sum)


(k2, k3, k5, k6) = map(int, input().split())
r1 = min(k2, k5, k6)
res1 = r1 * 256
k2 -= r1
res2 = min(k2, k3) * 32
print(res1 + res2)


(x1, x2, x3, x4) = map(int, input().split())
z = min(x1, x3, x4)
x1 -= z
x3 -= z
x4 -= z
sum = 256 * z
m = min(x1, x2)
sum += 32 * m
print(sum)


(s2, s3, s5, s6) = map(int, input().split())
c = 0
d = min(s2, s5, s6)
c = c + 256 * d
s2 = s2 - d
s5 = s5 - d
s6 = s6 - d
d = min(s2, s3)
c = c + 32 * d
print(c)


s = input().split()
for i in range(4):
	s[i] = int(s[i])
S = min(min(s[0], s[2]), s[3])
D = min(s[0] - S, s[1])
print(S * 256 + D * 32)


import sys
from math import sqrt, floor
inp = sys.stdin.readline
read = lambda : list(map(int, inp().split()))

def solve():
	arr = read()
	s1 = min(arr[0], arr[2], arr[3])
	s2 = min(arr[1], arr[0] - s1)
	s = 256 * s1 + 32 * s2
	print(s)
solve()


k = [int(_) for _ in input().split()]
p = min(k[0], k[2], k[3])
print(256 * p + 32 * min(k[0] - p, k[1]))


(a, b, c, d) = map(int, input().split())
cn = 0
x = min(a, c, d)
cn = x * 256 + cn
a = a - x
c = c - x
d = d - x
x = min(a, b)
cn = cn + x * 32
print(cn)


(k2, k3, k5, k6) = [int(x) for x in input().split()]
min1 = min(k2, k5, k6)
if min1 == k2:
	ans = 256 * min1
else:
	ans = 256 * min1 + 32 * min(k2 - min1, k3)
print(ans)


(k2, k3, k5, k6) = map(int, input().split())
c = min(k2, k5, k6)
k2 = k2 - c
d = min(k2, k3)
sum = 0
sum = 256 * c + d * 32
print(sum)


(a, b, c, d) = map(int, input().split())
s = 0
while 1:
	if a > 0 and c > 0 and (d > 0):
		s = s + 256
		a = a - 1
		c = c - 1
		d = d - 1
	elif a > 0 and b > 0:
		s = s + 32
		a = a - 1
		b = b - 1
	else:
		break
print(s)


(a, b, c, d) = map(int, input().split())
e = min(a, c, d)
f = 256 * e
a -= e
c -= e
d -= e
if a != 0 and b != 0:
	e = min(a, b)
	f += 32 * e
print(f)


from sys import stdin
(two, three, five, six) = map(int, stdin.readline().rstrip().split(' '))
num_256 = min(two, five, six)
total = 256 * num_256
two -= num_256
five -= num_256
six -= num_256
num_32 = min(two, three)
total += 32 * num_32
print(total)


a = [int(i) for i in input().split()]
x = min(a[0], a[2], a[3])
y = min(a[0] - x, a[1])
print(256 * x + 32 * y)


[a, b, c, d] = [int(x) for x in input().split()]
k = min(a, c, d)
a -= k
q = min(a, b)
print(k * 256 + q * 32)


[k2, k3, k5, k6] = [int(x) for x in input().split()]
min256 = min(k2, k5, k6) * 256
if k2 - min(k2, k5, k6) <= 0:
	min32 = 0
else:
	min32 = min(k2 - min(k2, k5, k6), k3) * 32
print(min256 + min32)


(a, b, c, d) = list(map(int, input().split()))
l = min(a, c, d)
res = 256 * l
a -= l
c -= l
d -= l
m = min(a, b)
res += 32 * m
print(res)


(a, b, c, d) = map(int, input().split())
mi = min([a, c, d])
mi2 = min([a - mi, b])
print(256 * mi + 32 * mi2)


(k2, k3, k5, k6) = map(int, input().split())
(max_, min_) = (min(k5, k6, k2), 0)
if max_ < k2:
	min_ = min(k2 - max_, k3)
print(max_ * 256 + min_ * 32)


(k2, k3, k5, k6) = map(int, input().split())
sum1 = 0
cur = min(min(k2, k5), k6)
sum1 += cur * 256
k2 -= cur
k5 -= cur
k6 -= cur
cur = min(k2, k3)
sum1 += cur * 32
print(sum1)


(a, b, c, d) = list(map(int, input().split()))
sum = 0
sum += min(a, c, d) * 256
a -= min(a, c, d)
sum += min(a, b) * 32
print(sum)


(twos, threes, fives, sixes) = map(int, input().split())
som = 0
while twos > 0 and fives > 0 and (sixes > 0):
	pr = min(twos, fives, sixes)
	twos -= pr
	fives -= pr
	sixes -= pr
	som += 256 * pr
while twos > 0 and threes > 0:
	pr = min(twos, threes)
	twos -= pr
	threes -= pr
	som += 32 * pr
print(str(som))


(a, b, x, z) = input().split()
two = int(a)
three = int(b)
five = int(x)
six = int(z)
counter_32 = 0
counter_256 = 0
while True:
	if two > 0 and five > 0 and (six > 0):
		counter_256 += 1
		two -= 1
		five -= 1
		six -= 1
	elif two > 0 and three > 0:
		counter_32 += 1
		two -= 1
		three -= 1
	else:
		break
print(256 * counter_256 + 32 * counter_32)


def call():
	(a, b, c, d) = map(int, input().split())
	t = min(a, min(c, d))
	coN3 = min(b, a - t)
	print(32 * coN3 + 256 * t)
call()


(K2, K3, K5, K6) = list(map(int, input().split()))
N2 = min(K2, K5, K6)
K2 -= N2
N3 = min(K2, K3)
print(256 * N2 + 32 * N3)


(a, b, c, d) = input().split()
e = []
f = []
e.append(int(a))
e.append(int(c))
e.append(int(d))
cn = min(e) * 256
if int(a) - int(min(e)) > 0:
	f.append(int(a) - int(min(e)))
	f.append(int(b))
	ct = int(min(f)) * 32
	print(cn + ct)
else:
	print(cn)


(a, b, c, d) = input().split()
(a, b, c, d) = (int(a), int(b), int(c), int(d))
m1 = min(a, c, d)
a2 = a - m1
m2 = min(a2, b)
sum = m2 * 32 + m1 * 256
print(sum)


(k2, k3, k5, k6) = map(int, input().split())
sum = 0
while k2 > 0:
	if k5 > 0 and k6 > 0:
		sum += 256
		k2 -= 1
		k5 -= 1
		k6 -= 1
	elif k2 > 0 and k3 > 0:
		sum += 32
		k3 -= 1
		k2 -= 1
	else:
		break
print(sum)


def solve():
	v = list(map(int, input().split()))
	(max_256, max_32) = (min([v[0]] + v[2:]), min(v[:2]))
	print(256 * max_256 + 32 * max(min(v[0] - max_256, v[1]), 0))
solve()


N = input().strip().split()
L = [int(x) for x in N]
cnt_256 = min(L[0], L[2], L[3])
L[0] -= cnt_256
L[2] -= cnt_256
L[3] -= cnt_256
cnt_32 = min(L[0], L[1])
print(cnt_32 * 32 + cnt_256 * 256)


import sys
(k_2, k_3, k_5, k_6) = map(int, sys.stdin.readline().split())
n_256 = min(k_2, k_5, k_6)
(k_2, k_5, k_6) = (k_2 - n_256, k_5 - n_256, k_6 - n_256)
n_32 = min(k_2, k_3)
s = n_256 * 256 + n_32 * 32
print(s)


x = [int(i) for i in input().split()]
(a, b, c, d) = (x[0], x[1], x[2], x[3])
a1 = min(a, c, d)
a2 = min(b, a - a1)
print(a2 * 32 + a1 * 256)


(a, b, c, d) = map(int, input().split())
p = min(a, c, d)
a -= p
q = min(a, b)
print(256 * p + 32 * q)


lst = input().split(' ')
for i in range(len(lst)):
	lst[i] = int(lst[i])
ans = min(lst[0], lst[2], lst[3]) * 256
lst[0] -= min(lst[0], lst[2], lst[3])
ans += min(lst[0], lst[1]) * 32
print(ans)


n = input().split()
count = 0
x = 256
y = 32
tw = int(n[0])
th = int(n[1])
fv = int(n[2])
sx = int(n[3])
a = min(sx, fv)
if tw > a:
	count = a * x
	tw -= a
else:
	count = tw * x
	tw = 0
if tw > th:
	count += th * y
else:
	count += tw * y
print(count)


x = input()
z = x.split()
k2 = int(z[0])
k3 = int(z[1])
d = [int(z[2]), int(z[3])]
k = min(d)
s = 0
if k > k2:
	s += k2 * 256
	k2 = 0
elif k == k2:
	s += k2 * 256
	k2 = 0
else:
	k2 -= k
	s += k * 256
o = [k2, k3]
g = min(o)
s += g * 32
print(s)


def main():
	(c2, c3, c5, c6) = [int(v) for v in input().split()]
	d1 = min(c2, c5, c6) * 256 + min(max(0, c2 - min(c2, c5, c6)), c3) * 32
	d2 = min(c2, c3) * 32 + min(max(0, c2 - min(c2, c3)), c5, c6) * 256
	print(max(d1, d2))
main()


a = list(map(int, input().split()))
yo = min(a[0], a[2], a[3])
a[0] = a[0] - yo
ro = min(a[0], a[1])
print(256 * yo + 32 * ro)


(twos, threes, fives, sixes) = map(int, input().split())
a = min(twos, min(fives, sixes))
ans = a * 256
(twos, fives, sixes) = (twos - a, fives - a, sixes - a)
ans += min(twos, threes) * 32
print(ans)


a = [int(a) for a in input().split()]
p = min(a[0], a[2], a[3])
q = min(a[0] - p, a[1])
print(p * 256 + q * 32)


(k2, k3, k5, k6) = [int(i) for i in input().split()]
big_count = min([k2, k5, k6])
current_sum = 256 * big_count
k2 = k2 - big_count
small_count = 0
if k2 > 0:
	small_count = min(k2, k3)
current_sum += 32 * small_count
print(current_sum)


from sys import stdin
(k2, k3, k5, k6) = list(map(int, stdin.readline().split()))
s256 = min(k2, k5, k6)
k2 -= s256
s32 = min(k2, k3)
print(s32 * 32 + s256 * 256)


sum = 0
count = 0
f = 0
g = 0
(a, b, c, d) = map(int, input().split())
e = min(c, d)
s = min(a, e)
a -= s
count = 256 * s + 32 * min(a, b)
print(count)


def numbers(k2, k3, k5, k6):
	r1 = min(min(k2, k5), k6)
	result = r1 * 256
	k2 -= r1
	k5 -= r1
	k6 -= r1
	r1 = min(k2, k3)
	return result + 32 * r1
(a2, a3, a5, a6) = [int(j) for j in input().split()]
print(numbers(a2, a3, a5, a6))


(k2, k3, k5, k6) = [int(x) for x in input().split()]
num_256 = min(k2, k5, k6)
k2 -= num_256
num_32 = min(k2, k3)
print(num_256 * 256 + num_32 * 32)


(k2, k3, k5, k6) = map(int, input().split())
mi = min(k2, k5, k6)
kq = mi * 256
k2 -= mi
print(kq + 32 * min(k2, k3))


(a, b, c, d) = map(int, input().split())
m1 = min(a, c, d)
s = m1 * 256
if a - m1 >= b:
	s = s + b * 32
else:
	s = s + (a - m1) * 32
print(s)


(k2, k3, k5, k6) = map(int, input().strip().split())
num2 = min([k2, k5, k6])
k2 -= num2
k5 -= num2
k6 -= num2
num1 = min([k2, k3])
print(num1 * 32 + num2 * 256)


(k2, k3, k5, k6) = map(int, input().split())
z = min(k2, k5, k6)
s = z * 256
z1 = min(k2 - z, k3)
s = s + z1 * 32
print(s)


inp = input()
chars = inp.split()
k2 = int(chars[0])
k3 = int(chars[1])
k5 = int(chars[2])
k6 = int(chars[3])
x = min(k2, k5, k6)
ans = x * 256
y = min(k2 - x, k3)
ans = ans + y * 32
print(ans)


list1 = [int(x) for x in input().split()]
list3 = [list1[0], list1[2], list1[3]]
x = 256 * min(list3)
num2 = list1[0] - min(list3)
num3 = list1[1]
list2 = [num2, num3]
if num2 == 0:
	print(x)
else:
	print(x + 32 * min(list2))


(k2, k3, k5, k6) = map(int, input().split())
tmp = min((k5, k6, k2))
k2 -= tmp
tmp1 = min((k2, k3))
print(tmp * 256 + tmp1 * 32)


x = list(map(int, input().split()))
three = x[1]
x.pop(1)
abc = min(x)
sum = 0
sum += abc * 256
x[0] -= abc
if three < x[0]:
	sum += 32 * three
else:
	sum += 32 * x[0]
print(sum)


k = list(map(int, input().split()))
(k2, k3, k5, k6) = k
min1 = k2
if k5 < min1:
	min1 = k5
if k6 < min1:
	min1 = k6
sum1 = 256 * min1
k2 -= min1
k6 -= min1
k5 -= min1
min2 = k2
if min2 > k3:
	min2 = k3
sum2 = 32 * min2
zagalSum = sum1 + sum2
print(zagalSum)


t = list(map(int, input().split(' ')))
a = min(t[0], t[2], t[3])
t[0] = t[0] - a
t[2] = t[2] - a
t[3] = t[3] - a
a = a * 256
b = min(t[0], t[1])
b = b * 32
print(a + b)


(k2, k3, k5, k6) = input().split()
(k2, k3, k5, k6) = (int(k2), int(k3), int(k5), int(k6))
Max = 0
if min([k2, k5, k6]) == k2:
	Max = k2 * 256
elif min([k2, k5, k6]) == k5:
	if k2 - k5 > k3:
		Max = k5 * 256 + k3 * 32
	else:
		Max = k5 * 256 + (k2 - k5) * 32
elif min([k2, k5, k6]) == k6:
	if k2 - k6 > k3:
		Max = k6 * 256 + k3 * 32
	else:
		Max = k6 * 256 + (k2 - k6) * 32
print(Max)


(two, three, five, six) = map(int, input().split())
x = min(two, five, six)
two -= x
y = min(two, three)
print(x * 256 + y * 32)


(a, b, c, d) = map(int, input().split())
n = min(a, c, d)
m = min(b, max(a - n, 0))
print(n * 256 + m * 32)


def solve(a, b, c, d):
	k = min(a, c, d)
	return 256 * k + 32 * min(b, a - k)
(a, b, c, d) = map(int, input().split())
print(solve(a, b, c, d))


a = [int(i) for i in input().split()]
ans = 0
if a[0] > 0 and a[2] > 0 and (a[3] > 0):
	ans += 256 * min(a[0], a[2], a[3])
	a[0] -= min(a[0], a[2], a[3])
	a[2] -= min(a[0], a[2], a[3])
	a[3] -= min(a[0], a[2], a[3])
if a[0] > 0 and a[1] > 0:
	ans += 32 * min(a[0], a[1])
	a[0] -= min(a[0], a[1])
	a[1] -= min(a[0], a[1])
print(ans)


(k2, k3, k5, k6) = map(int, input().split())
res = 0
res2 = min(k2, k5, k6)
res += res2 * 256
k2 -= res2
res += min(k2, k3) * 32
print(res)


line = input().split()
arr = [int(line[0]), int(line[1]), int(line[2]), int(line[3])]
t256 = min(arr[0], arr[2], arr[3])
arr[0] -= t256
t32 = min(arr[0], arr[1])
ans = 256 * t256 + 32 * t32
print(ans)


numbers = list(map(int, input().split(' ')))
count1 = 0
count2 = 0
_tmp = [numbers[0], numbers[2], numbers[3]]
min_value = min(_tmp)
if numbers[0]:
	count1 = min_value
	numbers[0] -= min_value
else:
	pass
if numbers[0] and numbers[1]:
	count2 = min([numbers[0], numbers[1]])
print(256 * count1 + 32 * count2)


from sys import stdin
max_val = int(10000000000000.0)
min_val = int(-10000000000000.0)

def read_int():
	return int(stdin.readline())

def read_ints():
	return [int(x) for x in stdin.readline().split()]

def read_str():
	return input()

def read_strs():
	return [x for x in stdin.readline().split()]
(two, three, five, six) = read_ints()
_256 = min(two, five, six)
_32 = min(three, two - _256)
print(_256 * 256 + _32 * 32)


import math
vals = input().split(' ')
a = int(vals[0])
b = int(vals[1])
c = int(vals[2])
d = int(vals[3])
ret = 0
minVal = min(a, min(c, d))
ret += 256 * minVal
a -= minVal
c -= minVal
d -= minVal
minVal = min(a, b)
ret += 32 * minVal
print(ret)


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_strList_from_str = lambda : list(sys.stdin.readline().strip())
get_int = lambda : int(sys.stdin.readline().strip())
pt = lambda x: sys.stdout.write(str(x))
(two, three, five, six) = get_list()
m = min(two, five, six)
total = 0
total += 256 * m
two -= m
five -= m
six -= m
n = min(two, three)
total += 32 * n
print(total)


(two, three, five, six) = map(int, input().split())
a = min(five, six)
if two >= a:
	summ = a * 256 + 32 * min(three, two - a)
else:
	summ = 256 * two
print(summ)


import math
from fractions import Fraction as frac
MOD = 1000000000.0 + 7

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)

def solve(case_no):
	(a, b, c, d) = map(int, input().split())
	ans = 0
	ff = min(a, c, d)
	a -= ff
	c -= ff
	d -= ff
	ans += ff * 256
	ff = min(a, b)
	a -= ff
	b -= ff
	ans += ff * 32
	print(ans)
t = 1
for i in range(1, t + 1):
	solve(i)


(a, b, c, d) = map(int, input().split())
s = 0
while a != 0 and c != 0 and (d != 0):
	s += 256
	a -= 1
	c -= 1
	d -= 1
while a != 0 and b != 0:
	s += 32
	a -= 1
	b -= 1
print(s)


def anton(arr):
	di = {2: arr[0], 3: arr[1], 5: arr[2], 6: arr[3]}
	min256 = min(di[2], di[5], di[6])
	ans = 256 * min256
	di[2] -= min256
	min32 = min(di[3], di[2])
	ans += 32 * min32
	return ans
x = list(map(int, input().rstrip().split()))
print(anton(x))


def find_sum():
	in_line = str(input())
	tokens = in_line.split(' ')
	k2 = int(tokens[0])
	k3 = int(tokens[1])
	k5 = int(tokens[2])
	k6 = int(tokens[3])
	num_256 = min(k2, k5, k6)
	if num_256 == k2:
		return 256 * num_256
	else:
		k2 = k2 - num_256
		num_32 = min(k2, k3)
		return 256 * num_256 + 32 * num_32
val = find_sum()
print(val)


(k2, k3, k5, k6) = [int(i) for i in input().split()[:4]]
if k2 != 0 and k5 != 0 and (k6 != 0):
	x1 = min(k2, k5, k6)
	a1 = 256 * x1
	k2 -= x1
	k5 -= x1
	k6 -= x1
	if k2 != 0 and k3 != 0:
		x2 = min(k2, k3)
		a2 = 32 * x2
		print(a1 + a2)
	else:
		print(a1)
elif k2 != 0 and k3 != 0:
	x2 = min(k2, k3)
	a2 = 32 * x2
	print(a2)
else:
	print(0)


inp = input().split()
n2 = int(inp[0])
n3 = int(inp[1])
n5 = int(inp[2])
n6 = int(inp[3])
res = 0
if n2 != 0:
	if n2 == n5:
		if n2 == n6:
			res = n2 * 256
			n2 = 0
	if n2 > 0 and n5 > 0 and (n6 > 0):
		x = min(n2, n5, n6)
		res = res + 256 * x
		n2 = n2 - x
	if n2 == n3:
		res = res + 32 * n2
		n2 = 0
	if n2 > 0 and n3 > 0:
		k = abs(n2 - n3)
		res = res + (n2 + n3 - k) / 2 * 32
print(int(res))


(k2, k3, k5, k6) = map(int, input().split(' '))
a = min(k2, k5, k6)
ans = 0
if a == k2:
	ans += k2 * 256
else:
	ans += a * 256 + min(k2 - a, k3) * 32
print(ans)


T = list(map(int, input().split()))
k2 = T[0]
k3 = T[1]
k5 = T[2]
k6 = T[3]
k = min(k2, k5, k6)
s = 256 * k
if k2 > k:
	kp = min(k2 - k, k3)
	s = s + 32 * kp
print(s)


while True:
	k_s = input()
	k = k_s.split(' ')
	for i in range(0, len(k)):
		k[i] = int(k[i])
	if len(k) < 4:
		continue
	if 0 <= k[0] <= 5000000 and 0 <= k[1] <= 5000000 and (0 <= k[2] <= 5000000) and (0 <= k[3] <= 5000000):
		break
min256 = min(k[0], k[2], k[3])
k[0] -= min256
min32 = 0
if 0 < k[0] and 0 < k[1]:
	min32 = min(k[0], k[1])
print(32 * min32 + 256 * min256)


(k2, k3, k5, k6) = map(int, input().split())
big = min(k2, k5, k6)
k2 -= big
small = min(k2, k3)
print(big * 256 + small * 32)


given = list(map(int, input().split()))
k1 = given[0]
k2 = given[1]
k3 = given[2]
k4 = given[3]
ans = min(k1, k3, k4)
count = ans * 256
ans1 = min(k1 - ans, k2)
count += ans1 * 32
print(count)


a = [int(x) for x in input().split()]
tmp = answer1 = min(a[0], a[2], a[3])
a[0] = a[0] - tmp
answer2 = min(a[0], a[1])
print(answer2 * 32 + answer1 * 256)


import math, sys, re, itertools, pprint, collections, copy
(rs, ri, rai, raf) = (input, lambda : int(input()), lambda : list(map(int, input().split())), lambda : list(map(float, input().split())))
(k2, k3, k5, k6) = rai()
a = max(min(k2, k5, k6), 0)
b = max(min(k2 - a, k3), 0)
print(a * 256 + b * 32)


l = list(map(int, input().split()))
(d, c, c1) = ({}, 0, 0)
(d[2], d[3], d[5], d[6]) = l
c += 256 * min(d[2], d[5], d[6])
c1 += 1 * min(d[2], d[5], d[6])
c += 32 * min(d[3], max(0, d[2] - c1))
print(c)


(k2, k3, k5, k6) = map(int, input().split())
s = 0
k = min(k2, k5, k6)
k1 = k2 - k
s = k * 256 + min(k1, k3) * 32
print(s)


xs = [int(x) for x in input().split(' ')]
k2 = xs[0]
k3 = xs[1]
k5 = xs[2]
k6 = xs[3]
cnt256 = min(k2, min(k5, k6))
cnt32 = max(0, min(k2 - cnt256, k3))
print(cnt256 * 256 + cnt32 * 32)


def digits(k):
	x = min(k[0], k[2], k[3])
	y = min(k[1], k[0] - x)
	return 256 * x + 32 * y
k_li = input().split()
k = []
for i in range(len(k_li)):
	k.append(int(k_li[i]))
res = digits(k)
print(res)


l = [int(i) for i in input().split()]
l2 = [l[0], l[2], l[3]]
l2.sort()
a = max(l[0] - l2[0], 0)
ans = 256 * l2[0]
ans += 32 * min(l[1], a)
print(ans)


ls = []
ls = list(map(int, input().split()))
w = ls[1]
ls[1] = 100000000
m = min(ls)
s = m * 256
m = ls[0] - m
ls1 = []
ls1.append(m)
ls1.append(w)
print(min(ls1) * 32 + s)


(k2, k3, k5, k6) = map(int, input().split())
sum1 = 0
sum2 = 0
t = min(k2, k5, k6)
sum1 += t * 256
k2 -= t
k5 -= t
k6 -= t
if k2 > 0:
	n = min(k2, k3)
	sum2 += n * 32
	print(sum1 + sum2)
else:
	print(sum1)


(a, b, c, d) = map(int, input().split())
k = min(a, min(c, d))
if b >= a - k:
	t = a - k
else:
	t = b
print(k * 256 + t * 32)


def main():
	try:
		while True:
			(a, b, c, d) = map(int, input().split())
			x = min(a, c, d)
			print((x << 8) + (min(a - x, b) << 5))
	except EOFError:
		pass
main()


import sys
import math
import bisect
import re

def main():
	A = list(map(int, input().split()))
	v1 = min([A[0], A[2], A[3]])
	A[0] -= v1
	A[2] -= v1
	A[3] -= v1
	v2 = min(A[0], A[1])
	print(v1 * 256 + v2 * 32)
main()


(a, b, c, d) = map(int, input().split())
a256 = min(a, min(c, d))
a -= a256
c -= a256
d -= a256
a32 = min(a, b)
ans = 256 * a256 + 32 * a32
print(ans)


(a, b, c, d) = map(int, input().split())
tot = 0
e = min(a, c, d)
tot += e * 256
a -= e
if a > 0:
	e = min(a, b)
	tot += e * 32
print(tot)


list1 = []
char1 = ''
sum1 = 0
sum2 = 0
char1 = char1 + input()
char2 = char1.split(' ')
for n in char2:
	list1.append(int(n))
sum1 = min(list1[0], list1[2], list1[3])
if sum1 == list1[0]:
	print(256 * sum1)
else:
	list1[0] = list1[0] - sum1
	sum2 = min(list1[0], list1[1])
	print(256 * sum1 + 32 * sum2)


(a, b, c, d) = input().split()
n = min(int(a), min(int(c), int(d)))
m = min(int(b), int(a) - n)
print(256 * n + 32 * m)


(a, b, c, d) = list(map(int, input().split()))
g = 0
h = min([a, c, d])
g = 256 * h
a -= h
c -= h
d -= h
h = max(min(a, b), 0)
a -= h
b -= h
g += 32 * h
print(g)


def main():
	(k2, k3, k5, k6) = list(map(int, input().split()))
	count256 = 0
	count32 = 0
	count256 = min(k2, k5, k6)
	(k2, k5, k6) = (k2 - count256, k5 - count256, k6 - count256)
	count32 = min(k3, k2)
	print(count256 * 256 + count32 * 32)
main()


(a, b, c, d) = (int(i) for i in input().split())
if a == min(a, c, d):
	print(a * 256)
x = a - min(a, c, d)
if x != 0:
	print(min(x, b) * 32 + min(a, c, d) * 256)


(k2, k3, k5, k6) = [int(_) for _ in input().split()]
number_of_256 = min(k2, k5, k6)
k2 -= number_of_256
k5 -= number_of_256
k6 -= number_of_256
number_of_32 = min(k2, k3)
k2 -= number_of_32
k3 -= number_of_32
print(number_of_256 * 256 + number_of_32 * 32)


l = list(map(int, input().split()))
sum = 0
k = min(l[0], l[2], l[3])
sum += 256 * k
l[0] -= k
l[2] -= k
l[3] -= k
sum += 32 * min(l[0], l[1])
print(sum)


(d2, d3, d5, d6) = map(int, input().split())
min256 = min(d2, d5, d6)
sum = 256 * min256
d2 = d2 - min256
if d2 < 0:
	print(sum)
else:
	sum += 32 * min(d2, d3)
	print(sum)


(tw, th, f, s) = map(int, input().split())
count = 0
m = min(tw, f, s)
count += 256 * m
m = min(th, tw - m)
count += 32 * m
print(count)


(a, b, c, d) = map(int, input().split())
res256 = min(a, c, d)
res32 = min(a - res256, b)
print(res256 * 256 + res32 * 32)


def solve(test):
	(a, b, c, d) = map(int, input().split())
	ans = min(a, c, d)
	a -= ans
	ans = 256 * ans + 32 * min(a, b)
	print(ans)
t = 1
for _ in range(t):
	solve(_ + 1)


(x, y, z, u) = map(int, input().split())
if x < z and x < u:
	print(min(x, z, u) * 256)
elif x != 0 and y != 0 and (z != 0) and (u != 0) and (x == y) and (y == z) and (z == u):
	print(256 * x)
elif x > z or x > u:
	print(min(x, u, z) * 256 + min(x - min(x, u, z), y) * 32)
elif x == z and z == u:
	print(x * 256)
elif x == z or x == u or z == u:
	print(256 * min(x, z, u))


(k_2, k_3, k_5, k_6) = map(int, input().split())
min_256 = min(k_2, k_5, k_6)
min_32 = min(k_3, k_2)
print(max(256 * min_256 + 32 * min(k_2 - min_256, k_3), 32 * min_32 + 256 * min(k_2 - min_32, min_256)))


(k2, k3, k5, k6) = [int(i) for i in input().split()]
m = min(k2, k5, k6)
(k2, k5, k6) = (k2 - m, k5 - m, k6 - m)
s = 0
if m != 0:
	for _ in range(m):
		s += 256
m = min(k2, k3)
if m != 0:
	for _ in range(m):
		s += 32
print(s)


(n_2, n_3, n_5, n_6) = map(int, input().split())
lower = n_5 if n_5 <= n_6 else n_6
sum = 0
x = min([n_2, n_5, n_6])
n_2 -= x
sum += 256 * x
y = min([n_2, n_3])
sum += 32 * y
print(sum)


def max_sum(k2, k3, k5, k6):
	sum = 0
	num_of_256 = min(k5, k6, k2)
	sum += 256 * num_of_256
	k5 -= num_of_256
	k6 -= num_of_256
	k2 -= num_of_256
	num_of_32 = min(k2, k3)
	sum += 32 * num_of_32
	k3 -= num_of_32
	k2 -= num_of_32
	return sum
user_input = input()
int_inputs = map(int, user_input.split(' ')[0:4])
print(max_sum(*int_inputs))


def func(n):
	sume = 0
	two = n[0]
	three = n[1]
	five = n[2]
	six = n[3]
	while two and five and six:
		sume += 256
		two -= 1
		five -= 1
		six -= 1
	while two and three:
		sume += 32
		two -= 1
		three -= 1
	print(sume)
n = list(map(int, input().split()))
func(n)


__author__ = 'artyom'

def main():
	(k2, k3, k5, k6) = read(3)
	n = min(k2, k5, k6)
	return 256 * n + 32 * min(k3, k2 - n)

def read(mode=1, size=None):
	if mode == 0:
		return input().strip()
	if mode == 1:
		return int(input().strip())
	if mode == 2:
		return input().strip().split()
	if mode == 3:
		return list(map(int, input().strip().split()))
	a = []
	for _ in range(size):
		a.append(read(3))
	return a

def write(s='\n'):
	if s is None:
		s = ''
	if isinstance(s, tuple) or isinstance(s, list):
		s = ' '.join(map(str, s))
	s = str(s)
	print(s, end='\n')
write(main())


(k2, k3, k5, k6) = map(int, input().split())
sum256 = min(k2, k5, k6) * 256
sum32 = min(k2 - min(k2, k5, k6), k3) * 32
print(sum256 + sum32)


def solve(arr):
	ans = 0
	ans += 256 * min(arr[0], arr[2], arr[3])
	arr[0] -= min(arr[0], arr[2], arr[3])
	arr[2] -= min(arr[0], arr[2], arr[3])
	arr[3] -= min(arr[0], arr[2], arr[3])
	ans += 32 * min(arr[0], arr[1])
	return ans
arr = list(map(int, input().split()))
print(solve(arr))


(k2, k3, k5, k6) = map(int, input().split())
min_value = min(k2, k5, k6)
another_min = min(k3, k2 - min_value)
print(256 * min_value + 32 * another_min)


mass = list(map(int, input().split()))
print(min(mass[1], mass[0] - min(mass[0], mass[2], mass[3])) * 32 + min(mass[0], mass[2], mass[3]) * 256)


s = input().split(' ')
n2 = int(s[0])
n3 = int(s[1])
n5 = int(s[2])
n6 = int(s[3])
f = min(min(n2, n5), n6)
mini = f
sum = 0
n2 -= mini
n5 -= mini
n6 -= mini
sum += f * 256
z = min(n2, n3)
sum += 32 * z
print(sum)


def main():
	(n1, n2, n3, n4) = map(int, input().split())
	ans = 0
	ans += 256 * min(n1, n3, n4)
	n1 -= min(n1, n3, n4)
	ans += 32 * min(n1, n2)
	print(ans)
	return
main()


is_debug = False
k = [int(x) for x in input().split()]
print(f'k={k}') if is_debug else ''
t = 0
m = k[0]
m = min(m, k[2])
m = min(m, k[3])
t = t + m * 256
k[0] = k[0] - m
m = k[0]
m = min(m, k[1])
t = t + m * 32
print(t)


import math
from collections import *
import sys
from functools import reduce

def get_ints():
	return map(int, input().strip().split())

def get_list():
	return list(get_ints())

def get_string():
	return list(input().strip().split())

def printxsp(*args):
	return print(*args, end='')

def printsp(*args):
	return print(*args, end=' ')
UGLYMOD = int(1000000000.0) + 7
SEXYMOD = 998244353
MAXN = int(100000.0)
(k2, k3, k5, k6) = get_ints()
a = min(k2, k5, k6)
k2 -= a
b = min(k3, k2)
print(256 * a + 32 * b)


(a, b, c, d) = [int(x) for x in input().split()]
first = min(a, c, d)
a -= first
second = min(a, b)
print(first * 256 + second * 32)


s = [int(a) for a in input().split()]
two = s[0]
three = s[1]
five = s[2]
six = s[3]
m = min(two, five, six)
cnt = m * 256
two = two - m
mm = min(two, three)
cnt = cnt + mm * 32
print(cnt)


x = input()
(k2, k3, k5, k6) = list(map(int, x.strip().split()))
vsota = min(k2, k5, k6) * 256
vsota += min(k2 - min(k2, k5, k6), k3) * 32
print(vsota)


import math

def func():
	inp = input().split()
	sum = 0
	sum = 256 * min(int(inp[0]), int(inp[2]), int(inp[3]))
	inp[0] = int(inp[0]) - min(int(inp[0]), int(inp[2]), int(inp[3]))
	sum = sum + 32 * min(int(inp[1]), int(inp[0]))
	print(sum)
func()


string = input().split(' ')
two = int(string[0])
three = int(string[1])
five = int(string[2])
six = int(string[3])
num1 = min(two, five, six)
two -= num1
num2 = min(two, three)
print(str(num1 * 256 + num2 * 32))


(k2, k3, k5, k6) = map(int, input().split())
x = [k2, k5, k6]
x1 = []
d = 256 * min(x)
k = min(x)
for i in range(len(x)):
	x[i] = x[i] - k
d += min(x[0], k3) * 32
print(d)


ks = list(map(int, input().split()))
(k2, k3, k5, k6) = (ks[0], ks[1], ks[2], ks[3])
Num256 = min(k2, k5, k6)
Num32 = min(k2 - Num256, k3)
print(str(Num256 * 256 + Num32 * 32))


def main():
	from sys import stdin, stdout
	(a, b, c, d) = map(int, stdin.readline().split())
	m256 = min(a, c, d)
	m32 = min(a - m256, b)
	print(m256 * 256 + m32 * 32)
main()


l = list(map(int, input().split()))
a = min(l[0], l[2], l[3])
for i in [0, 2, 3]:
	l[i] = l[i] - a
b = 32 * min(l[0], l[1])
print(b + a * 256)


lst1 = list(map(int, input().split()))
a = min(lst1[0], lst1[2], lst1[3])
ans = a * 256
lst1[0] -= a
b = min(lst1[0], lst1[1])
ans += b * 32
print(ans)


(b, c, e, f) = map(int, input().split())
m = min(b, e, f)
b -= m
s = 256 * m
m = min(b, c)
s += 32 * m
print(s)


(k_2, k_3, k_5, k_6) = map(int, input().split())
k_256 = min(k_2, min(k_5, k_6))
k_32 = min(k_3, k_2 - k_256)
print(256 * k_256 + 32 * k_32)


(k2, k3, k5, k6) = (int(a) for a in input().split(' '))
max256 = min(k2, k5, k6)
k2 = k2 - max256
max32 = min(k2, k3)
S = max256 * 256 + max32 * 32
print(S)


(n, m, o, p) = map(int, input().split())
a = min(n, o, p)
if a == n:
	print(a * 256)
else:
	n = n - a
	k = min(n, m)
	print(a * 256 + 32 * k)


(k2, k3, k5, k6) = map(int, input().split())
summ = 0
if k2 > 0 and k5 > 0 and (k6 > 0):
	z = min(k2, k5, k6)
	summ += 256 * z
	k2 -= z
	k5 -= z
	k6 -= z
if k2 > 0 and k3 > 0:
	z = min(k2, k3)
	summ += 32 * z
	k2 -= z
	k3 -= z
print(summ)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def foo():
	ar = inlt()
	m = min(ar[0], ar[2], ar[3])
	a = 256 * m
	ar[0] = ar[0] - m
	ar[2] = ar[2] - m
	ar[3] = ar[3] - m
	n = min(ar[0], ar[1])
	b = 32 * n
	print(a + b)
foo()


import math

def get_primes(prime_supr):
	is_prime = [0] * 2 + [1] * prime_supr
	for i in range(2, int(math.sqrt(prime_supr)) + 1):
		if is_prime[i]:
			for j in range(i * i, prime_supr + 1, i):
				is_prime[j] = 0
	return is_prime
get_int = lambda : map(int, input().split())
a = list(get_int())
print(min(a[0], a[2], a[3]) * 256 + min(a[0] - min(a[0], a[2], a[3]), a[1]) * 32)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
(k2, k3, k5, k6) = invr()
m = min(k2, k5, k6)
s = m * 256
k2 = k2 - m
n = min(k2, k3)
s = s + n * 32
print(s)


(k_1, k_2, k_3, k_4) = map(int, input('').split())
sum = 0
minimum_1 = min(k_1, k_3, k_4)
sum += 256 * minimum_1
k_1 = k_1 - minimum_1
k_3 = k_3 - minimum_1
k_4 = k_4 - minimum_1
minimum_2 = min(k_1, k_2)
sum += 32 * minimum_2
print(sum)


(n2, n3, n5, n6) = tuple(input().split(' '))
n2 = int(n2)
n3 = int(n3)
n5 = int(n5)
n6 = int(n6)
a = min(n2, n5)
a = min(a, n6)
sum = a * 256
n2 -= a
a = min(n2, n3)
sum += a * 32
print(sum)


(k2, k3, k5, k6) = map(int, input().split())
summa = 0
for i in range(5000001):
	if k2 > 0 and k5 > 0 and (k6 > 0):
		summa += 256
		k2 -= 1
		k5 -= 1
		k6 -= 1
	else:
		break
for i in range(50000001):
	if k2 > 0 and k3 > 0:
		summa += 32
		k2 -= 1
		k3 -= 1
	else:
		break
print(summa)


(k2, k3, k5, k6) = map(int, input().split())
minimum = min(k2, k5, k6)
total = 256 * minimum
if k2 > minimum:
	total += 32 * min(k2 - minimum, k3)
print(total)


(k2, k3, k5, k6) = map(int, input().split())
s1 = min(k2, k5, k6)
k2 = k2 - s1
s2 = min(k2, k3)
print(s1 * 256 + s2 * 32)


(k2, k3, k5, k6) = map(int, input().split(' '))
num_256 = min(k2, k5, k6)
k2 -= num_256
num_32 = min(k2, k3)
print(num_256 * 256 + num_32 * 32)


from sys import stdin, stdout
(k2, k3, k5, k6) = map(int, stdin.readline().split())
highest = min(k2, k5, k6)
k2 -= highest
k5 -= highest
k6 -= highest
ans = highest * 256
lower = min(k2, k3)
ans += lower * 32
stdout.write(str(ans) + '\n')


(a, b, c, d) = map(int, input().split())
e = min(c, d)
s = 0
if a >= e:
	s = s + e * 256
	a = a - e
	s = s + min(a, b) * 32
else:
	s = s + a * 256
print(s)


(dois, tres, cinco, seis) = map(int, input().split())
soma = 0
sub = min(dois, cinco, seis)
soma += 256 * sub
dois -= sub
sub = min(dois, tres)
soma += 32 * sub
print(soma)


a = [int(i) for i in input().split()]
ans = 0
max_ = min(a[0], a[2], a[3])
a[0] -= max_
ans += 256 * max_
max_ = min(a[0], a[1])
ans += 32 * max_
print(ans)


(a, b, c, d) = list(map(int, input().split()))
num256 = min(a, c, d)
a -= num256
c -= num256
d -= num256
num32 = min(b, a)
a -= num32
b -= num32
print(num256 * 256 + num32 * 32)


(k2, k3, k5, k6) = map(int, input().strip().split(' '))
x = min(k2, k5, k6)
s = 256 * x
k2 -= x
x = min(k2, k3)
s += x * 32
print(s)


(k2, k3, k5, k6) = list(map(int, input().split()))
ans = 0
x = min(k2, k5, k6)
ans += 256 * x
k2 -= x
k5 -= x
k6 -= x
x = min(k2, k3)
ans += 32 * x
print(ans)


(k2, k3, k5, k6) = map(int, input().split())
t_f_s = min(k2, k5, k6)
k2 -= t_f_s
t_t = min(k2, k3)
print(256 * t_f_s + 32 * t_t)


(k1, k2, k3, k4) = list(map(int, input().split()))
x = []
x.append(k1)
x.append(k3)
x.append(k4)
y = min(x)
sum = min(x) * 256
res = list(map(lambda z: z - y, x))
if res[0] >= 1 and k2 >= 1:
	if res[0] == 1 and k2 == 1:
		sum += 32
	elif res[0] < k2:
		sum += res[0] * 32
	else:
		sum += k2 * 32
print(sum)


(a2, a3, a5, a6) = tuple(map(int, input().split()))
minn = min([a2, a5, a6])
a2 -= minn
sum = minn * 256
sum += min([a2, a3]) * 32
print(sum)


(k2, k3, k5, k6) = [int(x) for x in input().split(' ')]
S = 0
S += min(k2, k5, k6) * 256
k2 -= int(S / 256)
k5 -= int(S / 256)
k6 -= int(S / 256)
S += min(k2, k3) * 32
print(str(S))


amt = list(map(lambda x: int(x), input().split()))
print(min(amt[0], amt[2], amt[3]) * 256 + min(amt[0] - min(amt[0], amt[2], amt[3]), amt[1]) * 32)


(a, b, c, d) = [int(a) for a in input().split()]
ans = 0
max256 = min(a, c, d)
ans += 256 * max256
a -= max256
c -= max256
d -= max256
max32 = min(a, b)
ans += 32 * max32
a -= max32
b -= max32
print(ans)


k = list(map(int, input().split()))
m = min(k[0], k[2], k[3])
output = m * 256 + min(k[0] - m, k[1]) * 32
print(output)


(a, b, c, d) = [int(i) for i in input().split()]
e = min(min(a, c), d)
sum = 0
sum = sum + e * 256
a = a - e
f = min(a, b)
sum = sum + f * 32
print(sum)


a = list(map(int, input().split()))
for x in range(len(a)):
	n = min(a[0], a[2], a[3])
	z = min(a[1], a[0] - n)
print(n * 256 + 32 * z)


(a, b, c, d) = list(map(int, input().split()))
z = min(a, d, c)
x = min(a - z, b)
print(z * 256 + x * 32)


(number2, number3, number5, number6) = map(int, input().split())
quantity = 0
while number2 > 0 and number5 > 0 and (number6 > 0) or (number2 > 0 and number3 > 0):
	if number2 > 0 and number5 > 0 and (number6 > 0):
		quantity += 256
		number2 -= 1
		number5 -= 1
		number6 -= 1
	else:
		quantity += 32
		number2 -= 1
		number3 -= 1
print(quantity)


(a, b, c, d) = map(int, input().split())
x = min([a, c, d])
y = a - x
if y > 0:
	y = min([a - x, b])
	print(256 * x + y * 32)
else:
	print(256 * x)


(a2, a3, a5, a6) = list(map(int, input().split()))
y = min(a5, a6, a2)
x = min(a3, a2 - y)
print(x * 32 + y * 256)


(k2, k3, k5, k6) = map(int, input().split())
ans = 256 * min(k2, k5, k6)
if k2 - min(k2, k5, k6) >= 1 and k3 >= 1:
	ans += 32 * min(k3, k2 - min(k2, k5, k6))
print(ans)


l = list(map(int, input().split()))
f = min(l[0], l[2], l[3])
s = 256 * f
l[0] -= f
l[2] -= f
l[3] -= f
s += 32 * min(l[0], l[1])
print(s)


(k2, k3, k5, k6) = map(int, input().strip().split(' '))
d32 = 0
d256 = 0
d256 += min(k2, k5, k6)
k2 -= min(k2, k5, k6)
d32 = min(k2, k3)
print(d256 * 256 + d32 * 32)


a = list(map(int, input().split()))
d = min(a[0], a[2], a[3])
a[0] -= d
d = d * 256
if a[0] > 0 and a[1] > 0:
	e = min(a[1], a[0])
	d = d + e * 32
print(d)


s = input()
a = s.split()
k2 = int(a[0])
k3 = int(a[1])
k5 = int(a[2])
k6 = int(a[3])
ans = 0
k5 = min(k5, k6)
if k5 >= k2:
	ans = k2 * 256
	k2 = -1
else:
	ans = k5 * 256
	k2 -= k5
if k2 > 0:
	ans += 32 * min(k3, k2)
print(ans)


numbers = list(map(int, input().split()))
i = 0
low_num = [numbers[0], numbers[1]]
numbers.remove(numbers[1])
min_num = min(numbers)
low_num[0] = low_num[0] - min_num
low_min_num = min(low_num)
print(min_num * 256 + low_min_num * 32)


a = list(map(int, input().split()))
s = 0
k = min(a[0], a[2], a[3])
s += 256 * k
a[0] = a[0] - k
if a[0] > 0 and a[1] > 0:
	s += 32 * min(a[0], a[1])
	print(s)
else:
	print(s)


a = [int(i) for i in input().split(' ')]
s1 = 0
s2 = 0
k2 = a[0]
k3 = a[1]
k5 = a[2]
k6 = a[3]
s1 = min(k3, k2) * 32 + 256 * min(min(k5, k6), k2 - min(k2, k3))
s2 = min(min(k2, k5), k6) * 256 + 32 * min(k3, k2 - min(min(k2, k5), k6))
print(max(s1, s2))


a = input().split(' ')
for i in range(4):
	a[i] = int(a[i])
x = min(a[0], a[2], a[3])
if a[0] - x > 0:
	y = min(a[0] - x, a[1])
else:
	y = 0
print(x * 256 + y * 32)


arr = list(map(int, input().split()))
delar = arr[1]
arr.pop(1)
fst = min(arr)
nd = min([arr[0] - fst, delar])
print(32 * nd + 256 * fst)


(k2, k3, k5, k6) = map(int, input().split())
min1 = min(k2, k5, k6)
ans1 = 256 * min1
k2 = k2 - min1
k5 = k5 - min1
k6 = k6 - min1
min2 = min(k2, k3)
ans2 = 32 * min2
print(ans1 + ans2)


(k2, k3, k5, k6) = map(int, input().split())
ans = 0
a = min(k2, k5, k6)
ans += a * 256
k2 -= a
a2 = min(k3, k2)
ans += a2 * 32
print(ans)


from sys import stdin, stdout
(k1, k2, k3, k4) = map(int, stdin.readline().split())
k = min(k1, min(k3, k4))
stdout.write(str(k * 256 + min(k1 - k, k2) * 32))


import sys
inf = float('inf')
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
(mod, MOD) = (1000000007, 998244353)
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
(two, three, five, six) = get_ints()
z = min(two, five, six)
if two >= z:
	two -= z
print(z * 256 + min(two, three) * 32)


s = input().split()
for i in range(0, 4):
	s[i] = int(s[i])
min = s[0]
for i in range(0, 4):
	if i == 1:
		continue
	if s[i] < min:
		min = s[i]
sum = 0
for i in range(0, 4):
	if i == 1:
		continue
	s[i] = s[i] - min
min1 = s[0]
for i in range(0, 2):
	if s[i] < min1:
		min1 = s[i]
sum = 256 * min + 32 * min1
print(sum)


(t, th, f, s) = map(int, input().split())
M = min(t, f, s)
n = M * 256
t -= M
n += min(t, th) * 32
print(n)


inp = lambda : map(int, input().split(' '))
res = 0
p = list(inp())
q = min(p[0], p[2], p[3])
res += 256 * q
res += 32 * min(p[0] - q, p[1])
print(res)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def solve():
	(k2, k3, k5, k6) = sep()
	ans = 0
	k = min(k2, k5, k6)
	ans += k * 256
	k2 -= k
	k = min(k2, k3)
	ans += k * 32
	print(ans)
solve()


(a, b, c, d) = map(int, input().split())
n = min(a, c, d)
m = min(a - n, b)
print((n << 8) + (m << 5))


arr = map(int, input().strip().split())
list1 = list(arr)
x = min(list1[0], list1[2], list1[3])
list1[0] -= x
list1[2] -= x
list1[3] -= x
y = min(list1[0], list1[1])
list1[0] -= y
list1[1] -= y
print(256 * x + 32 * y)


k = [int(x) for x in input().split()]
num256 = min(k[0], k[2], k[3])
k[0] = k[0] - num256
num32 = min(k[0], k[1])
print(256 * num256 + 32 * num32)


x = input().split()
a = []
for i in range(len(x)):
	if i == 1:
		d = int(x[i])
	else:
		a.append(int(x[i]))
m = min(a)
a[0] -= m
n = min(d, a[0])
print(m * 256 + n * 32)


(k2, k3, k5, k6) = input().split()
(k2, k3, k5, k6) = (int(k2), int(k3), int(k5), int(k6))
n256 = min(k2, k5, k6)
n32 = 0
if min(k2, k5, k6) != k2:
	n32 = min(k2 - min(k5, k6), k3)
print(n256 * 256 + n32 * 32)


(k2, k3, k5, k6) = map(int, input().split(' '))
x = min(k2, k5, k6)
z = min(k3, k2 - x)
total = x * 256 + z * 32
print(total)


k = list(map(int, input().split()))
max_nums = min(k[0], k[2], k[3])
v = max_nums * 256
if k[0] - max_nums > k[1]:
	s = k[1] * 32
else:
	s = (k[0] - max_nums) * 32
print(v + s)


from math import *
from sys import *
from queue import *
(a, b, c, d) = (int(z) for z in input().split())
ans = 0
ans += 256 * min(a, c, d)
a -= min(a, c, d)
ans += 32 * min(a, b)
print(ans)


x = input().split(' ')
m = min(int(x[0]), int(x[2]), int(x[3]))
if m == int(x[0]):
	l = m * 256
else:
	f = int(x[0]) - m
	if f < int(x[1]):
		l = m * 256 + f * 32
	else:
		l = m * 256 + int(x[1]) * 32
print(l)


import sys
if False:
	input = open('digits.txt', 'r')
else:
	input = sys.stdin
n = input.readline().split()
numbers = []
for i in n:
	i = int(i)
	numbers.append(i)
sums = 0
larger = [numbers[0], numbers[2], numbers[3]]
smaller = [numbers[0], numbers[1]]
larger.sort()
sums = sums + larger[0] * 256
for r in larger:
	r = r - larger[0]
smaller[0] = smaller[0] - larger[0]
smaller.sort()
sums = sums + smaller[0] * 32
print(sums)


(a, b, c, d) = map(int, input().split(' '))
total = 0
big = min(a, c, d)
a = a - big
c = c - big
d = d - big
small = min(a, b)
total = 256 * big + 32 * small
print(int(total))


(k2, k3, k5, k6) = map(int, input().split())
if k2 > k5:
	if k5 > k6:
		k = k6
		k2 -= k6
		if k2 > k3:
			h = k3
		else:
			h = k2
	else:
		k = k5
		k2 -= k5
		if k2 > k3:
			h = k3
		else:
			h = k2
elif k2 > k6:
	k = k6
	k2 -= k6
	if k2 > k3:
		h = k3
	else:
		h = k2
else:
	k = k2
	h = 0
print(k * 256 + h * 32)


(k2, k3, k5, k6) = map(int, input().split())
ind = min(k2, k5, k6)
ind2 = min(k3, k2 - ind)
print(256 * ind + 32 * ind2)


(t, th, f, si) = list(map(int, input().split()))
tfs = min(t, f, si)
t -= tfs
f -= tfs
si -= tfs
sum = 0
sum += 256 * tfs
sum += min(t, th) * 32
print(sum)


def ListFromInput():
	return [int(el) for el in input().split()]

def main():
	(k2, k3, k5, k6) = ListFromInput()
	count_of_256 = min(k2, k5, k6)
	count_of_lasts_2 = k2 - count_of_256
	count_of_32 = min(k3, count_of_lasts_2)
	max_summ = count_of_256 * 256 + count_of_32 * 32
	print(max_summ)
main()


(a, b, c, d) = map(int, input().split())
c2 = min(a, c, d)
a -= c2
c -= c2
d -= c2
c1 = min(a, b)
print(c2 * 256 + c1 * 32)


def lmap(f, x):
	return list(map(f, x))

def read_ints():
	return lmap(int, input().strip().split())

def main():
	res = 0
	(a2, a3, a5, a6) = read_ints()
	n256 = min(a2, a5, a6)
	res += n256 * 256
	a2 -= n256
	a5 -= n256
	a6 -= n256
	n32 = min(a3, a2)
	res += n32 * 32
	return res
print(main())


(a, b, c, d) = [int(i) for i in input().split()]
m = min(a, c, d)
n = a - m
o = min(b, n)
if o >= 0:
	s = m * 256 + o * 32
	print(s)
else:
	print(m * 256)


(k1, k2, k3, k4) = list(map(int, input().split()))
a = min(k1, k3, k4)
t = 256 * a
k1 = k1 - a
t += 32 * min(k1, k2)
print(t)


(k2, k3, k5, k6) = [int(x) for x in input().split(' ')]
m = 0
x = min(k2, k5, k6)
m += 256 * x
k2 -= x
k5 -= x
k6 -= x
y = min(k3, k2)
m += 32 * y
print(m)


def min(*a):
	min = a[0]
	for i in a:
		if min > i:
			min = i
	return min
(k2, k3, k5, k6) = map(int, input().split())
sum = 0
m = min(k2, k5, k6)
sum = sum + m * 256
if k2 - m > 0:
	sum = sum + min(k2 - m, k3) * 32
print(sum)


(k2, k3, k5, k6) = map(int, input().split())
c256 = min([k2, k5, k6])
c32 = min([k3, k2 - c256])
print(256 * c256 + 32 * c32)


(s2, s3, s5, s6) = map(int, input().split())
answer = 0
min_256 = min(s2, s5, s6)
answer += min_256 * 256
s2 -= min_256
s5 -= min_256
s6 -= min_256
min_32 = min(s2, s3)
answer += min_32 * 32
print(answer)


(a, b, c, d) = map(int, input().split())
i = min(a, c, d)
o = 256 * i
a -= i
c -= i
d -= i
y = min(b, a)
o += 32 * y
b -= y
a -= y
print(o)


(n, m, a, b) = map(int, input().split())
s = 0
c = min(n, a, b)
e = n - c
d = min(e, m)
s += 256 * c
s += 32 * d
print(s)


a = input().split()
two = int(a[0])
three = int(a[1])
five = int(a[2])
six = int(a[3])
total = 0
d = min(two, five, six)
total = d * 256
two = two - d
e = min(two, three)
total = total + e * 32
print(total)


a = list(map(int, input().split()))
s = min(a[0], a[2], a[3])
s1 = a[0] - s
print(256 * s + 32 * min(s1, a[1]))


l = list(map(int, input().split()))
k2 = l[0]
k3 = l[1]
k5 = l[2]
k6 = l[3]
sm = 0
r = min(k2, k5, k6)
sm += r * 256
(k2, k5, k6) = (k2 - r, k5 - r, k6 - r)
r = min(k2, k3)
sm += r * 32
print(sm)


(a, b, c, d) = map(int, input().split())
minimum = min(a, c, d)
sum = 0
a = a - minimum
c = c - minimum
d = d - minimum
sum = minimum * 256
mini = min(a, b)
sum += mini * 32
print(sum)


(d, t, ch, p) = map(int, input().split())
ans = 0
ans = min(d, ch, p) * 256
d -= min(d, ch, p)
ans += min(d, t) * 32
print(ans)


(a, b, c, d) = map(int, input().split())
if c == 0 or d == 0:
	print(32 * min(a, b))
elif a == 0:
	print(0)
else:
	print(min(a, c, d) * 256 + min(a - min(a, c, d), b) * 32)


from collections import deque, Counter
import array
from itertools import combinations, permutations
from math import sqrt
import unittest

def read_int():
	return int(input().strip())

def read_int_array():
	return [int(i) for i in input().strip().split(' ')]
(k2, k3, k5, k6) = read_int_array()
num256 = min(k2, k5, k6)
k2 -= num256
num32 = min(k2, k3)
print(256 * num256 + 32 * num32)


(k2, k3, k5, k6) = map(int, input().split())
t1 = min(k2, k5, k6)
t2 = min(k2 - t1, k3)
print(256 * t1 + 32 * t2)


c = list(map(int, input().split()))

def min(a, b):
	if a > b:
		return b
	else:
		return a
s = 0
s += min(c[0], min(c[2], c[3])) * 256
c[0] -= min(c[0], min(c[2], c[3]))
s += min(c[0], c[1]) * 32
print(s)


(k2, k3, k5, k6) = map(int, input().split())
ans = 0
kol = min(k2, k5, k6)
ans += kol * 256
k2 -= kol
k5 -= kol
k6 -= kol
kol1 = min(k3, k2)
ans += kol1 * 32
print(ans)


from typing import Iterator

def get_num_input() -> Iterator[int]:
	return map(int, input().split())

def main() -> None:
	twos: int
	threes: int
	fives: int
	sixes: int
	(twos, threes, fives, sixes) = get_num_input()
	count: int = min(twos, fives, sixes)
	print(256 * count + 32 * min(twos - count, threes))
ONLY_ONCE: bool = True
for _ in range(1 if ONLY_ONCE else int(input())):
	main()


k = list(map(int, input().split()))
first = min(k[0], k[2], k[3])
k[0] -= first
k[2] -= first
k[3] -= first
second = min(k[1], k[0])
print(first * 256 + second * 32)


t = 1
while t > 0:
	t -= 1
	(k2, k3, k5, k6) = map(int, input().split())
	n = min(k2, k5, k6)
	m = min(k3, k2 - n)
	print(32 * m + 256 * n)


(k2, k3, k5, k6) = [int(i) for i in input().split()]
tfs = min(k2, k5, k6)
k2 = k2 - tfs
tt = min(k2, k3)
total_sum = tfs * 256 + tt * 32
print(total_sum)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	(a, b, c, d) = LI()
	t = min([a, c, d])
	r = t * 256
	a -= t
	t = min(a, b)
	return r + t * 32
print(main())


l = list(map(int, input().split()))
c = l[1]
l.remove(c)
v = min(l)
d = l[0] - v
if d < c:
	g = d
else:
	g = c
q = v * 256 + g * 32
print(q)


(two, three, five, six) = map(int, input().split())
n_256 = min(two, five, six)
two -= n_256
five -= n_256
six -= n_256
n_32 = min(two, three)
print(256 * n_256 + 32 * n_32)


l = list(map(int, input().split()))
k = l[1]
del l[1]
r = min(l)
e = r * 256 + 32 * min(k, l[0] - r)
print(e)


l = list(map(int, input().split()))
t = l[0]
th = l[1]
f = l[2]
s = l[3]
x = min(s, f, t)
ans = 256 * x
t -= x
f -= x
s -= x
y = min(t, th)
ans += 32 * y
print(ans)


(k2, k3, k5, k6) = map(int, input().split())
num_256 = min(k2, k5, k6)
k2 = k2 - num_256
if k2 > 0:
	num_32 = min(k2, k3)
else:
	num_32 = 0
print(256 * num_256 + 32 * num_32)


a = list(map(int, input().split()))
w = min(a[0], a[2], a[3])
am = 256 * w
am += 32 * min(a[0] - w, a[1])
print(am)


(t, th, f, s) = map(int, input().split())
ans = 0
a = min(t, f, s)
ans += a * 256
t -= a
x = min(t, th)
ans += x * 32
print(ans)


def main():
	x = list(map(int, input().split()))
	ans = 0
	y = min(x[0], x[2], x[3])
	ans += 256 * y
	x[0] -= y
	x[2] -= y
	x[3] -= y
	ans += 32 * min(x[0], x[1])
	print(ans)
main()


(two, three, five, six) = map(int, input().split())
s = min(two, five, six)
z = 0
if two - s > 0:
	z += min(two - s, three)
print(s * 256 + z * 32)


l = [int(x) for x in input().split()]
k = min(l[0], l[2], l[3])
a = l[0] - k
j = min(a, l[1])
print(256 * k + 32 * j)


(a, b, c, d) = map(int, input().split())
t = min(a, c, d)
a = abs(a - t)
count = t * 256
a = min(a, b)
print(count + a * 32)


(k2, k3, k5, k6) = map(int, input().split())
intDict = {'2': k2, '3': k3, '5': k5, '6': k6}
output = 0
runs = min(k2, k5, k6)
output += 256 * runs
intDict['2'] -= runs
intDict['5'] -= runs
intDict['6'] -= runs
runs = min(intDict['2'], k3)
output += 32 * runs
intDict['2'] -= runs
intDict['3'] -= runs
print(output)


def getMin(n1, n2, n3):
	if n1 <= n2 and n1 <= n3:
		return n1
	if n2 <= n1 and n2 <= n3:
		return n2
	return n3
(k2, k3, k5, k6) = list(map(int, input().split()))
total = 0
m = getMin(k2, k5, k6)
total += 256 * m
k2 -= m
k5 -= m
k6 -= m
m = getMin(k2, k3, k3)
total += 32 * m
k2 -= m
k3 -= m
print(total)


s = input()
temp = s.split()
twoDigitCount = int(temp[0])
threeDigitCount = int(temp[1])
fiveDigitCount = int(temp[2])
sixDigitCount = int(temp[3])
bigNumberCount = min(twoDigitCount, fiveDigitCount, sixDigitCount)
twoDigitCount = twoDigitCount - bigNumberCount
fiveDigitCount = fiveDigitCount - bigNumberCount
sixDigitCount = sixDigitCount - bigNumberCount
smallNumberCount = min(threeDigitCount, twoDigitCount)
print(256 * bigNumberCount + 32 * smallNumberCount)


l = [int(i) for i in input().split()]
x = min(l[0], l[2], l[3])
print(256 * x + 32 * min(l[0] - x, l[1]))


n = list(map(int, input().split()))[:]
a = 0
k2 = n[0]
k3 = n[1]
k5 = n[2]
k6 = n[3]
if k2 - k5 <= 0:
	a = k2
	if k2 - k6 > 0:
		a = k6
else:
	a = k5
	if k6 - k5 <= 0:
		a = k6
x1 = 256 * a
k2 -= a
b = k2
if k3 - k2 <= 0:
	b = k3
x2 = 32 * b
total = x1 + x2
print(total)


k = [0, 0]
k = k + list(map(int, input().split()))
l = min(k[2:3] + k[4:])
k[2] = k[2] - l
j = min(k[2:4])
print(l * 256 + j * 32)


Lst = list(map(int, input().split()))
Lst1 = [Lst[0], Lst[2], Lst[3]]
Num = min(Lst1)
if Num == Lst[0]:
	print(Num * 256)
else:
	N2 = Lst[0] - Num
	Lst2 = [N2, Lst[1]]
	Num1 = min(Lst2)
	print(Num1 * 32 + Num * 256)


n = str(input())
(n2, n3, n5, n6) = n.split(' ')
total = 0
if int(n5) >= int(n6):
	if int(n2) >= int(n6):
		total += 256 * int(n6)
		n2 = int(n2) - int(n6)
	else:
		total += 256 * int(n2)
		n2 = 0
elif int(n2) >= int(n5):
	total += 256 * int(n5)
	n2 = int(n2) - int(n5)
else:
	total += 256 * int(n2)
	n2 = 0
if int(n2) <= int(n3):
	total += 32 * int(n2)
else:
	total += 32 * int(n3)
print(total)


(k2, k3, k5, k6) = [int(c) for c in input().split()]
num256 = min(k2, k5, k6)
num32 = min(k2 - num256, k3)
print(256 * num256 + 32 * num32)


l = list(map(int, input().rstrip().split()))

def calu(a):
	sum = 0
	x = min(l[2], l[3])
	if x < l[0]:
		sum = 256 * x
		l[0] -= x
	elif x == l[0]:
		return 256 * x
	elif x > l[0]:
		return 256 * l[0]
	y = min(l[1], l[0])
	sum = sum + 32 * y
	return sum
print(calu(l))


(b, a, p, q) = map(int, input().split())
s = 0
if b >= min(p, q):
	b = b - min(p, q)
	s += 256 * min(p, q)
elif b < min(p, q) and b > 0:
	s += 256 * min(p, q, b)
	b -= min(p, q)
if a > 0 and b > 0:
	s += 32 * min(a, b)
print(s)


def Anton(l):
	t = min([l[0], l[2], l[3]])
	print(t * 256 + min([l[1], l[0] - t]) * 32)
Anton([int(x) for x in input().split()])


k = input().split()
for i in range(0, len(k)):
	k[i] = int(k[i])
sum = 0
mn = min(k[0], k[2], k[3])
k[0] -= mn
k[2] -= mn
k[3] -= mn
sum += 256 * mn
mn = min(k[0], k[1])
k[0] -= mn
k[1] -= mn
sum += 32 * mn
print(sum)


(k2, k3, k5, k6) = input().split()
(k2, k3, k5, k6) = (int(k2), int(k3), int(k5), int(k6))
s = 0
m = min(k2, k5, k6)
(k2, k5, k6) = (k2 - m, k5 - m, k6 - m)
s += 256 * m
n = min(k3, k2)
(k2, k3) = (k2 - n, k3 - n)
s += 32 * n
print(s)


(k2, k3, k5, k6) = map(int, input().split())
a1 = min(k2, k5, k6)
result = a1 * 256
result += min(k2 - a1, k3) * 32
print(result)


(tw, th, f, s) = input().split()
tw = int(tw)
th = int(th)
f = int(f)
s = int(s)
n = 256 * min(tw, f, s)
d = min(tw, f, s)
tw -= d
f -= d
s -= d
r = min(tw, th)
n += 32 * r
print(n)


(two, three, five, six) = map(int, input().split())
a = min(three, two - min(two, five, six)) * 32 + min(two, five, six) * 256
b = min(two - min(two, three), five, six) * 256 + min(two, three) * 32
print(max(a, b))


(k2, k3, k5, k6) = tuple(map(int, input().strip(' ').split(' ')))
integer_1 = 256
integer_2 = 32
a = min(k2, k5, k6)
b = integer_1 * a
k2 = k2 - a
a = min(k3, k2)
c = integer_2 * a
print(b + c)


(a, b, c, d) = map(int, input().split())
sum = 0
possible_twofiftysix = min(a, c, d)
a -= possible_twofiftysix
if a != 0:
	sum += 256 * possible_twofiftysix + 32 * min(a, b)
else:
	sum += 256 * possible_twofiftysix
print(sum)


(k2, k3, k5, k6) = list(map(int, input().split()))
k = min(k2, k5, k6)
cnt = k * 256
k2 -= k
k5 -= k
k6 -= k
m = min(k3, k2)
cnt = cnt + m * 32
print(cnt)


(a, b, c, d) = map(int, input().split())
h = min(c, d)
res = 0
if h > a:
	print(a * 256)
else:
	res = res + h * 256
	a -= h
	e = min(a, b)
	res = res + e * 32
	print(res)


(a, b, c, d) = map(int, input().split())
if a - min(a, c, d) >= 1 and b != 0:
	print(min(a, c, d) * 256 + min(b, a - min(a, c, d)) * 32)
else:
	print(min(a, c, d) * 256)


(n, m, k, l) = map(int, input().split())
tufycx = min(n, k, l)
thritu = min(n - tufycx, m)
print(tufycx * 256 + thritu * 32)


(a2, a3, a5, a6) = list(map(int, input().split()))
am2 = min(a2, a5, a6)
am1 = min(a2 - am2, a3)
print(am2 * 256 + am1 * 32)


import math

def s():
	(k2, k3, k5, k6) = [int(x) for x in input().split(' ')]
	num_256 = min(k2, k5, k6)
	k2 -= num_256
	num_32 = min(k2, k3)
	ans = 256 * num_256 + 32 * num_32
	return ans
ans = s()
print(ans)


(a, b, c, d) = input().split()
a = int(a)
b = int(b)
c = int(c)
d = int(d)
k = min(a, c, d)
if k == a:
	y = k * 256
else:
	t = a - k
	m = min(t, b)
	x = m * 32
	y = x + k * 256
print(y)


(a1, a2, a3, a4) = input().split()
a1 = int(a1)
a2 = int(a2)
a3 = int(a3)
a4 = int(a4)
q = 0
r = 0
if a3 < a4:
	p = a3
else:
	p = a4
if p < a1:
	q = p
	a1 -= p
	if a1 > a2:
		r = a2
	else:
		r = a1
else:
	q = a1
n = 256 * q + 32 * r
print(n)


[a, b, c, d] = map(int, input().split())
total1 = min(a, c, d) * 256
a -= min(a, c, d)
if a > 0:
	total2 = min(a, b) * 32
	print(total1 + total2)
else:
	print(total1)


(twos, threes, fives, sixes) = map(int, input().split())
val = 0
least = min(twos, fives, sixes)
twos -= least
fives -= least
sixes -= least
val += 256 * least
if threes > 0 and twos > 0:
	val += 32 * min(threes, twos)
print(val)


(k2, k3, k5, k6) = map(int, input().strip().split())
(maxi, sumi) = (0, 0)
maxi = min(k2, k5, k6)
sumi += 256 * maxi
k2 -= maxi
maxi = 0
maxi = min(k2, k3)
sumi += 32 * maxi
print(sumi)


import sys
input = lambda : sys.stdin.readline()

def Main():
	Ans = 0
	(k2, k3, k5, k6) = map(int, input().split())
	rez = min(k2, min(k5, k6))
	ans1 = rez * 256
	k2 -= rez
	mn = min(k2, k3)
	if mn < 0:
		mn = 0
	ans2 = mn * 32
	print(ans1 + ans2)
Main()


n = [int(x) for x in input().split()]
k2 = n[0]
k3 = n[1]
k5 = n[2]
k6 = n[3]
n1 = min(k2, k5, k6)
s = 256 * n1 + 32 * min(k3, k2 - n1)
print(s)


(k2, k3, k5, k6) = list(map(int, input().split()))
dvpr = min(k2, k5, k6)
trdva = min(k2 - dvpr, k3)
print(dvpr * 256 + trdva * 32)


s = list(map(int, input().split()))
m = min(s[0], s[2], s[3])
ans = 256 * m + 32 * max(0, min(s[1], s[0] - m))
print(ans)


inp = input()
inp = inp.split()
k2 = int(inp[0].strip())
k3 = int(inp[1].strip())
k5 = int(inp[2].strip())
k6 = int(inp[3].strip())
print(min(k2, k5, k6) * 256 + min(k3, k2 - min(k2, k5, k6)) * 32)


(x, y, z, t) = map(int, input().split())
nhonhat = min(x, z, t)
new_x = int()
new_z = int()
new_t = int()
if nhonhat == x:
	new_z = z - x
	new_t = t - x
elif nhonhat == z:
	new_x = x - z
	new_t = t - z
elif nhonhat == t:
	new_x = x - t
	new_z = z - t
nhonhat_sau = min(new_x, y)
tong = nhonhat * 256 + 32 * nhonhat_sau
print(tong)


(k2, k3, k5, k6) = map(int, input().split())
summ = 0
m256 = min(k2, k5, k6)
if m256 != 0:
	summ = m256 * 256
	k2 -= m256
	k5 -= m256
	k6 -= m256
m32 = min(k3, k2)
if m32 != 0:
	summ += m32 * 32
print(summ)


(k2, k3, k5, k6) = [int(_) for _ in input().split()]
minimumNumber256 = min([k2, k5, k6])
S = 256 * minimumNumber256
k2 -= minimumNumber256
k5 -= minimumNumber256
k6 -= minimumNumber256
minimumNumber32 = min([k2, k3])
S += 32 * minimumNumber32
print(S)


ch = input()
l = ch.split()
A = [int(i) for i in l]
ch = 0
while True:
	if (A[0] != 0) & (A[2] != 0) & ((A[2] != 0) & (A[3] != 0)):
		A[0] = A[0] - 1
		A[2] = A[2] - 1
		A[3] = A[3] - 1
		ch += 256
	elif (A[2] == 0 or A[3] == 0) & ((A[0] != 0) & (A[1] != 0)):
		ch += 32
		A[0] = A[0] - 1
		A[1] = A[1] - 1
	else:
		break
print(ch)


nums = [int(i) for i in input().split()]
num256 = min(nums[0], nums[2], nums[3])
num32 = min(nums[0] - num256, nums[1])
print(num256 * 256 + num32 * 32)


(k2, k3, k5, k6) = list(map(int, input().strip().split(' ')))
ans = 0
k256 = min(k2, k5, k6)
ans += k256 * 256
k2 -= k256
k5 -= k256
k6 -= k256
k32 = min(k3, k2)
ans += k32 * 32
print(ans)


a = [int(i) for i in input().split(' ')]
s = 0
k2 = a[0]
k3 = a[1]
k5 = a[2]
k6 = a[3]
f = min(k2, k5, k6)
s = s + 256 * f
s = s + 32 * min(k2 - f, k3)
print(s)


(two, three, five, six) = map(int, input().split())
twofivesix = min(two, five, six)
threetwo = min(three, two - twofivesix)
print(256 * twofivesix + 32 * threetwo)


ar = [int(i) for i in input().split()]
k = min(ar[0], ar[2], ar[3])
ans = 0
ans += 256 * k
ar[0] -= k
ar[2] -= k
ar[3] -= k
k = min(ar[1], ar[0])
ans += 32 * k
print(ans)


def solve(k2, k3, k5, k6):
	mn = min(k2, k5, k6)
	summ = 0
	summ += 256 * mn
	k2 -= mn
	k5 -= mn
	k6 -= mn
	mn = min(k2, k3)
	summ += 32 * mn
	return summ
(k2, k3, k5, k6) = map(int, input().split())
print(solve(k2, k3, k5, k6))


arr = list(map(int, input().split()))
bigs = min((arr[i] for i in [0, 2, 3]))
smalls = min(arr[0] - bigs, arr[1])
print(bigs * 256 + smalls * 32)


k = list(map(int, input().split()))
k256 = min(k[0], k[2], k[3])
k32 = min(k[0] - k256, k[1])
print(k32 * 32 + k256 * 256)


a = input()
a = a.split()
d2 = int(a[0])
d3 = int(a[1])
d5 = int(a[2])
d6 = int(a[3])
s = 0
u = min(d2, d5, d6)
s += u * 256
r = min(d2 - u, d3)
s += r * 32
print(s)


(k1, k2, k3, k4) = [int(x) for x in input().split()]
res = 0
mink = min(min(k1, k3), k4)
res += 256 * mink
k1 -= mink
k3 -= mink
k4 -= mink
mink = min(k1, k2)
res += 32 * mink
print(res)


x = [int(j) for j in input().split()]
count256 = 0
count32 = 0
count256 = min([x[0], x[2], x[3]])
x[0] -= count256
if x[0] > 0:
	count32 = min(x[0], x[1])
print(count32 * 32 + count256 * 256)


import math
(k2, k3, k6, k5) = map(int, input().split())
len256 = min(k2, k5, k6)
len32 = min((abs(k2 - min(k2, k5, k6)), k3))
print(len256 * 256 + len32 * 32)


mnop = input().split()
m = int(mnop[0])
n = int(mnop[1])
o = int(mnop[2])
p = int(mnop[3])
z = min(m, o, p)
c = 256 * z
m -= z
z = min(m, n)
c += 32 * z
print(c)


(k2, k3, k5, k6) = [int(x) for x in input().split()]
q256 = min(k2, k5, k6)
k2 -= q256
k5 -= q256
k6 -= q256
q32 = min(k2, k3)
print(256 * q256 + 32 * q32)


import sys
nums = sys.stdin.readline()
nums = nums.strip().replace('\n', '').split(' ')
for i in range(0, len(nums)):
	nums[i] = int(nums[i])
total = 0
minimum = nums[0]
if nums[2] < minimum:
	minimum = nums[2]
if nums[3] < minimum:
	minimum = nums[3]
total += minimum * 256
nums[0] -= minimum
nums[2] -= minimum
nums[3] -= minimum
minimum = nums[0]
if nums[1] < minimum:
	minimum = nums[1]
nums[0] -= minimum
nums[1] -= minimum
total += 32 * minimum
print(total)


(k2, k3, k5, k6) = map(int, input().split())
max256 = min(k2, k5, k6)
max32 = min(k2 - max256, k3)
print(int(max256 * 256 + max32 * 32))


(k2, k3, k5, k6) = map(int, input().split())
tfx = min(k2, k5, k6)
k2 -= tfx
k5 -= tfx
k6 -= tfx
tt = min(k3, k2)
print(tfx * 256 + tt * 32)


a = list(map(int, input().split()))
z = min(a[0], min(a[2], a[3]))
sum1 = 0
sum1 = 256 * z
for _ in range(len(a)):
	if _ != 1:
		a[_] = a[_] - z
z = min(a[0], a[1])
sum2 = z * 32
print(sum1 + sum2)


(k2, k3, k5, k6) = map(int, input().split())
s = min(k2, k5, k6)
y = min(k2 - s, k3)
f = 256 * s + y * 32
print(f)


numbers = list(map(int, input().split()))
total = 0
max256 = 3
if numbers[2] < numbers[3]:
	max256 = 2
if numbers[0] < numbers[max256]:
	max256 = 0
	total = 256 * numbers[0]
	numbers[0] = 0
else:
	total = 256 * numbers[max256]
	numbers[0] = numbers[0] - numbers[max256]
max32 = 0
if numbers[1] < numbers[0]:
	max32 = 1
total = total + max(numbers[max32] * 32, 0)
print(total)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def I():
	return int(sys.stdin.readline())

def LS():
	return sys.stdin.readline().split()

def S():
	return input()

def main():
	(a, b, c, d) = LI()
	x = min(a, c, d)
	return x * 256 + min(a - x, b) * 32
print(main())


total = 0

def finder(a, b, c, d):
	total = 0
	f = min(a, c, d)
	m = max(a, c, d)
	if a == b == c == d:
		total = 256 * a
		return total
	if a == c == d:
		total = 256 * a
		return total
	if f != 0:
		if a > 0 and c > 0 and (d > 0):
			total = 256 * f
			if a == f:
				a = 0
				return total
			elif c == f:
				a = a - c
			elif d == f:
				a = a - d
	if b > 0 and a > 0:
		f = min(a, b)
		total = total + 32 * f
		if b == f:
			b = b - f
		if a == f:
			return total
		while a and b:
			total = total + 32
			a = a - 1
			b -= 1
	return total
(a, b, c, d) = map(int, input().split())
print(finder(a, b, c, d))


(a, b, c, d) = [int(x) for x in input().split()]
z = min(a, c, d)
count = 256 * z
a = a - z
d = d - z
c = c - z
y = min(a, b)
count2 = y * 32
print(count + count2)


digit = input().split()
d = [int(i) for i in digit]
_256 = min(d[0], d[2], d[3])
_32 = min(d[0] - _256, d[1])
print(256 * _256 + 32 * _32)


l = str(input()).split(' ')
l = list(map(int, l))
m1 = min(l[0], l[2], l[3])
a = l[0] - m1
m2 = min(l[1], a)
print(m1 * 256 + m2 * 32)


(a, b, c, d) = map(int, input().split())
amin = min(a, c, d)
asum = 256 * amin
a = a - amin
aamin = min(a, b)
if aamin < 0:
	aamin = 0
else:
	aamin = aamin
asum = asum + aamin * 32
print(asum)


arr = input().split(' ')
arr = [int(x) for x in arr]
two_hun = min(arr[0], arr[2], arr[3])
thirty = min(arr[0] - two_hun, arr[1])
print(two_hun * 256 + thirty * 32)


x = list(map(int, input().split()))
k2 = int(x[0])
k3 = int(x[1])
k5 = int(x[2])
k6 = int(x[3])
s = 0
if k2 == 0:
	print(0)
else:
	if k2 >= k5 and k2 >= k6:
		if k5 > k6:
			s += 256 * k6
			k2 -= k6
			if k2 > k3:
				s += k3 * 32
			else:
				s += k2 * 32
		else:
			s += 256 * k5
			k2 -= k5
			if k2 > k3:
				s += k3 * 32
			else:
				s += k2 * 32
	elif k2 < k5 and k2 < k6:
		s += 256 * k2
	elif k2 >= k5 and k2 <= k6:
		s += k5 * 256
		k2 -= k5
		if k2 > k3:
			s += k3 * 32
		else:
			s += k2 * 32
	elif k2 >= k6 and k2 <= k5:
		s += k6 * 256
		k2 -= k6
		if k2 > k3:
			s += k3 * 32
		else:
			s += k2 * 32
	print(s)


n = input()
n = n.split(' ')
a = min(int(n[0]), int(n[2]), int(n[3]))
total = a * 256
b = min(int(n[0]) - a, int(n[1]))
total += b * 32
print(total)


(k2, k3, k5, k6) = [int(i) for i in input().split()]
k256 = min(k2, k5, k6)
k32 = min(k3, k2 - k256)
k256_sum = k256 * 256
k32_sum = k32 * 32 if k32 > 0 else 0
print(k256_sum + k32_sum)


def hii(l):
	l2 = [l[0], l[2], l[3]]
	l2.sort()
	count1 = l2[0] * 256
	b = min(l[1], l[0] - l2[0])
	count2 = b * 32
	return count1 + count2
l = list(map(int, input().split()))
print(hii(l))


x = list(map(int, input().split()))
a = 0
c = 0
d = 0
b = x[1]
if x[0] <= x[2] and x[0] <= x[3]:
	a = x[0]
elif x[2] <= x[0] and x[2] <= x[3]:
	a = x[2]
elif x[3] <= x[2] and x[3] <= x[0]:
	a = x[3]
if x[0] - a > 0 and x[1] >= x[0] - a:
	c = x[0] - a
elif x[0] - a > 0 and x[1] < x[0] - a:
	c = x[1]
if b >= c and b >= 0 and (c >= 0):
	d = a * 256 + c * 32
elif b <= c and b >= 0 and (c >= 0):
	d = a * 256 + b * 32
print(d)


a = list(map(int, input().split()))
two = a[0]
three = a[1]
five = a[2]
six = a[3]
x = min(two, five, six)
two -= x
y = min(two, three)
print(x * 256 + y * 32)


(d, t, c, s) = map(int, input().split())
mini = min(d, c, s)
print(256 * mini + 32 * min(d - mini, t))


digits = input()
digits = [int(i) for i in digits.split(' ')]
n256 = min(digits[0], digits[2], digits[3])
digits[0] -= n256
digits[2] -= n256
digits[3] -= n256
n32 = min(digits[0], digits[1])
print(n32 * 32 + n256 * 256)


t = input()
A = []
r = 0
for x in t.split():
	A.append(int(x))
b = min(A[0], A[2], A[3])
r = r + 256 * b
c = min(A[0] - b, A[1])
r = r + 32 * c
print(r)


import sys
import math
files = False
if files:
	sys.stdout = open('slalom.out', mode='w')
	sys.stdin = open('slalom.in')
(k2, k3, k5, k6) = [int(i) for i in input().split()]
suma = min(k5, k6, k2) * 256
k2 -= min(k5, k6, k2)
suma += min(k3, k2) * 32
print(suma)
sys.stdout.close()


(a, b, c, d) = map(int, input().rstrip().split())
count1 = min(a, c, d)
a -= count1
count2 = min(a, b)
print(count1 * 256 + count2 * 32)


(Two, Three, Five, Six) = map(int, input().split())
Sum = 0
mylist = [Two, Five, Six]
minn = min(mylist)
if Two > 0 and Five > 0 and (Six > 0):
	Sum = 256 * minn
mylist2 = [Two - minn, Three]
if mylist2[0] > 0 and mylist2[1] > 0:
	Sum = Sum + min(mylist2) * 32
print(Sum)


(k2, k3, k5, k6) = map(int, input().split())
count = 0
c = 0
b = min(k2, k5, k6)
count += b * 256
if b != k2:
	c = k2 - b
if c > 0:
	d = min(c, k3)
	count += d * 32
print(count)


input = input().split()
(i2, i3, i5, i6) = map(int, input)
num_256 = min(min(i2, i5), i6)
i2 -= num_256
i5 -= num_256
i6 -= num_256
num_32 = min(i2, i3)
print(256 * num_256 + 32 * num_32)


(k2, k3, k5, k6) = list(map(int, input().split()))
b1 = min(k2, k5, k6)
b2 = min(k2 - b1, k3)
print((b1 << 8) + (b2 << 5))


def anton_and_digits():
	data = [int(x) for x in input().strip().split(' ')]
	no_256 = min(data[0], data[2], data[3])
	no_32 = min(data[0] - no_256, data[1])
	return 32 * no_32 + 256 * no_256
print(anton_and_digits())


(a, b, c, d) = [int(i) for i in input().split()]
m = min(a, c, d)
res = 256 * m
a -= m
c -= m
d -= m
M = min(a, b)
res += 32 * M
print(res)


(a, b, c, d) = map(int, input().split())
t = min(a, c, d)
A = 256 * t
a = a - t
m = min(a, b)
B = 32 * m
T = A + B
print(T)


(s2, s3, s5, s6) = map(int, input().split())
s256 = min([s2, s5, s6])
s2 -= s256
s32 = min(s2, s3)
print(256 * s256 + 32 * s32)


nums = list(map(int, input().split(' ')))
sum1 = 0
secmini = min(nums[0], nums[2])
if secmini < nums[3]:
	sum1 = 256 * secmini
	nums[0] = nums[0] - secmini
else:
	sum1 = 256 * nums[3]
	nums[0] = nums[0] - nums[3]
sum1 = sum1 + 32 * min(nums[0], nums[1])
print(sum1)


lst = list(map(int, input().split()))
twos = lst[0]
threes = lst[1]
fives = lst[2]
sixes = lst[3]
min = sixes
if min > fives:
	min = fives
if min > twos:
	min = twos
count256 = 256 * min
twos -= min
min = twos
if min > threes:
	min = threes
count32 = min * 32
print(count32 + count256)


[k2, k3, k5, k6] = list(map(int, input().split()))
w256 = min(k2, k6, k5)
k2 -= w256
k6 -= w256
k5 -= w256
w32 = min(k2, k3)
print(256 * w256 + w32 * 32)


(n2, n3, n5, n6) = [int(i) for i in input().strip().split()]
x = min(n2, n5, n6)
n2 -= x
n5 -= x
n6 -= x
y = min(n2, n3)
print(256 * x + 32 * y)


a = list(map(int, input().split()))
sum = 0
minimum = min(a[2], a[3])
if a[0] <= minimum:
	sum += a[0] * 256
else:
	a[0] = a[0] - minimum
	sum += 256 * minimum + min(a[0], a[1]) * 32
print(sum)


(k2, k3, k5, k6) = map(int, input().split())
(d, ans) = (dict(), 0)
d[2] = k2
d[3] = k3
d[5] = k5
d[6] = k6
v = min(d[2], d[5], d[6])
ans = 256 * v
d[2] -= v
if d[2] >= 1:
	ans += 32 * min(d[2], d[3])
print(ans)


(k2, k3, k5, k6) = map(int, input().split())
tmp256 = min(k2, k5, k6)
k2 -= tmp256
tmp32 = min(k2, k3)
print(tmp256 * 256 + tmp32 * 32)


(a2, a3, a5, a6) = map(int, input().split())
no_256 = min(a2, a5, a6)
a2 -= no_256
no_32 = min(a2, a3)
print(256 * no_256 + 32 * no_32)


(k2, k3, k5, k6) = map(int, input().split())
v256 = min(k2, min(k5, k6))
s = 256 * v256
k2 -= v256
k5 -= v256
k6 -= v256
v32 = min(k2, k3)
s += 32 * v32
print(s)


(k2, k3, k4, k5) = str(input()).split()
most32 = int(k3)
most256 = min(int(k4), int(k5))
ceil = int(k2)
if most256 > ceil:
	print(256 * ceil)
else:
	print(256 * most256 + 32 * min(most32, ceil - most256))


(k2, k3, k5, k6) = map(int, input().split())
n = k2 + k3 + k5 + k6
s = 0
for i in range(n):
	if k2 != 0 and k5 != 0 and (k6 != 0):
		s += 256
		k2 -= 1
		k5 -= 1
		k6 -= 1
	elif k2 != 0 and k3 != 0:
		s += 32
		k2 -= 1
		k3 -= 1
print(s)


cnt = list(map(int, input().split()))
n256 = min(cnt[0], cnt[2], cnt[3])
n32 = min(cnt[1], cnt[0] - n256)
print(256 * n256 + 32 * n32)


(k2, k3, k5, k6) = map(int, input().split(' '))
min256 = min(k2, k5, k6)
(k2, k5, k6) = (k2 - min256, k5 - min256, k6 - min256)
min32 = min(k2, k3)
output = min256 * 256 + min32 * 32
print(output)


numbers = input('')
(n_2, n_3, n_5, n_6) = numbers.split(' ')
(n_2, n_3, n_5, n_6) = (int(n_2), int(n_3), int(n_5), int(n_6))
n = n_2 + n_3 + n_5 + n_6
s_256 = '256'
n_256 = min([n_2, n_5, n_6])
n_2 = n_2 - n_256
n_5 = n_6 - n_256
n_6 = n_6 - n_256
n_32 = min([n_3, n_2])
print(str(n_256 * 256 + n_32 * 32))


c = list(map(int, input().split()))
s = 256 * min(c[0], c[2], c[3])
c[0] -= min(c[0], c[2], c[3])
s += 32 * min(c[0], c[1])
print(s)


(k2, k3, k5, k6) = map(int, input().split())
tot = 0
m_256 = min(k2, k5, k6)
tot += 256 * m_256
k2 -= m_256
k5 -= m_256
k6 -= m_256
m_32 = min(k2, k3)
tot += 32 * m_32
print(tot)


(twos, threes, fives, sixes) = map(int, input().split())
n256 = min(twos, fives, sixes)
n32 = min(threes, twos - n256)
ans = 0
if n256 >= 0:
	ans += n256 * 256
if n32 >= 0:
	ans += 32 * n32
print(ans)


(a, b, c, d) = map(int, input().split())
count = 0
counter = 0
m = min(a, min(c, d))
n = min(a - m, b)
count = n * 32
counter = m * 256
print(count + counter)


(k2, k3, k5, k6) = [int(i) for i in input().split()]
res = 0
x1 = min(k2, k5, k6)
res += 256 * x1
k2 -= x1
k5 -= x1
k6 -= x1
x1 = min(k2, k3)
res += 32 * x1
print(res)


def solve(k2, k3, k5, k6):
	mini = min(k2, k5, k6)
	k2 -= mini
	k5 -= mini
	k6 -= mini
	ans = mini * 256
	ans += min(k2, k3) * 32
	return ans
(k2, k3, k5, k6) = map(int, input().split())
print(solve(k2, k3, k5, k6))


(p, q, r, s) = map(int, input().split())
z = min(p, r, s)
x = 256 * z
p = p - z
y = min(p, q)
h = 32 * y
x = x + h
print(x)


import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *

class Scanner:

	@staticmethod
	def int():
		return int(sys.stdin.readline().rstrip())

	@staticmethod
	def string():
		return sys.stdin.readline().rstrip()

	@staticmethod
	def map_int():
		return [int(x) for x in Scanner.string().split()]

	@staticmethod
	def string_list(n):
		return [Scanner.string() for i in range(n)]

	@staticmethod
	def int_list_list(n):
		return [Scanner.map_int() for i in range(n)]

	@staticmethod
	def int_cols_list(n):
		return [Scanner.int() for i in range(n)]

class Math:

	@staticmethod
	def gcd(a, b):
		if b == 0:
			return a
		return Math.gcd(b, a % b)

	@staticmethod
	def lcm(a, b):
		return a * b // Math.gcd(a, b)

	@staticmethod
	def divisor(n):
		res = []
		i = 1
		for i in range(1, int(n ** 0.5) + 1):
			if n % i == 0:
				res.append(i)
				if i != n // i:
					res.append(n // i)
		return res

	@staticmethod
	def round_up(a, b):
		return -(-a // b)

	@staticmethod
	def is_prime(n):
		if n < 2:
			return False
		if n == 2:
			return True
		if n % 2 == 0:
			return False
		d = int(n ** 0.5) + 1
		for i in range(3, d + 1, 2):
			if n % i == 0:
				return False
		return True

def pop_count(x):
	x = x - (x >> 1 & 6148914691236517205)
	x = (x & 3689348814741910323) + (x >> 2 & 3689348814741910323)
	x = x + (x >> 4) & 1085102592571150095
	x = x + (x >> 8)
	x = x + (x >> 16)
	x = x + (x >> 32)
	return x & 127
MOD = int(1000000000.0) + 7
INF = int(1000000000000000.0)

def solve():
	(a, b, c, d) = Scanner.map_int()
	t = min(a, c, d)
	a -= t
	s = min(a, b)
	print(t * 256 + s * 32)

def main():
	solve()
main()


(k2, k3, k5, k6) = input().split()
k2 = int(k2)
k3 = int(k3)
k5 = int(k5)
k6 = int(k6)
ans = 0
k_256 = min(k2, k5, k6)
ans += k_256 * 256
k2 -= k_256
k5 -= k_256
k6 -= k_256
k_32 = min(k2, k3)
ans += k_32 * 32
k2 -= k_32
k3 -= k_32
print(ans)


import math
import os
import random
import re
import sys
a = list(map(int, input().rstrip().split()))
b = a[0]
x = [a[0], a[2], a[3]]
x.sort()
p = x[0]
b = b - p
y = [b, a[1]]
q = 0
if b <= 0:
	q = 0
else:
	y.sort()
	q = y[0]
s = 256 * p + 32 * q
print(s)


a = [int(i) for i in input().split()]
s = 0
g = [a[0], a[2], a[3]]
g.sort()
f = g[0]
s = f * 256
a[0] -= f
x = [a[0], a[1]]
x.sort()
l = x[0]
s += 32 * l
print(s)


l = list(map(int, input().strip().split()[:4]))
k2 = l[0]
k3 = l[1]
k5 = l[2]
k6 = l[3]
z = min(k2, k5, k6)
l = min(k2 - z, k3)
print(z * 256 + l * 32)


q = lambda : map(int, input().split())
qi = lambda : int(input())
qs = lambda : input().split()
(a, b, c, d) = q()
print(min([a, c, d]) * 256 + min([a - min([a, c, d]), b]) * 32)


(k2, k3, k5, k6) = map(int, input().split())
no_256 = min(k2, k5, k6)
no_32 = max(0, min(k2 - no_256, k3))
print(256 * no_256 + 32 * no_32)


k = list(map(int, input().split()))
m = min(k[0], k[2], k[3])
v = 256 * m
k[0] -= m
k[2] -= m
k[3] -= m
if k[0] > 0 and k[1] > 0:
	n = min(k[0], k[1])
	v += 32 * n
print(v)


arr = list(map(int, input().split()))
min6 = min(arr[0], arr[2], arr[3])
min2 = min(arr[0] - min6, arr[1])
print(min6 * 256 + min2 * 32)


temp = input().split()
k2 = int(temp[0])
k3 = int(temp[1])
k5 = int(temp[2])
k6 = int(temp[3])
m = min(k2, k5, k6)
n = min(k3, k2 - m)
print(256 * m + 32 * n)


(k2, k3, k5, k6) = [int(k) for k in input().split(' ')]
smallest = sorted([k2, k5, k6])[0]
summary = smallest * 256
s32 = k2 - smallest
if s32 > 0:
	summary += 32 * sorted([s32, k3])[0]
print(summary)


lis = input().split()
num = [int(i) for i in lis]
if num[0] <= num[2] and num[0] <= num[3]:
	int256 = num[0]
elif num[2] <= num[3]:
	int256 = num[2]
else:
	int256 = num[3]
num[0] -= int256
num[2] -= int256
num[3] -= int256
if num[0] <= num[1]:
	int32 = num[0]
else:
	int32 = num[1]
x = 256 * int256 + 32 * int32
print(x)


(k2, k3, k5, k6) = map(int, input().split())
m_x = min(k2, k5, k6)
m_y = min(k2, k3)
s1 = m_x * 256 + min(k2 - m_x, k3) * 32
s2 = m_y * 32 + min(k2 - m_y, k5, k6) * 256
print(max(s1, s2))


s = [int(i) for i in input().split()]
c = 0
if s[0] and s[2] and (s[3] != 0):
	c += 256 * min(min(s[0], s[2]), min(s[2], s[3]))
	s[0] -= min(min(s[0], s[2]), min(s[2], s[3]))
if s[1] and s[0] != 0:
	c += 32 * min(s[0], s[1])
print(c)


(k2, k3, k5, k6) = [int(x) for x in input().split()]
c256 = min(k2, k5, k6)
c32 = min(k3, k2 - c256)
print(c32 * 32 + c256 * 256)


(k2, k3, k5, k6) = (int(x) for x in input().split())
sum = 0
k56 = min(k5, k6)
k256 = min(k2, k56)
k2 -= k256
k32 = min(k3, k2)
sum = k256 * 256 + k32 * 32
print(sum)


(k2, k3, k5, k6) = [int(x) for x in input().split()]
num1 = min(k2, k5, k6)
num2 = min(k2 - num1, k3)
print(num1 * 256 + num2 * 32)


a = input().split()
two = int(a[0])
three = int(a[1])
five = int(a[2])
six = int(a[3])
small = 0
if two <= five and two <= six:
	small = two
elif five <= two and five <= six:
	small = five
elif six <= two and six <= five:
	small = six
sum1 = 256 * small
if three >= two - small:
	two = two - small
	sum1 += two * 32
else:
	sum1 += three * 32
print(sum1)


import sys
data = sys.stdin.readlines()
filtered_data = data[0].split()
d = []
for item in filtered_data:
	d += [int(item)]
num2 = d[0]
num3 = d[1]
num5 = d[2]
num6 = d[3]
num256 = min([num2, num5, num6])
if num3 > num2 - num256:
	num32 = num2 - num256
else:
	num32 = num3
print(num256 * 256 + num32 * 32)


(two, three, five, six) = [int(t) for t in input().split(' ')]
sumt = 0
a = min(two, five, six)
two -= a
b = min(three, two)
sumt = 256 * a + 32 * b
print(sumt)


(k2, k3, k5, k6) = map(int, input().split())
m = min(k2, k5, k6)
s = m * 256
(k2, k5, k6) = (k2 - m, k5 - m, k6 - m)
m1 = min(k2, k3)
s += m1 * 32
print(s)


t = list(map(int, input().split(' ')))
k2 = t[0]
k3 = t[1]
k5 = t[2]
k6 = t[3]
t = min(k2, k5, k6)
s = t * 256
k2 = k2 - t
if k2 > 0:
	s = s + 32 * min(k2, k3)
print(s)


(k2, k3, k5, k6) = list(map(int, input().split()))
n256 = min(k2, k5, k6)
sum = n256 * 256
nk2 = k2 - n256
if nk2 > 0 and k3 > 0:
	sum += min(nk2, k3) * 32
print(sum)


a = list(map(int, input().split()))
ans = min(a[0], a[2], a[3]) * 256
a[0] = max(0, a[0] - min(a[0], a[2], a[3]))
ans += min(a[0], a[1]) * 32
print(ans)


k = [int(x) for x in input().split()]
count1 = 0
count2 = 0
count1 = min(k[0], k[2], k[3])
k[0] -= count1
k[2] -= count1
k[3] -= count1
count2 = min(k[0], k[1])
print(count1 * 256 + count2 * 32)


a = [int(x) for x in input().split()]
b = min(a[0], a[2], a[3])
num = 256 * b
a[0] -= b
a[2] -= b
a[3] -= b
c = min(a[0], a[1])
num += 32 * c
print(num)


(a, b, c, d) = list(map(int, input().split()))
total_twofiftysix = min(a, c, d)
total_thirtytwo = min(a - min(a, c, d), b)
print(256 * total_twofiftysix + 32 * total_thirtytwo)


s = [int(x) for x in input().strip().split()]
k2 = s[0]
k3 = s[1]
k5 = s[2]
k6 = s[3]
c256 = min(k2, k5, k6)
k2 = k2 - c256
c32 = min(k3, k2)
print(256 * c256 + 32 * c32)


(a, b, c, d) = map(int, input().split())
s = 0
t = min(a, c, d)
s = 256 * t
a = a - t
y = min(a, b)
s = s + 32 * y
print(s)


k = [int(x) for x in input().split()]
m = min(k[0], k[2], k[3])
res = m * 256
k[0] -= m
m2 = min(k[0], k[1])
res += m2 * 32
print(res)


(k_2, k_3, k_5, k_6) = (int(x) for x in input().split())
used_2 = min(k_2, k_5, k_6)
print(256 * used_2 + 32 * min(k_2 - used_2, k_3))


cnt = list(map(int, input().split()))
mini = min(cnt[0], min(cnt[2], cnt[3]))
ans = mini * 256
(cnt[0], cnt[2], cnt[3]) = (cnt[0] - mini, cnt[2] - mini, cnt[3] - mini)
mini = min(cnt[0], cnt[1])
ans += mini * 32
print(ans)


inputString = input().split(' ')
k_2 = int(inputString[0])
k_3 = int(inputString[1])
k_5 = int(inputString[2])
k_6 = int(inputString[3])
min_256 = int(min(k_2, k_5, k_6))
output_256 = 256 * min_256
lost_2 = k_2 - min_256
if lost_2 > 0:
	min_32 = int(min(lost_2, k_3))
	output_32 = min_32 * 32
	print(output_256 + output_32)
else:
	print(output_256)


string = input().split()
num = list()
for i in string:
	num.append(int(i))
sum = 0
while num[0] > 0 and num[2] > 0 and (num[3] > 0):
	sum += 256
	num[0] -= 1
	num[2] -= 1
	num[3] -= 1
while num[0] > 0 and num[1] > 0:
	sum += 32
	num[0] -= 1
	num[1] -= 1
print(sum)


s = list(map(int, input().split()))
num_256 = min(s[0], s[2], s[3])
s[0] -= num_256
s[2] -= num_256
s[3] -= num_256
num_32 = min(s[0], s[1])
print(num_256 * 256 + num_32 * 32)


(twos, threes, fives, sixes) = input().split()
twos = int(twos)
threes = int(threes)
fives = int(fives)
sixes = int(sixes)
result = 0
mini = min(twos, fives, sixes)
result += mini * 256
twos -= mini
mini = min(twos, threes)
result += mini * 32
print(result)


l = list(map(int, input().split()))
sum1 = 0
mini1 = min(l[0], l[2], l[3])
sum1 = 256 * mini1
l[0] -= mini1
l[2] -= mini1
l[3] -= mini1
mini2 = min(l[1], l[0])
sum1 += 32 * mini2
print(sum1)


(a, b, c, d) = [int(i) for i in input().split()]
tot = 0
while a != 0 and c != 0 and (d != 0):
	tot += 256
	a -= 1
	c -= 1
	d -= 1
while a != 0 and b != 0:
	tot += 32
	a -= 1
	b -= 1
print(tot)


import sys

def minl(a, b):
	if a < b:
		return a
	return b
(k2, k3, k5, k6) = map(int, sys.stdin.readline().split())
mink56 = minl(k5, k6)
mink2 = min(mink56, k2)
print(mink2 * 256 + 32 * min(k2 - mink2, k3))


def answer():
	a = input().split()
	a = [int(x) for x in a]
	two = min(a[0], a[2], a[3])
	thir = min(a[0] - two, a[1])
	if thir < 0:
		thir = 0
	return two * 256 + thir * 32
print(answer())


def Anton():
	nums = [*map(int, input().split())]
	n_256 = min((nums[0], nums[2], nums[3]))
	ttl = n_256 * 256
	nums[0] -= n_256
	nums[2] -= n_256
	nums[3] -= n_256
	n_32 = min(nums[:2])
	ttl += n_32 * 32
	print(ttl)
Anton()


from sys import stdin

def main():
	(k2, k3, k5, k6) = stdin_get_ints_from_line()
	max_256 = min(k2, k5, k6)
	k2 -= max_256
	k5 -= max_256
	k6 -= max_256
	max_32 = min(k2, k3)
	res = max_256 * 256 + max_32 * 32
	print(res)
	return

def stdin_get_ints_from_line():
	return (int(x) for x in stdin.readline().strip().split(' '))

def stdin_get_ints_list_from_line():
	return list((int(x) for x in stdin.readline().strip().split(' ')))

def stdin_get_string_from_line():
	return stdin.readline().strip()
main()


(a2, a3, a5, a6) = map(int, input().split())
amt = 0
amt = min(a2, a5, a6) * 256
if a2 - min(a2, a5, a6) >= 0:
	if a2 - min(a2, a5, a6) >= a3:
		amt += 32 * a3
	elif a2 - min(a2, a5, a6) < a3:
		amt += 32 * (a2 - min(a2, a5, a6))
print(amt)


(k2, k3, k5, k6) = [int(x) for x in input().split()]
t = k2
s = 256 * min(k2, k5, k6)
t -= s // 256
s += 32 * min(t, k3)
print(s)


L = list(map(int, input().split()))
m1 = min(L[0], L[2], L[3])
L[0] -= m1
m2 = min(L[0], L[1])
print(m1 * 256 + m2 * 32)


l = list(map(int, input().split()))[:4]
g = l[1]
l.remove(g)
k = min(l)
j = l[0] - k
if j >= g:
	sum = g * 32 + k * 256
	print(sum)
else:
	sum = j * 32 + k * 256
	print(sum)


(d1, d2, d3, d4) = map(int, input().split())
a = [d1, d3, d4]
a.sort()
sum = 0
sum = sum + a[0] * 256
b = d1 - a[0]
if d2 < b:
	sum = sum + d2 * 32
else:
	sum = sum + b * 32
print(sum)


(two, three, five, six) = [int(i) for i in input().split()]
res = 0
low = min(two, five, six)
res += 256 * low
two -= low
five -= low
six -= low
low = min(two, three)
res += 32 * low
print(str(res))


k = list(map(int, input().split()))
s = 0
m256 = min([k[0], k[2], k[3]])
s += 256 * m256
k[0] -= m256
m32 = min([k[0], k[1]])
s += 32 * m32
print(s)


(k2, k3, k5, k6) = map(int, input().split())
c = min(k2, min(k5, k6))
r = c * 256
k2 = abs(c - k2)
p = min(k2, k3) * 32
print(p + r)