#include <bits/stdc++.h>
using namespace std;
int n, ans, k;
int main() {
  cin >> n >> k;
  while (n--) {
    int x;
    cin >> x;
    bool ok[10];
    for (int i = 0; i < 10; i++) ok[i] = 0;
    while (x) {
      ok[x % 10] = 1;
      x /= 10;
    }
    bool Ok = 1;
    for (int i = 0; i <= k; i++) Ok *= ok[i];
    ans += Ok;
  }
  cout << ans;
  return 0;
}
