# Arup Guha
# 11/16/2024
# Solution to 2024 SER D1/D2 Problem: Herb Mixing

toks = input().split()
g = int(toks[0])
r = int(toks[1])

# More green.
if r < g:

    # Pair these up.
    g -= r

    # What we get without last 0,1,2 green.
    res =10*r + (g//3)*10

    # Take care of leftover.
    if g%3 == 1:
        res += 1
    elif g%3 == 2:
        res += 3

    # Ta da!
    print(res)

# Best we can do is all pairs.
else:
    print(10*g)
