#!/usr/bin/env python3
x, y = map(int, input().split())

y = y // 2
ninetysixs = y // 16
fours = x // 2
count = min(fours, ninetysixs)
y -= count * 16
x -= count * 2

if y < 16:
    rest = 100 - (y * 6)
    if 2 * x >= rest:
        y = 0
        x -= rest // 2
        count += 1

count += x // 50

print(count)
