#include <bits/stdc++.h>
using namespace std;
map<string, int64_t> mp;
int64_t cnt = 0;
int64_t turn = -1;
bitset<100005> bs[50];
bitset<50> lik[50];
int32_t main() {
  {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
  };
  int64_t n, m, cmd, mx = 0;
  string s;
  cin >> n >> m;
  for (int64_t i = 0; i < n; i++) {
    cin >> cmd;
    if (cmd == 1) {
      turn++;
    } else {
      cin >> s;
      if (mp.find(s) == mp.end()) {
        mp[s] = cnt++;
      }
      bs[mp[s]][turn] = 1;
    }
  }
  for (int64_t i = 0; i < cnt; i++)
    for (int64_t j = i + 1; j < cnt; j++) {
      if ((bs[i] & bs[j]).count() == 0) {
        lik[i][j] = lik[j][i] = 1;
      }
    }
  vector<int64_t> v;
  srand(time(NULL));
  for (int64_t i = 0; i < cnt; i++) v.push_back(i);
  for (int64_t cc = 0; cc < 40000; cc++) {
    random_shuffle(v.begin(), v.end());
    vector<int64_t> ans;
    for (int64_t i : v) {
      bool ok = true;
      for (int64_t j : ans) {
        if (!lik[i][j]) ok = false;
      }
      if (ok) ans.push_back(i);
    }
    mx = max(mx, (int64_t)ans.size());
  }
  cout << mx << '\n';
  return 0;
}
