cho.sh
NotesCho Mini
Loading...

Colored Paper

Time limit

1s

Memory limit

128 MB

Problem

There are six kinds of square colored paper whose side lengths are 1cm, 2cm, 3cm, 4cm, 5cm, and 6cm. A sheet of type k has side length kcm.

Figure 1

All sheets must be attached to boards that are 6cm wide and 6cm tall. A sheet must not cross the boundary of a board, and two sheets must not overlap. Each sheet must fit completely inside a single board.

Figure 2

Given the number of sheets of each size, find the minimum number of 6cm × 6cm boards needed to attach all of them.

Input

Six lines are given. From the first line to the sixth line, they contain the numbers of type 1 through type 6 colored papers in order. Each count is at most 100.

Output

Print the minimum number of boards needed to attach all the colored papers.