#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, c = 0, count = 0;
  char k;
  string s;
  cin >> t >> k;
  while (t--) {
    c = 0;
    cin >> s;
    for (char i = '0'; i <= k; i++) {
      for (int j = 0; j <= s.size(); j++) {
        if (i == s[j]) {
          c++;
          break;
        }
      }
    }
    if (c - 1 == k - '0') count++;
  }
  cout << count << endl;
  return 0;
}
