#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1000000000;
template <class T>
T read(T &x) {
  char c;
  int flag = 1;
  while ((c = getchar()) < '0' || c > '9')
    if (c == '-') flag *= -1;
  x = c - '0';
  while ((c = getchar()) >= '0' && c <= '9') x = x * 10 + c - '0';
  x *= flag;
  return x;
}
bool flag[50], a[50][50];
int ans, cnt[50], group[50], n, vis[50];
bool dfs(int u, int pos) {
  int i, j;
  for (i = u + 1; i <= n; i++) {
    if (cnt[i] + pos <= ans) return 0;
    if (a[u][i]) {
      for (j = 0; j < pos; j++)
        if (!a[i][vis[j]]) break;
      if (j == pos) {
        vis[pos] = i;
        if (dfs(i, pos + 1)) return 1;
      }
    }
  }
  if (pos > ans) {
    for (i = 0; i < pos; i++) group[i] = vis[i];
    ans = pos;
    return 1;
  }
  return 0;
}
void maxclique() {
  ans = -1;
  for (int i = n; i > 0; i--) {
    vis[0] = i;
    dfs(i, 1);
    cnt[i] = ans;
  }
}
int id;
bool inset[50];
int m;
map<string, int> M;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> m >> n;
  for (int i = 1; i <= m; ++i) {
    int cmd;
    cin >> cmd;
    if (cmd == 1) {
      for (int i = 1; i <= n; ++i) inset[i] = 0;
    } else {
      string x;
      cin >> x;
      if (!M.count(x)) M[x] = ++id;
      if (inset[M[x]]) continue;
      inset[M[x]] = true;
      for (int i = 1; i <= n; ++i)
        if (i != M[x] && inset[i]) a[i][M[x]] = a[M[x]][i] = 1;
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      if (i == j) continue;
      a[i][j] = !a[i][j];
    }
  }
  maxclique();
  cout << ans << endl;
}
