High School Programming League 2008/2009

Broken Soroban

Problem code: HS08SBAN

Another Leo's task for Johnny concerned with the Japanese abacus called Soroban.

"Here is a Japanese abacus which you can use for calculations in the decimal system. Successive digits in the decimal system are represented by successive columns of the abacus, starting from the right. In the upper row one bead has a value of 5, in each of the lower rows - a value of 1. You have some number of beads and your task is to allocate them between lower rows (max. four beads in one column) in order to maximize the number of values that can be represented on the abacus. You may assume, that there are all beads in the upper row."

Help Johnny find a solution to his problem!

Input

Every data set consists of two positive integers r s given in one row, where 1 <= r <= 8 represents the number of columns in abacus and 0 <= s <= 4 * r is the number of beads that Johnny has to distribute between columns in the lower rows.

Output

Write to output the maximum number of correct values that can be represented on such broken Soroban.

Example 1

Input:
2 1

Output:
8

Example 2

Input:
2 3

Output:
24

Scoring

For every test data you can get 2 points, summing to a total of 10 points.


Added by:Michał Małafiejski
Date:2008-10-23
Time limit:1s
Source limit:50000B
Languages:SED C99 strict C++ 4.3.2 TCL SCALA NEM PHP SCM guile LISP sbcl LISP clisp ERL TECS TEXT DOC PDF PS PERL 6 JS
Resource:High School Programming League 2008/2009
SPOJ System © 2008-2009 Sphere Research Labs. All Rights Reserved.