#include <bits/stdc++.h>
using namespace std;
template <typename T>
void maxtt(T& t1, T t2) {
  t1 = max(t1, t2);
}
template <typename T>
void mintt(T& t1, T t2) {
  t1 = min(t1, t2);
}
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "URDL";
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int& x, int y, int mod = 1000000007) {
  assert(y >= 0);
  x += y;
  if (x >= mod) x -= mod;
  assert(x >= 0 && x < mod);
}
void et(int x = -1) {
  printf("%d\n", x);
  exit(0);
}
long long fastPow(long long x, long long y, int mod = 1000000007) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = (x * ans) % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
long long gcd1(long long x, long long y) { return y ? gcd1(y, x % y) : x; }
int t[100035], cnt, a[100035];
string s[100035];
map<string, int> mp;
int gid(string a) {
  if (mp.find(a) == mp.end()) mp[a] = cnt++;
  return mp[a];
}
bool vs[55];
namespace zdt {
int tot, G[55][55], cnt[55], ans, vis[55], group[55];
bool dfs(int u, int pos) {
  for (int i = u + 1; i <= tot; i++) {
    if (cnt[i] + pos <= ans) return false;
    if (G[u][i]) {
      int j;
      for (j = 0; j < pos; j++)
        if (!G[i][vis[j]]) break;
      if (j == pos) {
        vis[pos] = i;
        if (dfs(i, pos + 1)) return true;
      }
    }
  }
  if (pos > ans) {
    for (int i = 0; i < pos; i++) group[i] = vis[i];
    ans = pos;
    return true;
  }
  return false;
}
void maxclique() {
  ans = -1;
  for (int i = tot; i >= 1; i--) {
    vis[0] = i;
    dfs(i, 1);
    cnt[i] = ans;
  }
}
};  // namespace zdt
void fmain(int tid) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    cin >> t[i];
    if (t[i] == 2) {
      cin >> s[i];
      a[i] = gid(s[i]);
    }
  }
  for (int(i) = 1; (i) <= (int)(m); (i)++)
    for (int(j) = 1; (j) <= (int)(m); (j)++) zdt::G[i][j] = 1;
  for (int i = 1, j; i <= n; i = j) {
    if (t[i] == 1) {
      j = i + 1;
      continue;
    }
    for (j = i; j <= n && t[j] == 2; j++)
      ;
    for (int(k) = 0; (k) < (int)(m); (k)++) vs[k] = 0;
    for (int k = i; k < j; k++) {
      vs[a[k]] = 1;
    }
    for (int(x) = 0; (x) < (int)(m); (x)++)
      if (vs[x])
        for (int(y) = 0; (y) < (int)(m); (y)++)
          if (vs[y])
            if (x != y) {
              zdt::G[x + 1][y + 1] = 0;
              zdt::G[y + 1][x + 1] = 0;
            }
  }
  zdt::tot = m;
  zdt::maxclique();
  int ans = zdt::ans;
  ans = max(ans, 0);
  cout << ans << endl;
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}
