#include <cstdio>
#include <string>
#include <set>
#include <sstream>
#include <iostream>

using namespace std;

int main()
{
	int t, z;
	scanf("%d", &t);
	
	while (t--) {
		string buf, str;
    	getline(cin, str);
    	stringstream ss(str);
    	int cnt = 0;

    	set<string> tokens;

    	while (ss >> buf) {
        	tokens.insert(buf);
        }
        
        for (set<string>::iterator it = tokens.begin(); it != tokens.end(); ++it) {
    		cnt++;
    	}
    	
        printf("%d\n", cnt);
    }
    
    return 0;
}