#include <bits/stdc++.h>
using namespace std;
int n, m, k;
map<string, int> d;
bool e[40][40];
int res;
void dfs(vector<int>& cand, int cnt) {
  if (cnt + cand.size() <= res) return;
  if (cnt > res) res = cnt;
  for (int i = 0; i < cand.size(); i++) {
    vector<int> nxt;
    for (int j = i + 1; j < cand.size(); j++) {
      if (!e[cand[i]][cand[j]]) nxt.push_back(cand[j]);
    }
    dfs(nxt, cnt + 1);
  }
}
long long st[40];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  string s;
  long long cur = 0;
  for (int i = 0; i < n; i++) {
    int q;
    cin >> q;
    if (q == 1) {
      for (int j = 0; j < k; j++)
        if (cur & (1LL << j)) {
          for (int t = j + 1; t < k; t++)
            if (cur & (1LL << t)) {
              e[j][t] = e[t][j] = true;
            }
        }
      cur = 0;
    } else {
      cin >> s;
      if (!d.count(s)) d[s] = k++;
      cur |= (1LL << d[s]);
    }
  }
  for (int i = 0; i < k; i++)
    if (cur & (1LL << i)) {
      for (int j = i + 1; j < k; j++)
        if (cur & (1LL << j)) {
          e[i][j] = e[j][i] = true;
        }
    }
  vector<int> v;
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < k; j++)
      if (e[i][j] || i == j) {
        st[i] |= (1LL << j);
      }
  }
  for (int i = 0; i < k; i++) {
    bool ok = true;
    for (int j = 0; j < k; j++)
      if (i != j) {
        if ((st[i] & st[j]) == st[j]) {
          if (st[i] != st[j]) {
            ok = false;
            break;
          } else if (i > j) {
            ok = false;
            break;
          }
        }
      }
    if (ok) v.push_back(i);
  }
  dfs(v, 0);
  cout << res << "\n";
  return 0;
}
