Given a -ary alphabet , the Hamming distance between two words is the total number of positions in which has a different symbol than .

Rewriting with mathematical symbols, that means: