#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5;
int n, m, tot = 0;
long long f[50];
map<string, int> Map;
bitset<maxn + 5> zero, g[50];
int ans = 0;
void dfs(int pt, int cc, long long mk) {
  if (pt + cc <= ans) return;
  ans = max(ans, cc);
  for (int i = pt; i >= 1; --i) {
    if ((f[i] & mk) == 0) {
      dfs(i - 1, cc + 1, mk | (1LL << i));
    }
  }
}
int main() {
  zero.reset();
  scanf("%d%d", &n, &m);
  {
    int now = 0, o, id;
    string s;
    char ch[100];
    for (int i = 1; i <= n; ++i) {
      scanf("%d", &o);
      if (o == 1)
        now = i;
      else {
        scanf("%s", ch);
        s = string(ch);
        if (Map.find(s) == Map.end()) Map[s] = ++tot;
        id = Map[s];
        g[id][now] = 1;
      }
    }
  }
  for (int i = 1; i <= m; ++i)
    for (int k = i + 1; k <= m; ++k) {
      if ((g[i] & g[k]) != zero) {
        f[i] |= (1LL << k);
        f[k] |= (1LL << i);
      }
    }
  dfs(m, 0, 0LL);
  printf("%d\n", ans);
  return 0;
}
