#include <bits/stdc++.h>
using namespace std;
const int V = 50;
const int N = 1e5 + 10;
struct MaxClique {
  bool g[V][V];
  int n, ans, max[V], adj[V][V];
  int path[V], clique[V];
  void init(int _n) {
    n = _n;
    memset(g, false, sizeof(g));
  }
  bool dfs(int cur, int dep) {
    if (cur == 0) {
      if (dep > ans) {
        ans = dep;
        swap(clique, path);
        return 1;
      }
      return 0;
    }
    for (int i = 0; i < cur; ++i) {
      if (dep + cur - i <= ans) return 0;
      int u = adj[dep][i], nxt = 0;
      if (dep + max[u] <= ans) return 0;
      path[dep] = u;
      for (int j = i + 1; j < cur; ++j) {
        int v = adj[dep][j];
        if (g[u][v]) adj[dep + 1][nxt++] = v;
      }
      if (dfs(nxt, dep + 1)) return 1;
    }
    return 0;
  }
  int maxClique() {
    ans = 0;
    memset(max, 0, sizeof max);
    for (int i = n - 1; ~i; --i) {
      int cur = 0;
      for (int j = i + 1; j < n; ++j)
        if (g[i][j]) adj[1][cur++] = j;
      path[0] = i;
      dfs(cur, 1);
      max[i] = ans;
    }
    return ans;
  }
} solver;
struct query {
  int ty, id;
  string s;
};
map<string, int> sav;
query a[N];
set<int> ss;
int main() {
  ios::sync_with_stdio(false);
  int n, m, cnt;
  cin >> n >> m;
  solver.init(m);
  for (int i = 1; i <= n; i++) {
    cin >> a[i].ty;
    if (a[i].ty == 2) {
      cin >> a[i].s;
      if (!sav.count(a[i].s)) sav.insert(make_pair(a[i].s, 0));
    }
  }
  a[n + 1].ty = 1;
  cnt = 0;
  for (auto& it : sav) it.second = cnt++;
  for (int i = 1; i <= n; i++) {
    if (a[i].ty == 2) a[i].id = sav[a[i].s];
  }
  for (int i = 2; i <= n + 1; i++) {
    if (a[i].ty == 1) {
      for (auto it : ss) {
        for (auto it2 : ss) {
          if (it == it2) continue;
          solver.g[it][it2] = solver.g[it2][it] = true;
        }
      }
      ss.clear();
    } else
      ss.insert(a[i].id);
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < m; j++) {
      if (i == j)
        solver.g[i][j] = 0;
      else
        solver.g[i][j] = !solver.g[i][j];
    }
  }
  cout << solver.maxClique() << '\n';
  return 0;
}
