#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x) {
  char c;
  bool nega = 0;
  while ((!isdigit(c = getchar())) && (c != '-'))
    ;
  if (c == '-') {
    nega = 1;
    c = getchar();
  }
  x = c - 48;
  while (isdigit(c = getchar())) x = x * 10 + c - 48;
  if (nega) x = -x;
}
template <typename T>
inline void writep(T x) {
  if (x > 9) writep(x / 10);
  putchar(x % 10 + 48);
}
template <typename T>
inline void write(T x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  writep(x);
}
template <typename T>
inline void writeln(T x) {
  write(x);
  putchar('\n');
}
int n, m, g[43][43], v[43];
map<string, int> ma;
int all[43][43], some[43][43], none[43][43], ans = 0;
void dfs(int d, int an, int sn, int nn) {
  int i, j, sn1, nn1, u, v;
  if (!sn && !nn) {
    if (ans < an) ans = an;
  }
  u = some[d][0];
  for (i = 0; i < sn; i++) {
    v = some[d][i];
    if (g[u][v]) continue;
    for (j = 0; j < an; j++) all[d + 1][j] = all[d][j];
    all[d + 1][an] = v;
    sn1 = 0, nn1 = 0;
    for (j = 0; j < sn; j++)
      if (g[v][some[d][j]]) some[d + 1][sn1++] = some[d][j];
    for (j = 0; j < nn; j++)
      if (g[v][none[d][j]]) none[d + 1][nn1++] = none[d][j];
    dfs(d + 1, an + 1, sn1, nn1);
    some[d][i] = 0, none[d][nn++] = v;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int i, j, t, cnt = 0, k;
  set<int> s;
  string name;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    cin >> t;
    if (t == 1) {
      s.clear();
    } else {
      cin >> name;
      if (ma[name] == 0) {
        ma[name] = ++cnt;
      }
      k = ma[name];
      if (s.find(k) == s.end()) {
        for (set<int>::iterator it = s.begin(); it != s.end(); it++) {
          g[k][*it] = g[*it][k] = 1;
        }
        s.insert(k);
      }
    }
  }
  for (i = 1; i <= m; i++) {
    for (j = 1; j <= m; j++)
      if (i != j) g[i][j] = !g[i][j];
  }
  for (i = 0; i < m; i++) some[1][i] = i + 1;
  dfs(1, 0, m, 0);
  cout << ans << endl;
  return 0;
}
