#include <bits/stdc++.h>
using namespace std;
const int maxn = 100 + 10, mod = 1e9 + 7, INF = 0x3f3f3f3f;
bool e[maxn][maxn];
map<string, int> id;
int n, ans, tot, num, cnt[maxn], vis[maxn], a[maxn];
string t;
bool dfs(int u, int dep) {
  for (int v = u + 1; v <= n; ++v) {
    if (cnt[v] + dep <= ans) return 0;
    if (e[u][v]) {
      int i = 0;
      while (i < dep && e[v][vis[i]]) ++i;
      if (i == dep) {
        vis[dep] = v;
        if (dfs(v, dep + 1)) return 1;
      }
    }
  }
  if (dep > ans) {
    ans = dep;
    return 1;
  }
  return 0;
}
void maxclique() {
  ans = -1;
  for (int i = n; i; i--) {
    vis[0] = i;
    dfs(i, 1);
    cnt[i] = ans;
  }
}
int main() {
  int m;
  cin >> m >> n;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) e[i][j] = 1;
  for (int i = 0; i < m; ++i) {
    int ty;
    scanf("%d", &ty);
    if (ty == 1)
      tot = 0;
    else {
      cin >> t;
      if (id.find(t) == id.end()) id[t] = ++num;
      int cur = id[t];
      for (int i = 1; i <= tot; ++i) e[a[i]][cur] = e[cur][a[i]] = 0;
      a[++tot] = cur;
    }
  }
  maxclique();
  cout << ans;
}
