#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, num;
  cin >> n >> k;
  int count = 0;
  bool b;
  string s;
  for (int i = 0; i < n; ++i) {
    cin >> num;
    stringstream ss;
    ss << num;
    ss >> s;
    b = true;
    for (int i = 0; i <= k; ++i) {
      if (s.find(char(i + 48)) == -1) b = false;
    }
    if (b) ++count;
  }
  cout << count << endl;
}
