def hamster(stringg):
    total_num = 0
    s = stringg.split("\n")
    x = int(s[0].split(" ")[0])
    y = int(s[0].split(" ")[1])
    lowest_val = 1000
    for i in range(x):
        a = s[i+1].split(" ")
        for j in range(len(a)):
            total_num+=int(a[j])
            if (not i==0 or not j==0) and (int(a[j])<lowest_val):
                lowest_val=int(a[j])
    if (x%2==0) and (y%2==0):
        total_num-=lowest_val
    return(str(total_num))

print(hamster(input()))