#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 50;
const int M = 50;
int n, m, id[M], cnt;
map<string, int> f;
long long vis, G[M];
int main() {
  srand(20011227);
  scanf("%d%d", &n, &m);
  string name;
  for (int i = 1, o; i <= n; i++) {
    scanf("%d", &o);
    if (o == 2) {
      cin >> name;
      if (!f[name]) f[name] = ++cnt;
      vis |= 1ll << f[name];
    } else {
      for (int i = 1; i <= m; i++)
        if ((vis >> i) & 1) G[i] |= vis;
      vis = 0;
    }
  }
  for (int i = 1; i <= m; i++)
    if ((vis >> i) & 1) G[i] |= vis;
  for (int i = 1; i <= m; i++) id[i] = i;
  int best = 0;
  for (int T = 1; T <= 1e6; T++) {
    random_shuffle(id + 1, id + m + 1);
    long long vis = 0;
    int res = 0;
    for (int j = 1; j <= m; j++)
      if ((vis & G[id[j]]) == 0) vis |= 1ll << id[j], res++;
    best = max(best, res);
  }
  printf("%d\n", best);
  return 0;
}
