The only changes are to use lines of input as string, rather than words, and to remove the calls on unique. Other than that the program is the same.