#include <bits/stdc++.h>
using namespace std;
int contains(int n, int v) {
  while (n != 0) {
    if (n % 10 == v) return true;
    n /= 10;
  }
  return false;
}
long long n, k;
int main() {
  cin >> n >> k;
  long long t = 0;
  for (int i = 0; i < n; i++) {
    long long a;
    cin >> a;
    bool skip = false;
    for (int j = 0; j <= k; j++)
      if (!contains(a, j)) skip = true;
    if (skip) continue;
    t++;
  }
  cout << t << endl;
  return 0;
}
