#include <bits/stdc++.h>
using namespace std;
int n, m;
map<string, int> name;
int get_id(string s) { return name[s] ? name[s] : name[s] = name.size(); }
const int N = 45;
bitset<100100> bs[N];
bool cmp(int a, int b) { return bs[a].count() < bs[b].count(); }
int main() {
  name.clear();
  cin >> n >> m;
  int op;
  int gp = 0;
  for (int i = 0; i < n; i++) {
    cin >> op;
    if (op == 1) {
      gp++;
    } else {
      string s;
      cin >> s;
      int k = get_id(s);
      bs[k][gp] = 1;
    }
  }
  vector<vector<int>> g(m + 1, vector<int>(m + 1, 1));
  for (int i = 1; i <= m; i++)
    for (int j = i + 1; j <= m; j++)
      if ((bs[i] & bs[j]).count()) {
        g[i][j] = 0;
        g[j][i] = 0;
      }
  int df = 1e5;
  int ans = 0;
  while (df--) {
    vector<int> p(m + 1);
    for (int i = 1; i <= m; i++) p[i] = i;
    random_shuffle(p.begin() + 1, p.end());
    vector<int> vis(m + 1, 0);
    int z = 0;
    for (int i = 1; i <= m; i++) {
      int gg = 0;
      int x = p[i];
      for (int j = 1; j <= m; j++)
        if (vis[j] && !g[x][j]) gg = 1;
      if (!gg) {
        vis[x] = 1;
        z++;
      }
    }
    ans = max(ans, z);
  }
  printf("%d\n", ans);
}
