#include <bits/stdc++.h>
using namespace std;
int Q;
bool vis[41];
int C;
map<string, int> msi;
int N;
int DP[1 << 23];
long long V[41];
int dp(long long S) {
  if (S < (1LL << 23) && DP[S] != -1) return DP[S];
  bool fnd = false;
  int u;
  for (int i = 0; i <= N - 1; i++)
    if (S & (1LL << i)) {
      fnd = true;
      u = i;
    }
  if (!fnd) return 0;
  int Mxc = max(1 + dp(S & V[u]), dp(S & ~(1LL << u)));
  if (S < (1LL << 23)) DP[S] = Mxc;
  return Mxc;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> Q >> N;
  for (int i = 0; i <= N - 1; i++) V[i] = ((1LL << N) - 1) & ~(1LL << i);
  int cmd;
  string str;
  for (int q = 1; q <= Q; q++) {
    cin >> cmd;
    if (cmd == 1) {
      for (int i = 0; i <= C - 1; i++)
        for (int j = i + 1; j <= C - 1; j++) {
          if (vis[i] && vis[j]) {
            V[i] &= ~(1LL << j);
            V[j] &= ~(1LL << i);
          }
        }
      memset(vis, 0, sizeof(vis));
    } else {
      cin >> str;
      if (msi.find(str) == msi.end()) {
        msi[str] = C++;
      }
      int i = msi[str];
      vis[i] = true;
    }
  }
  for (int i = 0; i <= C - 1; i++)
    for (int j = i + 1; j <= C - 1; j++) {
      if (vis[i] && vis[j]) {
        V[i] &= ~(1LL << j);
        V[j] &= ~(1LL << i);
      }
    }
  memset(DP, -1, sizeof(DP));
  int Ans = dp((1LL << N) - 1);
  cout << Ans << '\n';
  return 0;
}
