A polygon with sides running along the sides of the squares was cut out of an endless chessboard. A segment of the perimeter of a polygon is called black if the polygon adjacent to it from the inside is which cell is black, respectively white if the cell is white. Let $A$ be the number of black segments on the perimeter, and $B$ be the number of white ones, Let the polygon consist of $a$ black and $b$ white cells. Prove that $A-B = 4(a -b)$.