#include <bits/stdc++.h>
using namespace std;
int n, m, tot;
long long e[100];
vector<set<int>> v;
map<string, int> mp;
map<long long, int> f;
int dfs(long long x) {
  if (f.find(x) != f.end()) return f[x];
  int cnt = 0;
  while (!((x >> cnt) & 1)) ++cnt;
  int a = dfs(x ^ (1ll << cnt)), b = dfs(x & e[cnt]);
  return f[x] = max(a, b + 1);
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    int opt;
    cin >> opt;
    if (opt == 1) {
      set<int> st;
      v.push_back(st);
    } else {
      string name;
      cin >> name;
      if (mp.find(name) == mp.end()) mp[name] = tot++;
      v.back().insert(mp[name]);
    }
  }
  fill(e, e + m, (1ll << m) - 1);
  for (int i = 0; i < v.size(); ++i)
    for (auto i1 = v[i].begin(); i1 != v[i].end(); i1++)
      for (auto i2 = v[i].begin(); i2 != v[i].end(); i2++) {
        int x = *i1, y = *i2;
        e[x] &= ~(1ll << y);
      }
  f[0] = 0;
  cout << dfs((1ll << m) - 1) << endl;
  return 0;
}
