#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, j, ans = 0, arr1[10], i, f, d, k1;
  long long arr[100];
  cin >> n >> k;
  for (i = 0; i < n; i++) cin >> arr[i];
  for (i = 0; i < n; i++) {
    k1 = arr[i];
    f = 0;
    memset(arr1, 0, sizeof(arr1));
    while (k1 != 0) {
      d = k1 % 10;
      arr1[d] += 1;
      k1 /= 10;
    }
    for (j = 0; j <= k; j++)
      if (arr1[j] == 0) f = 1;
    if (f == 0) ++ans;
  }
  cout << ans;
  return 0;
}
