#include <bits/stdc++.h>
using namespace std;
int main() {
  FILE *fp, *fo;
  fp = fopen("input.txt", "r");
  fo = fopen("output.txt", "w");
  long long n, k, ans = 0, i, dig, temp, j;
  cin >> n >> k;
  for (i = 0; i < n; i++) {
    cin >> temp;
    int flag = 0, b[10] = {0};
    while (temp > 0) {
      dig = temp % 10;
      b[dig]++;
      temp = temp / 10;
    }
    for (j = 0; j <= k; j++) {
      if (b[j] == 0) {
        flag = 1;
        break;
      }
    }
    if (flag == 0) ans++;
  }
  cout << ans << endl;
  return 0;
}
