#include <bits/stdc++.h>
using namespace std;
bool checkGOOD(int num, int k) {
  int arr[10] = {0};
  while (num) {
    int p = num % 10;
    num = num / 10;
    arr[p] = 1;
  }
  for (int i = 0; i <= k; i++) {
    if (arr[i] != 1) {
      return false;
    }
  }
  return true;
}
int main() {
  int c = 0;
  int n, k, x;
  cin >> n >> k;
  while (n--) {
    cin >> x;
    if (checkGOOD(x, k)) {
      c++;
    }
  }
  cout << c;
  return 0;
}
