#include <bits/stdc++.h>
using namespace std;
const int maxn = 100;
bool a[maxn][maxn];
int ans, cnt[maxn], group[maxn], vis[maxn], cn;
map<string, int> mmp;
vector<int> pre;
bool dfs(int u, int pos) {
  int i, j;
  for (int i = u + 1; i < cn; i++) {
    if (cnt[i] + pos <= ans) return 0;
    if (a[u][i]) {
      for (j = 0; j < pos; j++)
        if (!a[i][vis[j]]) break;
      if (j == pos) {
        vis[pos] = i;
        if (dfs(i, pos + 1)) return 1;
      }
    }
  }
  if (pos > ans) {
    for (i = 0; i < pos; i++) group[i] = vis[i];
    ans = pos;
    return 1;
  }
  return 0;
}
void maxclique() {
  ans = -1;
  for (int i = cn; i > 0; i--) {
    vis[0] = i;
    dfs(i, 1);
    cnt[i] = ans;
  }
}
int main() {
  int n, m;
  ios::sync_with_stdio(false);
  cin >> n >> m;
  cn = 1;
  memset(a, 1, sizeof(a));
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    if (t == 1)
      pre.clear();
    else {
      string s;
      cin >> s;
      if (!mmp[s]) mmp[s] = cn++;
      int now = mmp[s];
      for (int j = 0; j < pre.size(); j++) {
        a[now][pre[j]] = 0;
        a[pre[j]][now] = 0;
      }
      pre.push_back(now);
    }
  }
  ans = 0;
  maxclique();
  cout << ans << endl;
}
