#include <bits/stdc++.h>
using namespace std;
const int maxn = 50;
int mm[45][45];
map<string, int> name;
int n, m, Ans;
int Set[60], dp[45];
void dfs(int depth, int now) {
  for (int i = now; i <= m; i++) {
    if (depth + dp[i] <= Ans) return;
    bool flag = true;
    for (int j = 1; j <= depth; j++)
      if (!mm[Set[j]][i]) {
        flag = false;
        break;
      }
    if (flag) {
      Set[depth + 1] = i;
      dfs(depth + 1, i + 1);
    }
  }
  if (depth > Ans) Ans = depth;
}
int main() {
  scanf("%d%d", &n, &m);
  int tot = 1;
  memset(mm, 1, sizeof(mm));
  vector<int> res;
  for (int i = 0; i < n; i++) {
    int k;
    scanf("%d", &k);
    if (k == 1) {
      res.clear();
    } else {
      char str[maxn];
      scanf("%s", str);
      if (!name.count(str)) {
        name[str] = tot++;
      }
      int f = 1;
      for (int j = 0; j < res.size(); j++) {
        int tmp = res[j];
        if (tmp == name[str]) {
          f = 0;
          break;
        }
        mm[name[str]][tmp] = mm[tmp][name[str]] = 0;
      }
      if (f) res.push_back(name[str]);
    }
  }
  Ans = 0;
  dp[m] = 1;
  for (int i = m - 1; i >= 1; i--) {
    Set[1] = i;
    dfs(1, 1 + i);
    dp[i] = Ans;
  }
  printf("%d\n", dp[1]);
}
