Max Matrix Sum

EasyProblem #3
Time LimitMemoryInputOutput
1 s64 MBstdinstdout

A great first DP problem. Think about the only two ways a path can enter a field.

In an table, the fields are filled with the digits 0 to 9. A player starts in the top left corner of the table, and in one step can move to the adjacent right field or the adjacent lower field. His goal is to reach the bottom right corner in a way that maximizes the sum of values he passes through. Write a program that determines the maximum sum a player can achieve when moving from the top left to the bottom right corner.

Input

First line of input will be two numbers: and , the dimensions of the table.
In the next lines will be digits, the values of the fields.

Output

A single number - the maximum possible sum of the visited fields.

Example

Input
3 3
1 2 3
4 5 6
7 8 9
Output
29

The best path is .

Constraints


Submit your solution