#include <bits/stdc++.h>
using namespace std;
pair<int, unsigned long long> maxindset(vector<unsigned long long> g) {
  int n = g.size(), m = n / 2, k = n - m;
  vector<pair<int, unsigned long long>> v(1 << m, {0, 0});
  for (int i = 1, t = -1; i < (1 << m); ++i) {
    if ((i & -i) == i) t++;
    int z = 1 << t;
    v[i] = v[i ^ z];
    z |= g[t];
    v[i] = max(v[i], {v[i & ~z].first + 1, v[i & ~z].second | (1 << t)});
  }
  pair<int, unsigned long long> res = v.back();
  vector<unsigned long long> f(1 << k, 0);
  for (int i = 1, t = -1; i < (1 << k); ++i) {
    if ((i & -i) == i) t++;
    int z = 1 << t;
    f[i] = f[i ^ z] | g[m + t];
    if ((f[i] >> m) & i) continue;
    z = ((1 << m) - 1) & ~f[i];
    res = max(res, {__builtin_popcount(i) + v[z].first,
                    v[z].second | ((unsigned long long)i << m)});
  }
  return res;
}
int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, q;
  cin >> q >> n;
  map<string, int> m;
  unsigned long long b = 0;
  vector<unsigned long long> g(n, 0);
  while (q--) {
    int o;
    cin >> o;
    if (o == 1) {
      for (int i = 0; i != n; ++i)
        if ((b >> i) & 1) g[i] |= b;
      b = 0;
    } else {
      string s;
      cin >> s;
      b |= (1ull << m.insert({s, m.size()}).first->second);
    }
  }
  for (int i = 0; i != n; ++i)
    if ((b >> i) & 1) g[i] |= b;
  for (int i = 0; i != n; ++i) g[i] &= ~(1ull << i);
  cout << maxindset(g).first << endl;
  return 0;
}
