#include <bits/stdc++.h>
using namespace std;
int cas, n, m, t[202020];
map<string, int> id;
set<int> doc;
int tot = 0;
string s[202020];
int ans;
int vis[60];
int mat[60][60];
int cnt[60];
int ok(int tot, int k) {
  for (int i = 0; i <= tot; i++) {
    if (mat[vis[i]][k] == 0) return 0;
  }
  return 1;
}
void dfs(int u, int dep) {
  if (ans < dep) ans = dep;
  for (int i = u + 1; i < n; i++) {
    if (cnt[i] + dep < ans) return;
    if (ok(dep - 1, i)) {
      vis[dep] = i;
      dfs(i, dep + 1);
    }
  }
}
void maxclique() {
  ans = -1;
  for (int i = n - 1; i >= 0; i--) {
    vis[0] = i;
    dfs(i, 1);
    cnt[i] = ans;
  }
}
int main() {
  scanf("%d%d", &m, &n);
  for (int i = 1; i <= m; i++) {
    scanf("%d", &t[i]);
    if (t[i] == 2) {
      cin >> s[i];
      if (id.count(s[i]) == 0) {
        id[s[i]] = tot;
        tot++;
      }
    }
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) mat[i][j] = 1;
  for (int i = m; i >= 1; i--) {
    if (t[i] == 2)
      doc.insert(id[s[i]]);
    else {
      for (auto ss : doc)
        for (auto tt : doc) {
          mat[ss][tt] = mat[tt][ss] = 0;
        }
      doc.clear();
    }
  }
  maxclique();
  if (ans < 0) ans = 0;
  printf("%d\n", ans);
  return 0;
}
