#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, len, k, ans, q, ss, b[200], c[10];
  char a[200];
  while (~scanf("%d%d", &n, &k)) {
    ans = 0;
    for (int i = 0; i < n; i++) {
      ss = 0;
      q = 0;
      memset(c, 0, sizeof(c));
      scanf("%d", &b[i]);
      while (b[i]) {
        c[b[i] % 10] = 1;
        b[i] /= 10;
      }
      for (q = 0; q <= k; q++) {
        if (c[q]) {
          ss++;
        }
      }
      if (ss == k + 1) {
        ans++;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
