#include <bits/stdc++.h>
using namespace std;
map<string, int> mmp;
vector<int> temp;
bool a[50][50];
int dp1[(1 << 20)];
bool check1[(1 << 20)], check2[(1 << 20)];
int cal(int mask, int m1, int m2) {
  int x = 0;
  for (int i = 0; i < m1; i++) {
    bool f = 1;
    for (int j = 0; j < m2; j++) {
      if (mask & (1 << j) && a[i][j + m1]) {
        f = 0;
      }
    }
    if (f) {
      x += (1 << i);
    }
  }
  return __builtin_popcount(mask) + dp1[x];
}
int main() {
  int i, j, t, x, y, k, n, m;
  string c;
  scanf("%d%d", &n, &m);
  k = 0;
  for (i = 0; i < n; i++) {
    scanf("%d", &x);
    if (x == 1) {
      for (x = 0; x < (int)temp.size(); x++) {
        for (y = x + 1; y < (int)temp.size(); y++) {
          a[temp[x]][temp[y]] = 1;
          a[temp[y]][temp[x]] = 1;
        }
      }
      temp.clear();
    } else {
      cin >> c;
      if (mmp.count(c)) {
        temp.push_back(mmp[c]);
      } else {
        mmp[c] = k++;
        temp.push_back(mmp[c]);
      }
    }
  }
  for (x = 0; x < (int)temp.size(); x++) {
    for (y = x + 1; y < (int)temp.size(); y++) {
      a[temp[x]][temp[y]] = 1;
      a[temp[y]][temp[x]] = 1;
    }
  }
  int m1 = m / 2, m2 = m - m1;
  for (i = 0; i < (1 << m1); i++) {
    bool f = 1;
    for (x = 0; x < m1; x++) {
      for (y = x + 1; y < m1; y++) {
        if ((i & (1 << x)) && (i & (1 << y)) && a[x][y]) {
          f = 0;
        }
      }
    }
    check1[i] = f;
    if (f) {
      dp1[i] = __builtin_popcount(i);
    }
  }
  for (i = 0; i < (1 << m2); i++) {
    bool f = 1;
    for (x = 0; x < m2; x++) {
      for (y = x + 1; y < m2; y++) {
        if ((i & (1 << x)) && (i & (1 << y)) && a[x + m1][y + m1]) {
          f = 0;
        }
      }
    }
    check2[i] = f;
  }
  for (j = 0; j < m1; j++) {
    for (i = 0; i < (1 << m1); i++) {
      if (i & (1 << j)) {
        dp1[i] = max(dp1[i], dp1[(i ^ (1 << j))]);
      }
    }
  }
  int ans = 1;
  for (i = 0; i < (1 << m2); i++) {
    if (check2[i]) {
      ans = max(ans, cal(i, m1, m2));
    }
  }
  cout << ans << endl;
  ;
}
