Calc hamming distance