#include <bits/stdc++.h>
using namespace std;
long long n, m, o = 1, cur = -1, ans = 0;
vector<long long> av;
clock_t t;
bool tooLate() {
  return (double)((double)(clock() - t) / CLOCKS_PER_SEC) > 1.9;
}
int main() {
  t = clock();
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  map<string, long long> index;
  vector<vector<long long> > group;
  bool gr = false;
  for (long long i = 0; i < n; i++) {
    long long type;
    cin >> type;
    if (type == 1)
      gr = false;
    else {
      if (!gr) {
        group.push_back(vector<long long>(0));
        cur++;
        gr = true;
      }
      string nick;
      cin >> nick;
      if (index[nick] == 0) {
        index[nick] = o;
        o++;
      }
      group[cur].push_back(index[nick]);
    }
  }
  av.resize(m, ((long long)1 << m) - 1);
  for (long long i = 0; i < group.size(); i++) {
    long long bin = ((long long)1 << m) - 1;
    for (long long j = 0; j < group[i].size(); j++) {
      long long x = group[i][j] - 1;
      if ((bin >> x) % 2) bin -= ((long long)1 << x);
    }
    for (long long j = 0; j < group[i].size(); j++) {
      long long x = group[i][j] - 1;
      av[x] &= bin;
    }
  }
  vector<long long> fr(m);
  for (int i = 0; i < m; i++) fr[i] = i;
  for (int i = 0; i < 1e4; i++) {
    random_shuffle(fr.begin(), fr.end());
    long long curBin = ((long long)1 << m) - 1, cur = 0;
    for (int i = 0; i < m && !tooLate(); i++) {
      if ((curBin >> fr[i]) & 1) {
        cur++;
        curBin &= av[fr[i]];
      }
    }
    ans = max(ans, cur);
  }
  cout << ans;
  return 0;
}
