#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
const int INF = 0x3f3f3f3f;
const int iinf = 1 << 30;
const long long linf = 2e18;
const long long MOD = 1000000007;
void print(int x) {
  cout << x << endl;
  exit(0);
}
void PRINT(string x) {
  cout << x << endl;
  exit(0);
}
void douout(double x) { printf("%lf\n", x + 0.0000000001); }
map<string, int> id;
int n, m, cnt, ans;
int f[N], g[N][N];
bool fg[N * 100], vis[N * 100];
bool check(int x) {
  for (int i = (1); i <= (m); i++)
    if (g[i][x] && vis[i]) return 0;
  return 1;
}
signed main() {
  scanf("%d%d", &n, &m);
  for (int i = (1); i <= (n); i++) {
    int op;
    scanf("%d", &op);
    if (op == 1)
      memset(fg, 0, sizeof(fg));
    else {
      string s;
      cin >> s;
      if (!id[s]) id[s] = ++cnt;
      for (int j = (1); j <= (m); j++)
        if (fg[j]) g[id[s]][j] = g[j][id[s]] = 1;
      fg[id[s]] = 1;
    }
  }
  for (int i = (1); i <= (m); i++) f[i] = i;
  int tim = 1e5;
  while (tim--) {
    random_shuffle(f + 1, f + m + 1);
    memset(vis, 0, sizeof(vis));
    int sum = 0;
    for (int i = (1); i <= (m); i++)
      if (check(f[i])) {
        sum++;
        vis[f[i]] = 1;
      }
    ans = max(ans, sum);
  }
  printf("%d\n", ans);
  return 0;
}
