def g;gets.split.map &:to_i;end
while(m,n=g)[0]>0
a=(1..g[0]).map{|i|g+[i]}
b=(1..g[0]).map{g+[11]}
p b.map{|c|d=a+[c]
s=0
(1..n).map{|j|(1..m).map{|i|d.min_by{|x,y,t|z=(y-j).abs
[z+[(x-i).abs-(z+(i<x ?1-j%2:j%2))/2,0].max,t]}==c&&s+=1}}
s}.max
end