#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  unsigned long long n, k, x, c = 0;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> x;
    unsigned long long a[10] = {0};
    while (x) {
      a[x % 10] = 1;
      x /= 10;
    }
    for (int i = 0; i <= k; i++)
      if (a[i] == 0) {
        c++;
        break;
      }
  }
  cout << n - c;
  return 0;
}
