Raster indexes. Google for paper, if you want a complete background, it's not easy, but worth a read. Basically create bitmpas for your booleans as follows:
010110101010
110100010100
000101001100
XOR , , . ( , () 100 ), , .
: XOR. ( )
000101001100 source
000101001010 target
000000000110 result of XOR
int n = 0; if (v) do { n++; } while (v &= (v-1)); return(n);
1 , 2 m-2 , m - .