eolymp
bolt
Try our new interface for solving problems
Problems

Stepan's heritage

Stepan's heritage

Stepan inherited from his grandfather a parking lot on n places, numbered from 1 to n. The parking lot is divided into two parts. The first m places are on the left side, while the other n - m places are on the right. Every day n residents of this area park their cars in the Stepan parking lot. It is known that the first resident comes first, then the second, and so on, that is, k - th comes k - th. Also, for every i resident, it is known how much he will pay if his car is put on the j-th place. Stepan purchased a distributor of seats, that for each coming car shows which side to park, after which the car is parked on the free space with minimum number on the corresponding side. At the same time, Stepan decided to save money and did not purchase the software for the distributor, so it does not work optimally.

Stepan asks you to write a program for this distributor, that maximizes Stepan's profit.

Input

First line contains two integers n (2n1000) and m (1m < n) - the total number of parking places and the number of places on the left side, respectively. Each of the next n lines contains n positive integers. j-th number at i-th line means how much the i-th resident will pay for the place with number j at this parking. Each number does not exceed 106.

Output

Print one number - the maximum profit of the parking lot.

Time limit 1 second
Memory limit 128 MiB
Input example #1
2 1
3 2
6 4
Output example #1
8
Input example #2
4 1
4 3 1 1
3 1 1 1
1 1 4 1
1 1 1 2
Output example #2
12
Source 2012 - 2013 III этап Всеукраинской олимпиады школьников, 1 тур