#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int n, m, k, ed;
unordered_map<string, int> mp;
long long ceng[maxn], G[50];
inline string read() {
  char ch = getchar();
  string st1 = "";
  while (!((ch >= 'a') && (ch <= 'z'))) ch = getchar();
  while ((ch >= 'a') && (ch <= 'z')) st1 += ch, ch = getchar();
  return st1;
}
unordered_map<long long, int> dp = {{0ll, 0}};
long long dfs(long long mask) {
  if (dp.count(mask)) return dp[mask];
  int u = __builtin_ctzll(mask);
  return dp[mask] = max(dfs(mask ^ (1ll << u)), 1 + dfs(mask & G[u]));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  int opt, flag = 1;
  string s;
  for (register int i = 1; i <= n; ++i) {
    cin >> opt;
    if (opt == 1 && flag) {
      flag = 0;
      ed++;
    } else if (opt == 2) {
      flag = 1;
      cin >> s;
      if (!mp.count(s)) mp[s] = k++;
      ceng[ed] |= 1ll << mp[s];
    }
  }
  for (register int c = 1; c <= ed; ++c) {
    for (int i = 0; i < k; i++) {
      for (int j = 0; j < k; j++) {
        if ((ceng[c] >> i) & 1 && (ceng[c] >> j) & 1) {
          G[i] |= 1ll << j;
        }
      }
    }
  }
  for (int i = 0; i < k; i++) G[i] = ~G[i];
  cout << dfs((1ll << m) - 1);
}
