#include <bits/stdc++.h>
using namespace std;
int mod = 998244353;
const int maxn = 40 + 7;
int n, m;
int cnt = 0, inde = 0, ans = 0;
set<int> second[100007];
int some[maxn][maxn];
int none[maxn][maxn];
int all[maxn][maxn];
int ma[maxn][maxn];
map<string, int> ma1;
pair<int, int> deg[maxn];
void dfs(int d, int an, int sn, int nn) {
  if (!sn && !nn) {
    ans = max(ans, an);
    return;
  }
  int pivot = some[d][1];
  for (int j = 1; j <= an; ++j) all[d + 1][j] = all[d][j];
  for (int i = 1; i <= sn; ++i) {
    int v = some[d][i];
    if (ma[pivot][v]) continue;
    all[d + 1][an] = v;
    int tsn = 0, tnn = 0;
    for (int j = 1; j <= sn; ++j)
      if (ma[v][some[d][j]]) some[d + 1][++tsn] = some[d][j];
    for (int j = 1; j <= nn; ++j)
      if (ma[v][none[d][j]]) none[d + 1][++tnn] = none[d][j];
    dfs(d + 1, an + 1, tsn, tnn);
    some[d][i] = 0, none[d][++nn] = v;
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = (1); i <= (n); i++) {
    int x;
    scanf("%d", &x);
    if (x == 1)
      ++cnt;
    else {
      string s;
      cin >> s;
      if (ma1.count(s) == 0) ma1[s] = ++inde;
      second[cnt].insert(ma1[s]);
    }
  }
  for (int i = (1); i <= (m); i++)
    for (int j = (1); j <= (m); j++) ma[i][j] = 1;
  for (int i = (1); i <= (cnt); i++)
    for (auto x : second[i])
      for (auto y : second[i]) {
        ma[x][y] = 0;
      }
  for (int i = (1); i <= (m); i++)
    for (int j = (1); j <= (m); j++) {
      if (ma[i][j]) deg[i].first++;
      deg[i].second = i;
    }
  sort(deg + 1, deg + 1 + m);
  for (int i = m; i >= 1; i--) some[1][i] = deg[i].second;
  dfs(1, 0, m, 0);
  printf("%d\n", ans);
  return 0;
}
