Description
Lily's good friend xiaoou333 is very empty recently. He thought about a pointless thing, which is to count the total number of different words in an article. Your task below is to help xiaoou333 to solve this problem.
Input
There are multiple sets of data, one for each group, and each group is a small article. Each small article is composed of lowercase letters and spaces, without punctuation marks, when # is encountered, it means the end of input.
Output
Each group outputs only one integer, which is a separate line. The integer represents the total number of different words in an article.
Sample Input
you are my friend #
Sample Output
4
#include <iostream>
#include <sstream>
#include <set>
using namespace std;
int main(){
string str, s;
while (getline(cin, str)){
if (str == "#")
break;
istringstream iss(str);
set<string> sets;
while (iss >> s)
sets.insert(s);
cout << sets.size() << endl;
}
return 0;
}