if (a[x,y] == 1)
  					length_up[x,y] = 0
  				else
  					length_up[x,y] = 1 + length_up[x,y-1]