#include <bits/stdc++.h>
using namespace std;
int n, k, i, x, j, v[10], nr, ok;
int main() {
  cin >> n;
  cin >> k;
  for (i = 1; i <= n; i++) {
    cin >> x;
    for (j = 0; j <= 9; j++) v[j] = 0;
    do {
      v[x % 10] = 1;
      x /= 10;
    } while (x);
    ok = 1;
    for (j = 0; j <= k; j++) {
      if (v[j] == 0) ok = 0;
    }
    if (ok == 1) nr++;
  }
  cout << nr;
  return 0;
}
