h,w=gets.split.map &:to_i;*S=$<.map{|e|e.bytes.map{|b|1-b/46}} 1.upto(h-1){|y|1.upto(w-1){|x|S[y][x]+=[S[y-1][x-1],S[y][x-1],S[y-1][x]].min*S[y][x]}} p -~S.flatten.max/2