#include <bits/stdc++.h>
#pragma warning(disable : 4786)
#pragma warning(disable : 4996)
using namespace std;
set<int> adj[50];
bitset<40> adjB[50];
map<string, int> M;
int n, m;
int ans;
void bktk(bitset<40> B, int taken, int st = 0) {
  int best = m - B.count() + taken;
  if (best <= ans) return;
  ans = ((ans) > (taken) ? (ans) : (taken));
  if (B.count() == m) return;
  for (int i = st; i < m; i++) {
    if (B.test(i)) continue;
    bitset<40> C = B;
    C |= adjB[i];
    C.set(i);
    bktk(C, taken + 1, i + 1);
    B.set(i);
  }
}
void solve(int ks) {
  scanf("%d %d", &n, &m);
  set<int> V;
  int cnt = 0;
  while (n--) {
    int now;
    char name[100];
    scanf("%d", &now);
    if (now == 1) {
      if (V.empty()) continue;
      for (int i : V)
        for (int j : V) {
          if (i != j) {
            adj[i].insert(j);
            adj[j].insert(i);
          }
        }
      V.clear();
      continue;
    }
    scanf("%s", name);
    if (M.find(name) == M.end()) M[name] = ++cnt;
    V.insert(M[name]);
  }
  for (int i : V)
    for (int j : V) {
      if (i != j) {
        adj[i].insert(j);
        adj[j].insert(i);
      }
    }
  {
    vector<int> V;
    for (int i = 1; i <= m; i++) {
      V.push_back(i - 1);
    }
    random_shuffle(V.begin(), V.end());
    set<int> a[50];
    for (int i = 1; i <= m; i++) {
      for (int j : adj[i]) {
        a[i].insert(V[j - 1]);
      }
    }
    for (int i = 0; i < m; i++) {
      adj[V[i]] = a[i + 1];
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j : adj[i]) adjB[i].set(j);
  }
  bktk(0, 0);
  printf("%d\n", ans);
}
int main() {
  if (0) {
    int T;
    scanf("%d", &T);
    for (int ks = 1; ks <= T; ks++) solve(ks);
  } else {
    solve(0);
  }
  return 0;
}
