def hamming_distance(str1, str2):
    """
    For binary strings a and b the Hamming distance is equal to the number of ones (population count) in a XOR b.
    """
    diffs = [a^b for a, b in zip(str1, str2)]
    count = 0
    for diff in diffs:
        while diff != 0:
           diff = diff & (diff -1)
           count += 1
    return count