// hdoj_2072 单词数
// 0MS 236K 695 B GCC
#include <stdio.h>
#include <string.h>
char word[100000];
char arr[100][100]; //arr用于存储以前出现过的单词
int main(void)
{
int len, pos, count;
char temp[100];
while(gets(word) && strcmp(word, "#") != 0)
{
len = strlen(word);
pos = 0;
count = 0;
// pos加单词长度一直到>=len
while(pos < len)
{
sscanf(word + pos, "%s", temp); //把一个单词存入temp,空格忽略
int i;
for(i = 0; i < count; i ++)
if(strcmp(arr[i], temp) == 0)//如果和以前存入的单词相同,则不计数
break;
if(i == count)
strcpy(arr[count++], temp); //把temp存入arr,并计数器cnt加一
/*用pos来记录下次读取的位置*/
for(i = pos; word[i] == ' '; i++) //空格
pos++;
pos += strlen(temp) + 1; //单词
}
//判断是否全为空格
int k, m = 0;
for(k = 0; k < len; k ++)
if(word[k] == ' ')
m ++;
if(m == len)
printf("0\n");
else
printf("%d\n", count);
}
return 0;
}