#include <bits/stdc++.h>
const int N = 41, M = 21;
using namespace std;
int n, m, cur = 0, conf[N][N];
map<string, int> mp;
set<int> vals[N];
int get(string s) {
  if (mp.count(s)) return mp[s];
  return mp[s] = mp.size();
}
bool can[1 << M];
int dp[1 << M];
int main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    int op;
    cin >> op;
    if (op == 1) {
      cur++;
    } else {
      string s;
      cin >> s;
      vals[get(s)].insert(cur);
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < i; j++) {
      int u = i, v = j;
      if (vals[u].size() < vals[v].size()) swap(u, v);
      bool con = 0;
      for (auto el : vals[v]) {
        if (vals[u].count(el)) con = 1;
      }
      conf[u][v] = conf[v][u] = con;
    }
  }
  int brek = (m + 1) / 2;
  int ans = 0;
  for (int e = 0; e < (1 << brek); e++) {
    bool bo = 0;
    int cnt = 0;
    for (int i = 0; i < brek; i++) {
      if (((1 << i) & e) == 0) continue;
      cnt++;
      for (int j = 0; j < i; j++) {
        if (((1 << j) & e) == 0) continue;
        if (conf[i][j]) bo = 1;
      }
    }
    if (!bo) {
      can[e] = 1;
      dp[e] = cnt;
      ans = max(ans, cnt);
    }
  }
  for (int i = 0; i < brek; i++) {
    for (int j = 0; j < (1 << brek); j++) {
      if ((1 << i) & j) dp[j] = max(dp[j], dp[j - (1 << i)]);
    }
  }
  int lef = m - brek;
  for (int e = 0; e < (1 << lef); e++) {
    bool bo = 0;
    int cnt = 0;
    for (int i = 0; i < lef; i++) {
      if (((1 << i) & e) == 0) continue;
      cnt++;
      for (int j = 0; j < i; j++) {
        if (((1 << j) & e) == 0) continue;
        if (conf[i + brek][j + brek]) bo = 1;
      }
    }
    if (bo) continue;
    ans = max(ans, cnt);
    vector<bool> c(brek, 1);
    for (int i = 0; i < lef; i++) {
      if (((1 << i) & e) == 0) continue;
      for (int j = 0; j < brek; j++) {
        if (conf[i + brek][j]) c[j] = 0;
      }
    }
    int d = 0;
    for (int i = 0; i < brek; i++) {
      d += (1 << i) * c[i];
    }
    ans = max(ans, cnt + dp[d]);
  }
  cout << ans << '\n';
  return 0;
}
