#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, cnt = 0;
  cin >> n >> k;
  vector<bool> v(10, false);
  while (n--) {
    int tmp;
    cin >> tmp;
    while (tmp) v[tmp % 10] = true, tmp /= 10;
    bool b = true;
    for (int i = 0; i <= k; i++)
      if (v[i] == false) b = false;
    if (b) cnt++;
    for (int i = 0; i <= k; i++) v[i] = false;
  }
  cout << cnt;
  return 0;
}
