#include <bits/stdc++.h>
using namespace std;
long long G[55];
long long n, ans;
void bronKerbosch(long long R, long long P, long long X) {
  if (!P and !X) ans = max(ans, (long long)__builtin_popcountll(R));
  auto pivot = __builtin_ctzll(P | X);
  auto Q = P & ~G[pivot];
  while (Q) {
    auto v = __builtin_ctzll(Q);
    bronKerbosch(R | (1LL << v), P & G[v], X & G[v]);
    P &= ~(1LL << v);
    Q &= ~(1LL << v);
    X |= 1LL << v;
  }
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  ;
  map<string, long long> ma;
  set<long long> v;
  long long cnt = 0;
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    if (x == 1) {
      if (v.size() > 1) {
        for (auto &a : v) {
          for (auto &b : v) {
            if (a != b) {
              G[a] |= (1LL << b);
              G[b] |= (1LL << a);
            }
          }
        }
      }
      v.clear();
    } else {
      string s;
      cin >> s;
      if (ma.count(s) == 0) ma[s] = cnt++;
      v.insert(ma[s]);
    }
  }
  if (v.size() > 1) {
    for (auto &a : v) {
      for (auto &b : v) {
        if (a != b) {
          G[a] |= (1LL << b);
          G[b] |= (1LL << a);
        }
      }
    }
  }
  v.clear();
  for (long long i = 0; i < m; i++) {
    G[i] ^= ((1LL << m) - 1);
    G[i] ^= (1LL << i);
  }
  ans = 0;
  bronKerbosch(0, (111LL << m) - 1, 0);
  cout << ans << '\n';
  return 0;
}
