#include <bits/stdc++.h>
using namespace std;
bool bz[45], can[45][45];
int num[45];
int n, m;
vector<string> name;
vector<int> st;
struct op {
  int h;
  int name;
} opnow[100004];
void build() {
  name.push_back("-1");
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    for (int j = 1; j <= m; ++j) {
      can[i][j] = true;
    }
  }
  int handle;
  string s;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &handle);
    if (handle == 1) {
      opnow[i].h = handle;
      continue;
    }
    cin >> s;
    int flag = -1;
    for (int j = 1; j < name.size(); ++j) {
      if (s == name[j]) {
        flag = j;
        break;
      }
    }
    if (flag == -1) name.push_back(s), flag = name.size() - 1;
    opnow[i].name = flag;
    opnow[i].h = handle;
  }
  for (int i = 0; i < n; ++i) {
    if (opnow[i].h == 1) {
      for (int j = 0; j < st.size(); ++j) {
        for (int k = 0; k < st.size(); ++k) {
          can[st[j]][st[k]] = can[st[j]][st[k]] = false;
        }
      }
      st.clear();
    } else
      st.push_back(opnow[i].name);
  }
  for (int j = 0; j < st.size(); ++j) {
    for (int k = 0; k < st.size(); ++k) {
      can[st[j]][st[k]] = can[st[j]][st[k]] = false;
    }
  }
  st.clear();
}
int main() {
  build();
  int ans = 0;
  for (int i = 1; i <= m; ++i) num[i] = i;
  srand(time(NULL));
  for (int tim = 1; tim <= 10000; ++tim) {
    random_shuffle(num + 1, num + 1 + m);
    int cnt = 0;
    for (int i = 1; i <= m; ++i) bz[i] = 0;
    for (int i = 1; i <= m; ++i) {
      int x = num[i];
      int c = 0;
      for (int y = 1; y <= m; ++y)
        if (can[x][y] && bz[y]) c++;
      if (c == cnt) {
        cnt++;
        bz[x] = 1;
      }
    }
    ans = max(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}
