shift_and_count(x_shift, y_shift, M, R) that shifts matrix M relative to matrix R by (x_shift, y_shift) and counts the overlapping 1s.(x_shift, y_shift) within the range [0, N-1].shift_and_count() twice, once with img1 as M and img2 as R, and once with img2 as M and img1 as R.1s.