#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long power(long long a, long long n) {
  a %= 1000000007;
  if (n == 1) return a;
  if (n == 0) return 1;
  if (n % 2)
    return (a * (power((a * a) % 1000000007, n / 2) % 1000000007)) % 1000000007;
  return power((a * a) % 1000000007, n / 2) % 1000000007;
}
const long long inf = (long long)1e18;
long long inverse(long long x) { return power(x, 1000000007 - 2) % 1000000007; }
long long n, m, can[45][45], ctr = 0;
map<string, long long> mp;
long long mask[45], a[(1 << 20) + 5];
void solve() {
  cin >> n >> m;
  for (long long i = 1; i < m + 1; ++i) {
    for (long long j = 1; j < m + 1; ++j) can[i][j] = 1;
  }
  vector<pair<long long, string>> v(n + 5);
  for (long long i = 1; i < n + 1; ++i) {
    cin >> v[i].first;
    if (v[i].first == 2) {
      cin >> v[i].second;
      if (mp.find(v[i].second) == mp.end()) mp.insert({v[i].second, ++ctr});
    } else
      v[i].second = "";
  }
  for (long long i = 1; i < n + 1; ++i)
    if (v[i].first == 2) {
      set<long long> s;
      s.insert(mp[v[i].second]);
      while (i + 1 <= n && v[i + 1].first == 2) ++i, s.insert(mp[v[i].second]);
      for (auto &x : s) {
        for (auto &y : s)
          if (x != y) can[x][y] = 0;
      }
    }
  for (long long i = 1; i < m + 1; ++i) {
    for (long long j = 1; j < m + 1; ++j) {
      if (can[i][j]) mask[i] |= (1LL << (j - 1));
    }
  }
  for (long long i = 0; i < 1LL << (m / 2); ++i) {
    long long msk = (1LL << m) - 1;
    for (long long j = 0; j < m / 2; ++j) {
      if (i & (1LL << j)) {
        msk &= mask[j + 1];
      }
    }
    if ((msk & i) == i)
      a[i] = __builtin_popcount(i);
    else
      a[i] = 0;
  }
  for (long long i = 0; i < m / 2; ++i) {
    for (long long j = 0; j < 1LL << (m / 2); ++j) {
      if (j & (1LL << i)) a[j] = max(a[j], a[j ^ (1LL << i)]);
    }
  }
  long long ans = 0;
  for (long long i = 0; i < 1LL << (m - m / 2); ++i) {
    long long msk = (1LL << m) - 1;
    for (long long j = 0; j < m - m / 2; ++j) {
      if (i & (1LL << j)) {
        msk &= mask[j + 1 + m / 2];
      }
    }
    if ((msk & (i << (m / 2))) == (i << (m / 2))) {
      for (long long j = m / 2; j < m; ++j)
        if ((1LL << j) & msk) msk ^= (1LL << j);
      ans = max(ans, __builtin_popcount(i) + a[msk]);
    }
  }
  cout << ans << "\n";
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long T = 1;
  for (long long t = 1; t < T + 1; ++t) {
    solve();
  }
  return 0;
}
