#include <bits/stdc++.h>
using namespace std;
void open(const char *s) {}
void open2(const char *s) {}
template <class T>
int upmin(T &a, const T &b) {
  return (b < a ? a = b, 1 : 0);
}
template <class T>
int upmax(T &a, const T &b) {
  return (b > a ? a = b, 1 : 0);
}
namespace io {
const int SIZE = (1 << 20) + 1;
char ibuf[SIZE], *iS, *iT;
char obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1;
int getc() {
  (iS == iT ? iS = ibuf, iT = ibuf + fread(ibuf, 1, SIZE, stdin) : 0);
  return iS == iT ? EOF : *(iS++);
}
int f;
char c;
template <class T>
void get(T &x) {
  f = 1;
  for (c = getc(); (c < '0' || c > '9') && c != '-'; c = getc())
    ;
  (c == '-' ? f = -1, c = getc() : 0);
  x = 0;
  for (; c >= '0' && c <= '9'; c = getc()) x = x * 10 + c - '0';
  x *= f;
}
void flush() {
  fwrite(obuf, 1, oS - obuf, stdout);
  oS = obuf;
}
void putc(char x) {
  *(oS++) = x;
  if (oS == oT) flush();
}
int a[55], t;
template <class T>
void put(T x) {
  if (!x) putc('0');
  x < 0 ? putc('-'), x = -x : 0;
  while (x) {
    a[++t] = x % 10;
    x /= 10;
  }
  while (t) putc(a[t--] + '0');
}
void space() { putc(' '); }
void enter() { putc('\n'); }
struct flusher {
  ~flusher() { flush(); }
} io_flusher;
}  // namespace io
const int N = 100010;
int n, m;
map<string, int> c;
int op[N], d[N];
char str[50];
int ti;
long long f[N];
long long b[N];
int s[1 << 20];
int main() {
  open2("e");
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &op[i]);
    if (op[i] == 2) {
      scanf("%s", str + 1);
      if (!(d[i] = c[str + 1])) d[i] = c[str + 1] = ++ti;
    }
  }
  for (long long i = 1; i <= n; i++)
    if (op[i] == 1) {
      long long s = 0;
      for (long long j = 1; j <= m; j++)
        if (f[j]) s |= 1ll << (j - 1);
      for (long long j = 1; j <= m; j++)
        if (f[j]) b[j] |= s;
      memset(f, 0, sizeof f);
    } else
      f[d[i]] = 1;
  {
    long long s = 0;
    for (long long j = 1; j <= m; j++)
      if (f[j]) s |= 1ll << (j - 1);
    for (long long j = 1; j <= m; j++)
      if (f[j]) b[j] |= s;
    memset(f, 0, sizeof f);
  }
  for (long long i = 1; i <= m; i++)
    if ((b[i] >> (i - 1)) & 1) b[i] ^= 1ll << (i - 1);
  for (long long i = 0; i < 1 << (m / 2); i++) {
    long long flag = 1;
    long long cnt = 0;
    long long s2 = 0;
    for (long long j = 1; j <= m / 2; j++)
      if ((i >> (j - 1)) & 1) {
        if (i & b[j]) {
          flag = 0;
          break;
        }
        s2 |= b[j];
        cnt++;
      }
    if (flag) s[(1ll << (m - m / 2)) - 1 - (s2 >> (m / 2))] = cnt;
  }
  for (long long i = (1ll << (m - m / 2)) - 1; i >= 0; i--)
    for (long long j = 1; j <= m - m / 2; j++)
      if (!(i & (1ll << (j - 1)))) s[i] = max(s[i], s[i | (1ll << (j - 1))]);
  int ans = 0;
  for (long long i = 0; i < 1 << (m - m / 2); i++) {
    long long flag = 1;
    long long cnt = 0;
    long long s2 = 0;
    for (long long j = 1; j <= m - m / 2; j++)
      if ((i >> (j - 1)) & 1) {
        if ((i << (m / 2)) & b[j + m / 2]) {
          flag = 0;
          break;
        }
        s2 |= 1ll << (j - 1);
        cnt++;
      }
    if (flag) ans = max(ans, int(cnt + s[s2]));
  }
  printf("%d\n", ans);
  return 0;
}
