#include <bits/stdc++.h>
using namespace std;
const int N = 45;
int nd, nm, G[N][N];
int cntClique, pts[N], res[N], cnt[N];
map<string, int> H;
int n;
vector<int> v;
bool dfs(int pos, int num) {
  for (int i = pos + 1; i <= n; ++i) {
    if (cnt[i] + num <= cntClique) return false;
    if (G[pos][i]) {
      int ok = 1;
      for (int id = 1; id <= num; ++id) {
        if (!G[i][pts[id]]) {
          ok = 0;
          break;
        }
      }
      if (ok) {
        pts[num + 1] = i;
        if (dfs(i, num + 1)) return true;
      }
    }
  }
  if (num > cntClique) {
    for (int i = 1; i <= num; ++i) {
      res[i] = pts[i];
    }
    cntClique = num;
    return true;
  }
  return false;
}
void maxClique() {
  cntClique = -1;
  for (int i = n; i > 0; --i) {
    pts[1] = i;
    dfs(i, 1);
    cnt[i] = cntClique;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  memset(G, 1, sizeof G);
  cin >> nd >> nm;
  for (int i = 1; i <= nd; ++i) {
    int op;
    string s;
    cin >> op;
    if (op == 1) {
      v.clear();
    } else {
      cin >> s;
      if (!H.count(s)) {
        H[s] = ++n;
      }
      int y = H[s];
      for (auto& x : v) {
        G[x][y] = 0;
        G[y][x] = 0;
      }
      v.push_back(y);
    }
  }
  maxClique();
  if (cntClique < 0) {
    cout << "0";
  } else {
    cout << cntClique;
  }
  return 0;
}
