import java.io.*;
import java.util.Scanner;

class PA2sol {
    public static void main(String[] args) {
	Scanner inscanner = new Scanner(System.in);
	int n, m;
	//A[i][j] is the number at square (i, j). C arrays are 0 based hence the extra size.
	n = inscanner.nextInt();
	m = inscanner.nextInt();
	int A[][] = new int[n+1][m+1];
	for(int i=1;i<=n;i++)
	    for(int j=1;j<=m;j++)
		A[i][j] = inscanner.nextInt();

	//D[i][j] is the maximum sum of numbers a grumkin can collect going from (1, 1) to (i, j)
	int D[][] = new int[n+1][m+1];

	//First row is special (base case)
	D[1][1] = A[1][1];
	for(int j=2;j<=m;j++){
	    D[1][j] = D[1][j-1] + A[1][j];
	    for(int l=1;l<j;l++)
		if((j % l)==0) //If l | j
		    D[1][j] = max(D[1][j], D[1][l] + A[1][j]);
	}
	//Recursion:
	for(int i=2;i<=n;i++){
	    //We want to compute D[i][1]: First column is also a bit special.
	    D[i][1] = D[i-1][1] + A[i][1];
	    for(int l=1;l<=m;l++)
		D[i][1] = max(D[i][1], D[i-1][l] + A[i][1]);
	    
	    for(int j=2;j<=m;j++){
		//We want to compute D[i][j]. 
		//Either we came here from last row or column:
		D[i][j] = max(D[i-1][j], D[i][j-1]) + A[i][j];
		//Or from same row but a column number which divided j:
		for(int l=1;l<j;l++)
		    if((j % l)==0) //If l | j
			D[i][j] = max(D[i][j], D[i][l] + A[i][j]);
	    }
	}


	System.out.printf("%d\n", D[n][m]);
    }

    public static int max(int a, int b) {
	if(a<b) return b;
	else return a;
    }
};