#include <bits/stdc++.h>
using namespace std;
int n, k, r;
bool check(int n) {
  int r = 0;
  bool arr[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  while (n) {
    arr[n % 10] = 1;
    n /= 10;
  }
  for (int i = 0; i <= k; i++) {
    if (!arr[i]) return 0;
  }
  return true;
}
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0, act; i < n; i++) {
    scanf("%d", &act);
    if (check(act)) r++;
  }
  printf("%d\n", r);
  return 0;
}
