#include <bits/stdc++.h>
using namespace std;
const int M = 1e2 + 5;
map<string, int> mp;
string str;
bool a[M][M], b[M][M];
int ans, cnt[M], group[M], n, m, vis[M], tot, op, g[M], tmp;
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 main() {
  while (~scanf("%d%d", &m, &n)) {
    tot = 1;
    for (int i = 0; i < m; i++) {
      scanf("%d", &op);
      if (op == 1) {
        if (tmp) {
          for (int x = 0; x < tmp; x++) {
            for (int y = 0; y < tmp; y++) {
              b[g[x]][g[y]] = 1;
            }
          }
          memset(g, 0, sizeof(g));
          tmp = 0;
        }
      }
      if (op == 2) {
        cin >> str;
        if (!mp[str]) {
          mp[str] = tot++;
        }
        g[tmp++] = mp[str];
      }
    }
    if (tmp) {
      for (int x = 0; x < tmp; x++) {
        for (int y = 0; y < tmp; y++) {
          b[g[x]][g[y]] = 1;
        }
      }
    }
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++)
        if (!b[i][j]) a[i][j] = 1;
    maxclique();
    if (ans < 0) ans = 0;
    printf("%d\n", ans);
  }
}
