#include <bits/stdc++.h>
using namespace std;
bool checker(int n, int k) {
  bool mark[10];
  fill(mark, mark + 10, false);
  while (n) {
    mark[n % 10] = true;
    n /= 10;
  }
  for (int i = 0; i <= k; i++)
    if (!mark[i]) return false;
  return true;
}
int main() {
  int k, n, counter = 0;
  cin >> n >> k;
  while (n--) {
    int key;
    cin >> key;
    if (checker(key, k)) counter++;
  }
  cout << counter << '\n';
  return 0;
}
