import java.util.Scanner;

public class Hamster {

    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {

        int n = sc.nextInt();
        int m = sc.nextInt();


        int res = 0;
        int min = Integer.MAX_VALUE;
        boolean minSet = false;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (i == 0 && j == 0) {
                    res += sc.nextInt();
                } else if (i == n -1 && j == m - 1) {
                    res += sc.nextInt();
                } else {
                    int num = sc.nextInt();
                    if (num < min && (n % 2 == 0 && m % 2 == 0)) {
                        if (minSet) {
                            res += min;
                        }
                        minSet = true;
                        min = num;
                    } else {
                        res += num;
                    }
                }
            }
        }
        System.out.println(res);

    }

}
