#include <bits/stdc++.h>
using namespace std;
const int mod = int(1e9 + 7);
const double PI = acos(-1.0);
int n, k, a, ans, b[10];
int g(int x) {
  for (int i = 0; i <= 9; i++) b[i] = 0;
  while (x > 0) {
    b[x % 10]++;
    x /= 10;
  }
  for (int i = 0; i <= k; i++)
    if (b[i] == 0) return 0;
  return 1;
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (g(a)) ans++;
  }
  cout << ans;
  return 0;
}
