#include <bits/stdc++.h>
using namespace std;
const int MAXN = 42;
map<string, int> M;
int mps;
int mapeo(string S) {
  if (!M.count(S)) M[S] = mps++;
  return M[S];
}
int n, q;
bitset<MAXN> G[MAXN];
long long g[MAXN];
map<long long, int> S;
int solve(long long bm) {
  int cnt = __builtin_popcountll(bm);
  if (cnt < 2) return S[bm] = cnt;
  if (S.count(bm)) return S[bm];
  int p = 0;
  while (p < n && ((bm & (1LL << p)) == 0)) p++;
  int ans = solve(bm ^ (1LL << p));
  int ansm = 1 + solve((bm & g[p]) ^ (1LL << p));
  return S[bm] = max(ans, ansm);
}
int main() {
  ios::sync_with_stdio(false);
  while (cin >> q >> n) {
    M.clear();
    S.clear();
    mps = 0;
    for (int i = (0); i < (int)(n); i++) G[i] = 0;
    bitset<MAXN> neigh = 0;
    for (int i = (0); i < (int)(q); i++) {
      int tp;
      cin >> tp;
      if (tp == 1) {
        for (int i = (0); i < (int)(n); i++)
          if (neigh[i]) G[i] |= neigh;
        neigh = 0;
      } else {
        string X;
        cin >> X;
        int guy = mapeo(X);
        neigh[guy] = 1;
      }
    }
    for (int i = (0); i < (int)(n); i++)
      if (neigh[i]) G[i] |= neigh;
    neigh = 0;
    for (int i = (0); i < (int)(n); i++) {
      g[i] = 0;
      for (int j = (0); j < (int)(n); j++)
        if (G[i][j] == 0) g[i] |= (1LL << j);
      g[i] |= (1LL << i);
    }
    printf("%d\n", solve((1LL << n) - 1));
  }
  return 0;
}
