For many summers the Agile Crystal Mining company ran an internship program for students. It valued an intern's ability to self organize into a team, so orientation included a get to know you activity: the interns had to split into teams. Inside one team, either every member's first name begins with the same letter, or every member's last name begins with the same letter. One more condition made it interesting. They had to use as few teams as possible.
One year six interns showed up. Stephen Cook, Vinton Cerf, Edmund Clarke, Judea Pearl, Shafi Goldwasser, and Silvio Micali split into three teams.
As a historical note, the company was eventually shut down over a rather strange (and illegal) hiring practice. It refused to hire any intern whose last name began with S, T, U, V, W, X, Y, or Z. First names were not subject to that whim, which was fortunate for Vinton Cerf.
Given one year's interns, find the smallest number of teams they can form.
Each year's group of interns is a separate trial. A trial begins with a line containing a single integer N (1≤N≤300), the number of interns that year. The next N lines each hold one intern's first name and last name, separated by one space. Names have no punctuation, and both the first name and the last name begin with an uppercase letter. For a last name, that letter is always in the range 'A' to 'R' inclusive. A line containing 0 marks the end of the input. There are at most 20 trials.
For each trial, print a single integer k, the minimum number of teams that were necessary.