#include <bits/stdc++.h>
using namespace std;
int n, m, cnt, kt[41][41], d[2000000], f[2000000], ans;
vector<int> v;
map<string, int> doi;
int main() {
  ios_base::sync_with_stdio();
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    int tt;
    string s;
    cin >> tt;
    if (tt == 1)
      v.clear();
    else {
      cin >> s;
      if (doi[s] == 0) doi[s] = ++cnt;
      for (auto x : v)
        if (x != doi[s]) kt[x][doi[s]] = kt[doi[s]][x] = 1;
      v.push_back(doi[s]);
    }
  }
  int m1 = m / 2;
  for (int i = 0; i < (1 << m1); i++)
    for (int j1 = 0; j1 < m1; j1++)
      if ((i & (1 << j1)) != 0)
        for (int j2 = 0; j2 < m1; j2++)
          if ((i & (1 << j2)) != 0)
            if (kt[j1 + 1][j2 + 1] == 1) d[i] = 1;
  for (int i = 1; i < (1 << m1); i++) {
    if (d[i] == 0) {
      int dem = 0;
      for (int j = 0; j < m1; j++)
        if ((i & (1 << j)) != 0) dem++;
      f[i] = dem;
      continue;
    }
    for (int j = 0; j < m1; j++)
      if ((i & (1 << j)) != 0) f[i] = max(f[i], f[i - (1 << j)]);
  }
  int m2 = m - m1;
  for (int i = 0; i < (1 << m2); i++) {
    int tt = 0;
    for (int j1 = 0; j1 < m2; j1++)
      if ((i & (1 << j1)) != 0)
        for (int j2 = 0; j2 < m2; j2++)
          if ((i & (1 << j2)) != 0)
            if (kt[j1 + 1 + m1][j2 + 1 + m1] == 1) tt = 1;
    if (tt == 0) {
      int dem = 0;
      for (int j1 = 0; j1 < m1; j1++) {
        dem += (1 << j1);
        for (int j2 = 0; j2 < m2; j2++)
          if ((i & (1 << j2)) != 0)
            if (kt[j1 + 1][j2 + 1 + m1] == 1) {
              dem -= (1 << j1);
              break;
            }
      }
      dem = f[dem];
      for (int j = 0; j < m2; j++)
        if ((i & (1 << j)) != 0) dem++;
      ans = max(ans, dem);
    }
  }
  cout << ans;
  return 0;
}
