#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, ans = 0;
  cin >> n >> k;
  set<int> sett;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    sett.clear();
    while (a != 0) {
      if (a % 10 <= k) sett.insert(a % 10);
      a /= 10;
    }
    if (sett.size() == k + 1) ans++;
  }
  cout << ans;
  return 0;
}
