The psuedo-code can be written as:
For each i in X: For each j in Y: D(i,j) = min( D(i-1,j) + 1 , D(1,j-1) + 1 , D(i-1,j-1) + 2 )