arr=Array.new(10){Array.new(10,0)}
while gets
    x,y,s=$_.chomp.split(',').map(&:to_i)
    if s>=1
        arr[y][x]+=1
        arr[y][x+1]+=1 if x+1<10
        arr[y][x-1]+=1 if x-1>=0
        arr[y+1][x]+=1 if y+1<10
        arr[y-1][x]+=1 if y-1>=0
    end
    if s>1
        arr[y-1][x-1]+=1 if y-1>=0 && x-1>=0
        arr[y-1][x+1]+=1 if y-1>=0 && x+1<10
        arr[y+1][x-1]+=1 if y+1<10 && x-1>=0
        arr[y+1][x+1]+=1 if y+1<10 && x+1<10
    end
    if s>2
        arr[y-2][x]+=1 if y-2>=0
        arr[y+2][x]+=1 if y+2<10
        arr[y][x-2]+=1 if x-2>=0
        arr[y][x+2]+=1 if x+2<10
    end
end
arr.flatten!.sort!
p arr.find_all{|item|item==0}.size
p arr[-1]