#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int ans = 0;
  int f = (1 << (k + 1)) - 1;
  for (int i = 0; i < n; ++i) {
    int t;
    cin >> t;
    int buf = 0;
    while (t) {
      buf |= (1 << (t % 10));
      t /= 10;
    }
    if ((buf & f) == f) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
