#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct Cliquer {
  vector<ll> adj, f, g, h;
  int n, n_1, n_2;
  Cliquer(const vector<ll>& _adj) {
    adj = _adj;
    n = int(adj.size());
    assert(n > 0);
    for (int i = 0; i < n; i++) {
      adj[i] |= (1LL << i);
    }
    n_2 = n / 2;
    n_1 = n - n_2;
    f.assign((1LL << n_1), 0LL);
    g.assign((1LL << n_2), 0LL);
    for (ll x = 0; x < ll(f.size()); x++) {
      ll mask = (1LL << n) - 1;
      for (int i = 0; i < n_1; i++)
        if (x & (1LL << i)) {
          mask &= adj[i];
        }
      f[x] = ((mask & x) == x);
    }
    for (ll x = 0; x < ll(g.size()); x++) {
      ll mask = (1LL << n) - 1;
      ll y = (x << n_1);
      for (int i = n_1; i < n; i++)
        if (y & (1LL << i)) {
          mask &= adj[i];
        }
      g[x] = ((mask & y) == y);
    }
  }
  ll calc(ll x) {
    if (x == 0) return 0;
    ll& ans = h[x];
    if (ans != -1) return ans;
    ans = g[x] * __builtin_popcount(x);
    for (int i = 0; i < n_2; i++)
      if (x & (1 << i)) {
        ans = max(ans, calc(x ^ (1 << i)));
      }
    return ans;
  }
  int max_clique_size() {
    h.assign((1 << n_2), -1LL);
    int ans = 0;
    for (ll x = 0; x < ll(f.size()); x++)
      if (f[x]) {
        ll mask = (1LL << n) - 1;
        int res = 0;
        for (int i = 0; i < n_1; i++)
          if (x & (1 << i)) {
            res++;
            mask &= adj[i];
          }
        res += calc(mask >> n_1);
        ans = max(ans, res);
      }
    return ans;
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<ll> adj(m, (1LL << m) - 1);
  map<string, int> id;
  int cur = 0;
  set<int> s;
  auto process = [&]() {
    assert(int(s.size()) <= m);
    for (int x : s)
      for (int y : s)
        if (x != y) {
          adj[x] &= (~(1LL << y));
        }
  };
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    if (t == 1) {
      process();
      s.clear();
    } else {
      string f;
      cin >> f;
      if (id.find(f) == id.end()) id[f] = cur++;
      s.insert(id[f]);
    }
  }
  process();
  assert(cur == m);
  Cliquer c(adj);
  cout << c.max_clique_size() << '\n';
}
