Implement Hamming distance (needed for 1-6).