Add Hamming distance function