#include <bits/stdc++.h>
#pragma gcc optimize("Ofast")
using namespace std;
int n, m, cnt;
map<string, int> sig;
int G[50][50];
int dp[1 << 21];
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> m >> n;
  vector<int> v;
  for (int i = 0; i < m; ++i) {
    int type;
    cin >> type;
    if (type == 2) {
      string x;
      cin >> x;
      if (sig.find(x) == sig.end()) sig[x] = cnt++;
      v.emplace_back(sig[x]);
    } else if (type == 1) {
      for (int j = 0; j < (int)(v).size(); ++j)
        for (int t = 0; t < (int)(v).size(); ++t)
          if (j != t) {
            G[v[j]][v[t]] = 1;
            G[v[t]][v[j]] = 1;
          }
      v.clear();
    }
  }
  for (int j = 0; j < (int)(v).size(); ++j)
    for (int t = 0; t < (int)(v).size(); ++t)
      if (j != t) {
        G[v[j]][v[t]] = 1;
        G[v[t]][v[j]] = 1;
      }
  int nn = n / 2;
  for (int i = 0; i < (1 << nn); ++i) {
    vector<int> u;
    int ok = 1;
    for (int j = 0; j < nn; ++j)
      if ((i >> j) & 1) u.emplace_back(j);
    for (int j = 0; j < (int)(u).size() && ok; ++j)
      for (int t = 0; t < (int)(u).size() && ok; ++t)
        if (j != t && G[u[j]][u[t]]) ok = 0;
    if (ok) dp[i] = (int)(u).size();
    for (int j = 0; j < nn; ++j)
      if ((i >> j) & 1) dp[i] = max(dp[i], dp[i ^ (1 << j)]);
  }
  int ans = 0;
  for (int i = 0; i < (1 << (n - nn)); ++i) {
    vector<int> u;
    int ok = 1;
    for (int j = 0; j < (n - nn); ++j)
      if ((i >> j) & 1) u.emplace_back(j + nn);
    for (int j = 0; j < (int)(u).size() && ok; ++j)
      for (int t = 0; t < (int)(u).size() && ok; ++t)
        if (j != t && G[u[j]][u[t]]) ok = 0;
    if (!ok) continue;
    bitset<25> che;
    for (int j = 0; j < nn; ++j) che[j] = 1;
    for (int j = 0; j < (int)(u).size(); ++j)
      for (int t = 0; t < nn; ++t)
        if (G[u[j]][t]) che[t] = 0;
    ans = max(ans, (int)(u).size() + dp[(int)che.to_ulong()]);
  }
  cout << ans;
}
