def hamming_distance(pattern, motiv):
    """ 
    Calculates the hamming distance
    between its two parameters
    """
    if len(pattern) != len(motiv):
        return -1

    hamming_distance = 0
    for i in range(len(motiv)):
        if pattern[i] != motiv[i]:
            hamming_distance += 1
    
    return hamming_distance