#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
pair<int, int> dp1[1 << 21], dp2[1 << 21], b[100001];
int ans1[1 << 21], ans2[1 << 21];
bitset<2 * 21> a[100001];
map<string, int> d;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m, idx = -1, c = -1, res = 0;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    int cmd;
    cin >> cmd;
    if (cmd == 1)
      ++idx;
    else {
      string s;
      cin >> s;
      if (!d.count(s)) d[s] = ++c;
      a[idx][d[s]] = 1;
    }
  }
  for (int i = 0; i < m; ++i) {
    b[i] = {(1 << m / 2) - 1, (1 << (m + 1) / 2) - 1};
    for (int j = 0; j <= idx; ++j)
      if (a[j][i]) {
        for (int k = 0; k < m / 2; ++k)
          if (a[j][k] && (b[i].first & (1 << k))) b[i].first ^= (1 << k);
        for (int k = m / 2; k < m; ++k)
          if (a[j][k] && (b[i].second & (1 << (k - m / 2))))
            b[i].second ^= (1 << (k - m / 2));
      }
  }
  dp1[0] = {(1 << m / 2) - 1, (1 << (m + 1) / 2) - 1};
  dp2[0] = {(1 << m / 2) - 1, (1 << (m + 1) / 2) - 1};
  for (int i = 0; i < (1 << m / 2); ++i)
    for (int j = m / 2 - 1; j >= 0; --j)
      if ((i & (1 << j)) && (dp1[i ^ (1 << j)].first & (1 << j))) {
        dp1[i] = {dp1[i ^ (1 << j)].first & b[j].first,
                  dp1[i ^ (1 << j)].second & b[j].second};
        ans1[i] = ans1[i ^ (1 << j)] + 1;
        break;
      }
  for (int i = 0; i < (1 << (m + 1) / 2); ++i)
    for (int j = (m + 1) / 2 - 1; j >= 0; --j) {
      if ((i & (1 << j)) && ans2[i] < ans2[i ^ (1 << j)]) {
        dp2[i] = dp2[i ^ (1 << j)];
        ans2[i] = ans2[i ^ (1 << j)];
      }
      if ((i & (1 << j)) && (dp2[i ^ (1 << j)].second & (1 << j)) &&
          ans2[i] < ans2[i ^ (1 << j)] + 1) {
        dp2[i] = {dp2[i ^ (1 << j)].first & b[j + m / 2].first,
                  dp2[i ^ (1 << j)].second & b[j + m / 2].second};
        ans2[i] = ans2[i ^ (1 << j)] + 1;
      }
    }
  for (int i = 0; i < (1 << m / 2); ++i) {
    res = max(res, ans1[i] + ans2[dp1[i].second]);
  }
  cout << res << '\n';
  return 0;
}
