According to top-secret mars sensor transition, a big oil field was founded on the Mars. The field is divided into N*M equal square, and each square contains some oil resources. Our army want to occupy all the territory of the field, but the UN (United Nations) will allow us to occupy only K squares. Of course, we want to get control over as many oil as possible, but, we will have to guard all our territory. So, they need our territory to be easy-controlled, i.e. from any square to any it must be possible to get moving only along two directions (selected from the next list: left, right, up, down; for different squares pairs of directions may differ).
You are to write a program, which determines, how many oil will be occupied by us.