#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const int MAXN = 100000 + 10;
int vis[50];
int n, m;
int Map[50][50];
int tot;
int ans;
int temp;
map<string, int> ma;
bitset<100005> bit[50];
char s[50];
int cnt[50];
bool dfs(int x, int d) {
  for (int i = x + 1; i <= m; i++) {
    if (d + cnt[i] <= ans) return 0;
    if (Map[x][i]) {
      int flag = 1;
      for (int j = 0; j < d; j++) {
        if (!Map[i][vis[j]]) {
          flag = 0;
          break;
        }
      }
      if (flag) {
        vis[d] = i;
        if (dfs(i, d + 1)) return 1;
      }
    }
  }
  if (d > ans) {
    ans = d;
    return 1;
  } else {
    return 0;
  }
}
void solve() {
  memset(vis, 0, sizeof(vis));
  ans = 0;
  for (int i = m; i > 0; i--) {
    vis[0] = i;
    dfs(i, 1);
    cnt[i] = ans;
  }
  printf("%d\n", ans);
}
int main() {
  scanf("%d %d", &n, &m);
  int op;
  int now = 0;
  while (n--) {
    scanf("%d", &op);
    if (op == 1) {
      now++;
    } else {
      scanf("%s", s);
      string name = s;
      int id;
      if (ma[name]) {
        id = ma[name];
      } else {
        ma[name] = ++tot;
        id = tot;
      }
      bit[id][now] = 1;
    }
  }
  for (int i = 1; i <= m; i++) {
    Map[i][i] = 1;
    for (int j = i + 1; j <= m; j++) {
      if ((bit[i] & bit[j]).count() != 0) {
        Map[i][j] = Map[j][i] = 0;
      } else {
        Map[i][j] = Map[j][i] = 1;
      }
    }
  }
  solve();
  return 0;
}
