#include <bits/stdc++.h>
using namespace std;
vector<long long> masks;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  unordered_map<string, long long> table;
  long long n, m;
  cin >> n >> m;
  masks.resize(m, 0);
  vector<pair<long long, long long>> arr(n);
  long long type;
  string name;
  long long nextID = 0;
  long long mask = 0;
  for (long long i = 0; i < n; ++i) {
    cin >> type;
    if (type == 1) {
      if (mask) {
        for (long long bit = 0; bit < m; ++bit) {
          if (mask & (1LL << bit)) {
            masks[bit] |= mask & (~(1LL << bit));
          }
        }
        mask = 0;
      }
      arr[i] = {type, -1};
    } else {
      cin >> name;
      if (!table.count(name)) table[name] = nextID++;
      arr[i] = {type, table[name]};
      mask |= (1LL << table[name]);
    }
  }
  if (mask) {
    for (long long bit = 0; bit < m; ++bit) {
      if (mask & (1LL << bit)) {
        masks[bit] |= mask & (~(1LL << bit));
      }
    }
    mask = 0;
  }
  long long res = 0;
  const long long mid = m / 2;
  vector<long long> maxPeople(1LL << (mid + 1), 0);
  for (long long mask = 0; mask < (1LL << mid); ++mask) {
    long long peopleMask = 0;
    for (long long bit = 0; bit < mid; ++bit) {
      if (mask & (1LL << bit)) {
        peopleMask |= masks[bit];
      }
    }
    if ((peopleMask & mask) == 0) {
      maxPeople[peopleMask >> mid] =
          max(maxPeople[peopleMask >> mid], 1LL * __builtin_popcount(mask));
      res = max(res, maxPeople[peopleMask >> mid]);
    }
  }
  const long long otherMid = m - mid;
  for (long long mask = 0; mask < (1LL << otherMid); ++mask) {
    for (long long bit = 0; bit < otherMid; ++bit) {
      maxPeople[mask] = max(maxPeople[mask], maxPeople[mask & (~(1LL << bit))]);
    }
  }
  for (long long mask = 0; mask < (1LL << otherMid); ++mask) {
    long long peopleMask = 0;
    long long cnt = 0;
    for (long long bit = 0; bit < otherMid; ++bit) {
      if (mask & (1LL << bit)) {
        peopleMask |= masks[bit + mid];
        cnt++;
      }
    }
    if ((peopleMask & (mask << mid)) == 0) {
      res = max(res, cnt + maxPeople[(1LL << otherMid) - 1 - mask]);
    }
  }
  cout << res << '\n';
  return 0;
}
