#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  if (c == '-') f = -1, c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return f * x;
}
const int maxn = 40 + 7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
int n, m, cur, cnt;
bitset<100000> b[41];
map<string, int> hh;
int g[maxn][maxn];
int dp1[(1 << 20) + 7], dp2[(1 << 20) + 7];
inline void max(int &x, int y) {
  if (x < y) x = y;
}
int main() {
  n = read(), m = read();
  string name;
  for (int i = 1; i <= n; ++i) {
    int op = read();
    if (op == 1)
      ++cur;
    else {
      cin >> name;
      if (hh.count(name) == 0) hh[name] = ++cnt;
      b[hh[name]][cur] = 1;
    }
  }
  for (int i = 1; i <= m; ++i) {
    for (int j = i + 1; j <= m; ++j) {
      if ((b[i] & b[j]).count()) g[i - 1][j - 1] = g[j - 1][i - 1] = 1;
    }
  }
  int n2 = m / 2, n1 = m - n2;
  for (int i = 0; i < n1; ++i) dp1[1 << i] = 1;
  for (int s = 3; s < 1 << n1; ++s) {
    for (int i = 0; i < n1; ++i)
      if (s >> i & 1) {
        int f = 1;
        for (int j = 0; j < n1; ++j)
          if ((s >> j & 1) && g[i][j]) f = 0;
        max(dp1[s], dp1[s ^ (1 << i)] + f);
      }
  }
  for (int i = 0; i < n2; ++i) dp2[1 << i] = 1;
  for (int s = 3; s < 1 << n2; ++s) {
    for (int i = 0; i < n2; ++i)
      if (s >> i & 1) {
        int f = 1;
        for (int j = 0; j < n2; ++j)
          if ((s >> j & 1) && g[n1 + i][n1 + j]) f = 0;
        max(dp2[s], dp2[s ^ (1 << i)] + f);
      }
  }
  int ans = 0;
  for (int s = 0; s < 1 << n1; ++s) {
    int s2 = (1 << n2) - 1;
    for (int i = 0; i < n1; ++i)
      if (s >> i & 1) {
        for (int j = 0; j < n2; ++j)
          if ((s2 >> j & 1) && g[i][n1 + j]) s2 ^= 1 << j;
      }
    max(ans, dp1[s] + dp2[s2]);
  }
  printf("%d\n", ans);
}
