def ham_dist(s1, s2):
    """
    The Hamming distance is defined between two strings of equal length.
    It measures the number of positions with mismatching characters.
    """
    assert len(s1) == len(s2)
    return sum(ch1 != ch2 for ch1, ch2 in zip(s1, s2))