#include using namespace std; void solve(int n) { string riadok; int type; int types[1<<9]; for (int i = 0; i < (1<<9); ++i) types[i] = 0; for(int ii = 0; ii < n; ii++){ int curr = 0; cin >> riadok; for (int i = 0; i < riadok.length() ; ++i) { type = riadok[i] - '1'; curr |= (1 << type); } types[curr] = 1; } int value = 0; for (int i = 0; i < (1<<9); ++i) { value += types[i]; } cout << value << endl; } int main(){ int t; while (cin >> t) solve(t); return 0; }