#include <bits/stdc++.h>
using namespace std;
const int N = 40;
int e, n;
long long g[N];
int res = 1;
void calc(int i, long long mask, int cur) {
  if (i == n) {
    if (res < cur) res = cur;
    return;
  }
  int can = 0;
  for (int j = i; j < n; ++j)
    if ((mask & g[j]) == 0) ++can;
  if (cur + can <= res) return;
  if ((mask & g[i]) == 0) calc(i + 1, mask | (1ll << i), cur + 1);
  calc(i + 1, mask, cur);
}
int main() {
  srand(time(0));
  scanf("%d%d", &e, &n);
  long long mask = 0;
  map<string, int> mp;
  char s[42];
  vector<int> id;
  for (int i = 0; i < n; ++i) id.push_back(i);
  random_shuffle(id.begin(), id.end());
  for (int i = 0; i <= e; ++i) {
    int x;
    if (i < e) scanf("%d", &x);
    if (i == e || x == 1) {
      for (int j = 0; j < n; ++j)
        if ((mask >> j) & 1)
          for (int k = 0; k < n; ++k)
            if (j != k && ((mask >> k) & 1)) g[j] |= 1ll << k;
      mask = 0;
    } else {
      scanf("%s", s);
      if (mp.find(s) == mp.end()) {
        mp[s] = id.back();
        id.pop_back();
      }
      mask |= 1ll << mp[s];
    }
  }
  calc(0, 0, 0);
  printf("%d\n", res);
  return 0;
}
