#include <bits/stdc++.h>
using namespace std;
template <typename S, typename T>
ostream& operator<<(ostream& out, pair<S, T> const& p) {
  out << '(' << p.first << ", " << p.second << ')';
  return out;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T> const& v) {
  long long l = v.size();
  for (long long i = 0; i < l - 1; i++) out << v[i] << ' ';
  if (l > 0) out << v[l - 1];
  return out;
}
template <typename T>
void trace(const char* name, T&& arg1) {
  cout << name << " : " << arg1 << "\n";
}
template <typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  trace(comma + 1, args...);
}
const long long N = 1e5 + 100;
const long long M = 44;
long long n, m2;
long long g[M][M];
long long dp1[(1LL << (M / 2))], dp2[(1LL << (M / 2))];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m2;
  map<string, long long> m;
  set<string> s;
  long long curr = 0;
  for (long long i = 0; i <= n; i++) {
    long long t;
    if (i != n) {
      cin >> t;
    } else {
      t = 1;
    }
    if (t == 1) {
      if (!s.empty()) {
        for (auto j : s) {
          if (m.find(j) == m.end()) {
            m[j] = curr;
            curr++;
          }
        }
        for (auto j : s) {
          for (auto k : s) {
            long long a = m[j];
            long long b = m[k];
            g[a][b] = 1, g[b][a] = 1;
          }
        }
      }
      s.clear();
    } else {
      string temp;
      cin >> temp;
      s.insert(temp);
    }
  }
  curr = m2;
  for (long long i = 0; i < curr; i++) {
    for (long long j = 0; j < curr; j++) {
      g[i][j] = 1 - g[i][j];
    }
  }
  for (long long i = 0; i < curr; i++) {
    g[i][i] = 1;
  }
  long long s1 = curr / 2;
  long long s2 = (curr - s1);
  long long ans = 1;
  for (long long i = 0; i < s1; i++) {
    dp1[(1LL << i)] = 1;
  }
  for (long long i = 0; i < s2; i++) {
    dp2[(1LL << i)] = 1;
  }
  for (long long i = 0; i < (1LL << s1); ans = max(ans, dp2[i]), i++) {
    for (long long j = 0; j < s1; j++) {
      if ((~i >> j) & 1) {
        long long done = 0;
        for (long long k = 0; k < s1; k++) {
          if ((i >> k) & 1LL) {
            if (g[k][j] == 0) {
              done = 1;
              break;
            }
          }
        }
        if (done == 0) {
          dp1[i | (1LL << j)] = max(dp1[i | (1LL << j)], dp1[i] + 1);
        } else {
          dp1[i | (1LL << j)] = max(dp1[i | (1LL << j)], dp1[i]);
        }
      }
    }
  }
  for (long long i = 0; i < (1LL << s2); ans = max(ans, dp2[i]), i++) {
    for (long long j = 0; j < s2; j++) {
      if ((~i >> j) & 1) {
        long long done = 0;
        for (long long k = 0; k < s2; k++) {
          if ((i >> k) & 1LL) {
            if (g[k + s1][j + s1] == 0) {
              done = 1;
              break;
            }
          }
        }
        if (done == 0) {
          dp2[i | (1LL << j)] = max(dp2[i | (1LL << j)], dp2[i] + 1);
        } else {
          dp2[i | (1LL << j)] = max(dp2[i | (1LL << j)], dp2[i]);
        }
      }
    }
  }
  for (long long i = 0; i < (1LL << s1); i++) {
    if (dp1[i] > 0) {
      long long to_add = (1LL << s2) - 1;
      for (long long j = 0; j < s1; j++) {
        if ((i >> j) & 1LL) {
          for (long long k = 0; k < s2; k++) {
            if (g[j][s1 + k] == 0) {
              long long cc = (1LL << s2) - 1;
              cc ^= (1LL << k);
              to_add &= cc;
            }
          }
        }
      }
      ans = max(ans, dp1[i] + dp2[to_add]);
    }
  }
  cout << ans << "\n";
}
