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