#include <bits/stdc++.h>
using namespace std;
int n, k, num, check, res = 0;
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> num;
    check = 0;
    int digit[10] = {0};
    while (num > 0) {
      digit[num % 10]++;
      num /= 10;
    }
    for (int i = 0; i < k + 1; i++)
      if (digit[i] < 1) check = 1;
    if (!check) res++;
  }
  cout << res;
  return 0;
}
