import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.util.HashMap;
import java.util.Vector;

public class Main {
    public static void main(String[] args) throws FileNotFoundException {
        Scanner in = new Scanner(System.in);

        int row = in.nextInt();
        int col = in.nextInt();

        int min = 1001;
        int sum = 0;

        if (row % 2 == 0 && col % 2 == 0) {
            sum += in.nextInt();

            for (int i = 2; i < row * col; i++) {
                int c = in.nextInt();

                min = Math.min(min, c);

                sum += c;
            }

            sum += in.nextInt() - min;
        } else {
            for (int i = 0; i < row * col; i++) {
                sum += in.nextInt();
            }
        }

        System.out.println(sum);
    }

    private static Vector<coords> readLine(String line, int lineIndex) {
        Vector<coords> result = new Vector<>();
        var chars = line.toCharArray();
        if (chars[0] == '#')
            result.add(new coords(0, lineIndex));
        if (chars[4] == '#')
            result.add(new coords(4, lineIndex));
        if (chars[8] == '#')
            result.add(new coords(8, lineIndex));
        return result;
    }
}

class Pismeno {
    static HashMap<Character, Pismeno> map = new HashMap<>();
    private coords flag1;
    private coords flag2;

    public Pismeno(coords flag1, coords flag2) {
        this.flag1 = flag1;
        this.flag2 = flag2;
    }
}

class coords{
    int x;
    int y;

    public coords(int x, int y) {
        this.x = x;
        this.y = y;
    }
}