#include <bits/stdc++.h>
using namespace std;
const int maxn = 200050;
int bad[40][40];
int dp[(1 << 20) + 5];
int graph[40];
int between[40];
int main() {
  std::ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  map<string, int> id;
  set<int> cur;
  for (int i = 0; i < n; ++i) {
    int t;
    cin >> t;
    if (t == 2) {
      string x;
      cin >> x;
      if (!id.count(x)) {
        int z = (int)id.size();
        id[x] = z;
      }
      int j = id[x];
      for (int k : cur) {
        bad[k][j] = bad[j][k] = true;
      }
      cur.insert(j);
    } else {
      cur.clear();
    }
  }
  if (m == 1) {
    cout << 1 << endl;
    return 0;
  }
  int a = m / 2;
  int b = m - a;
  for (int i = 0; i < a; ++i) {
    for (int j = 0; j < a; ++j) {
      if (i != j && bad[i][j]) {
        graph[i] |= 1 << j;
      }
    }
  }
  for (int i = 0; i < b; ++i) {
    for (int j = 0; j < b; ++j) {
      if (i != j && bad[i + a][j + a]) {
        graph[i + a] |= 1 << j;
      }
    }
  }
  for (int i = 0; i < a; ++i) {
    for (int j = 0; j < b; ++j) {
      if (bad[j + a][i]) {
        between[j] |= 1 << i;
      }
    }
  }
  for (int i = 0; i < (1 << a); ++i) {
    bool ok = true;
    for (int j = 0; j < a; ++j) {
      if (i >> j & 1) {
        dp[i] = max(dp[i], dp[i ^ (1 << j)]);
        if ((graph[j] & i) != 0) {
          ok = false;
        }
      }
    }
    if (ok) {
      dp[i] = __builtin_popcount(i);
    }
  }
  int result = 0;
  for (int i = 0; i < (1 << b); ++i) {
    bool ok = true;
    int mask = 0;
    for (int j = 0; j < b; ++j) {
      if (i >> j & 1) {
        if ((graph[j + a] & i) != 0) {
          ok = false;
        }
        mask |= between[j];
      }
    }
    if (ok) {
      mask ^= (1 << a) - 1;
      result = max(result, __builtin_popcount(i) + dp[mask]);
    }
  }
  cout << result << endl;
  return 0;
}
