Converts trinary (tertary) input into an integer.