#include <bits/stdc++.h>
using std::string;
std::map<string, int> book;
int bookSize = -1;
int vis[45];
long long pow2[45];
long long banMask[45];
int f[1 << 20][21];
int getId(string s) {
  if (book.count(s))
    return book[s];
  else
    return book[s] = ++bookSize;
}
void addEdge(int n) {
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) continue;
    for (int j = i + 1; j <= n; j++) {
      if (vis[j]) {
        banMask[i] |= pow2[j - 1];
        banMask[j] |= pow2[i - 1];
      }
    }
  }
}
int min(int a, int b) { return a > b ? b : a; }
int max(int a, int b) { return a > b ? a : b; }
int main() {
  pow2[0] = 1;
  for (int i = 1; i <= 41; i++) pow2[i] = pow2[i - 1] * 2ll;
  int n, m;
  scanf("%d%d", &n, &m);
  bookSize = 0;
  for (int i = 1; i <= n; i++) {
    int t;
    scanf("%d", &t);
    if (t == 1) {
      addEdge(m);
      for (int j = 1; j <= m; j++) vis[j] = 0;
    } else {
      string s;
      std::cin >> s;
      vis[getId(s)] = 1;
    }
  }
  addEdge(m);
  int ans = 0;
  int fst = min(m, 20);
  for (long long i = 0; i < (1ll << fst); i++) {
    int ok = 1, cnt = 0;
    for (int j = 1; j <= fst; j++) {
      if (i & pow2[j - 1]) {
        if ((banMask[j] & i) != 0)
          ok = 0;
        else
          cnt++;
      }
    }
    if (ok)
      f[i][0] = cnt;
    else
      f[i][0] = 0;
    for (int j = 1; j <= fst; j++) {
      if (i & pow2[j - 1]) {
        int last = i ^ pow2[j - 1];
        f[i][j] = max(f[last][j - 1], f[i][j - 1]);
      } else
        f[i][j] = f[i][j - 1];
    }
    ans = max(ans, f[i][fst]);
  }
  int left = m - fst;
  for (long long i = 0; i < (1ll << left); i++) {
    long long all = pow2[fst] - 1;
    int ok = 1, cnt = 0;
    for (int j = 1; j <= left; j++) {
      if (i & pow2[j - 1]) {
        if (banMask[j + fst] & (i << fst))
          ok = 0;
        else {
          long long delet = ~(banMask[j + fst]);
          all &= delet;
          cnt++;
        }
      }
    }
    if (ok) {
      int offer = f[all][fst] + cnt;
      ans = max(ans, offer);
    }
  }
  printf("%d\n", ans);
  return 0;
}
