#include <bits/stdc++.h>
using namespace std;
int n, k;
bool check(int x) {
  int s[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  int t;
  while (x > 0) {
    t = x % 10;
    if (t <= k) s[t]++;
    x /= 10;
  }
  for (int i = 0; i <= k; i++) {
    if (s[i] == 0) return false;
  }
  return true;
}
int main() {
  cin >> n >> k;
  int res = 0;
  int t;
  for (int i = 0; i < n; i++) {
    cin >> t;
    if (check(t)) res++;
  }
  cout << res;
  return 0;
}
