//@author->.....future_me......//

//..............Learning.........//

import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.BigInteger;

public class B {

  // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Fast IO <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< //

  static class FastReader {
    BufferedReader  br;
    StringTokenizer st;

    public FastReader() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }
  }

  // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Code Starts <<<<<<<<<<<<<<<<<<<<<<<<<<<<< //

  static FastReader  sc  = new FastReader();
  static PrintWriter out = new PrintWriter(System.out);

  static int            mod = 1000000007;
  static ArrayList<dis> aa;
  static int            dis[][];

  public static void main(String[] args) throws Exception {
//    try {

    int t = sc.nextInt();
    while (t-- > 0)
      B.go();
    out.flush();
//    } catch (Exception e) {
//      return;
//    }
  }

  static void go() {
    int n = sc.nextInt();
    int k = sc.nextInt();
    int a[] = new int[n];

    HashSet<Integer> set = new HashSet<>();
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();

      set.add(a[i]);
    }

    int ans = Integer.MAX_VALUE;
    for (int j : set) {

      int i = 0;
      int c = 0;

      while (i < n) {
        int maxx = 0;
        int count = 0;
        while (i < n && a[i] == j) {
          i++;
        }

        while (i < n && maxx < k && a[i] != j) {

          if (count == 0) {
            c++;
            count++;
          }
          maxx++;

          i++;
        }

      }

      ans = Math.min(ans, c);
    }
    System.out.println(ans);
  }

  static int solve(int a[], int l, int r) {
    if (r == l) {
      return 1;
    }
    int max = 0;
    for (int i = l; i <= r; i++) {
      max = Math.max(dis[l][i], max);
    }

    return max;
  }

  // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Code Ends <<<<<<<<<<<<<<<<<<<<<<<<<<<<< //

  static void sort(long[] a) {
    ArrayList<Long> aa = new ArrayList<>();
    for (long i : a) {
      aa.add(i);
    }
    Collections.sort(aa);
    for (int i = 0; i < a.length; i++)
      a[i] = aa.get(i);
  }

  static long pow(long x, long y) {
    long res = 1l;
    while (y != 0) {
      if (y % 2 == 1) {
        res = x * res;
      }
      y /= 2;
      x = x * x;
    }
    return res;
  }

}

class dis {
  int x;
  int y;

  dis(int x, int y) {
    this.x = x;
    this.y = y;
  }
}


//@author->.....future_me......//

//..............Learning.........//

import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.BigInteger;

public class B {

  // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Fast IO <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< //

  static class FastReader {
    BufferedReader  br;
    StringTokenizer st;

    public FastReader() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }
  }

  // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Code Starts <<<<<<<<<<<<<<<<<<<<<<<<<<<<< //

  static FastReader  sc  = new FastReader();
  static PrintWriter out = new PrintWriter(System.out);

  static int            mod = 1000000007;
  static ArrayList<dis> aa;
  static int            dis[][];

  public static void main(String[] args) throws Exception {
//    try {

    int t = sc.nextInt();
    while (t-- > 0)
      B.go();

//    } catch (Exception e) {
//      return;
//    }
  }

  static void go() {
    int n = sc.nextInt();
    int k = sc.nextInt();
    int a[] = new int[n];

    LinkedHashSet<Integer> set = new LinkedHashSet<>();
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();

      set.add(a[i]);
    }

    int ans = Integer.MAX_VALUE;
    for (int j = 1; j <= 100; j++) {

      int i = 0;
      int c = 0;
      int s = j;
      while (i < n) {
        int maxx = 0;
        int count = 0;
        if (a[i] == s) {
          i++;
        }
        while (i < n && maxx < k && a[i] != s) {
          maxx++;
          i++;
          count++;
        }
        if (count != 0) {
          c++;
        }
      }

      ans = Math.min(ans, c);
    }
    System.out.println(ans);
  }

  static int solve(int a[], int l, int r) {
    if (r == l) {
      return 1;
    }
    int max = 0;
    for (int i = l; i <= r; i++) {
      max = Math.max(dis[l][i], max);
    }

    return max;
  }

  // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Code Ends <<<<<<<<<<<<<<<<<<<<<<<<<<<<< //

  static void sort(long[] a) {
    ArrayList<Long> aa = new ArrayList<>();
    for (long i : a) {
      aa.add(i);
    }
    Collections.sort(aa);
    for (int i = 0; i < a.length; i++)
      a[i] = aa.get(i);
  }

  static long pow(long x, long y) {
    long res = 1l;
    while (y != 0) {
      if (y % 2 == 1) {
        res = x * res;
      }
      y /= 2;
      x = x * x;
    }
    return res;
  }

}

class dis {
  int x;
  int y;

  dis(int x, int y) {
    this.x = x;
    this.y = y;
  }
}


//@author->.....future_me......//

//..............Learning.........//

import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.BigInteger;

public class B {

  // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Fast IO <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< //

  static class FastReader {
    BufferedReader  br;
    StringTokenizer st;

    public FastReader() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }
  }

  // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Code Starts <<<<<<<<<<<<<<<<<<<<<<<<<<<<< //

  static FastReader  sc  = new FastReader();
  static PrintWriter out = new PrintWriter(System.out);

  static int            mod = 1000000007;
  static ArrayList<dis> aa;
  static int            dis[][];

  public static void main(String[] args) throws Exception {
//    try {

    int t = sc.nextInt();
    while (t-- > 0)
      B.go();
    out.flush();
//    } catch (Exception e) {
//      return;
//    }
  }

  static void go() {
    int n = sc.nextInt();
    int k = sc.nextInt();
    int a[] = new int[n];

    LinkedHashSet<Integer> set = new LinkedHashSet<>();
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();

      set.add(a[i]);
    }

    int ans = Integer.MAX_VALUE;
    for (int j : set) {

      int i = 0;
      int c = 0;
      int s = j;
      while (i < n) {
        int maxx = 0;
        int count = 0;
        if (a[i] == s) {
          i++;
        }
        while (i < n && maxx < k && a[i] != s) {
          maxx++;
          i++;
          count++;
        }
        if (count != 0) {
          c++;
        }
      }

      ans = Math.min(ans, c);
    }
    System.out.println(ans);
  }

  static int solve(int a[], int l, int r) {
    if (r == l) {
      return 1;
    }
    int max = 0;
    for (int i = l; i <= r; i++) {
      max = Math.max(dis[l][i], max);
    }

    return max;
  }

  // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Code Ends <<<<<<<<<<<<<<<<<<<<<<<<<<<<< //

  static void sort(long[] a) {
    ArrayList<Long> aa = new ArrayList<>();
    for (long i : a) {
      aa.add(i);
    }
    Collections.sort(aa);
    for (int i = 0; i < a.length; i++)
      a[i] = aa.get(i);
  }

  static long pow(long x, long y) {
    long res = 1l;
    while (y != 0) {
      if (y % 2 == 1) {
        res = x * res;
      }
      y /= 2;
      x = x * x;
    }
    return res;
  }

}

class dis {
  int x;
  int y;

  dis(int x, int y) {
    this.x = x;
    this.y = y;
  }
}


//@author->.....future_me......//

//..............Learning.........//

import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.BigInteger;

public class B {

  // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Fast IO <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< //

  static class FastReader {
    BufferedReader  br;
    StringTokenizer st;

    public FastReader() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }
  }

  // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Code Starts <<<<<<<<<<<<<<<<<<<<<<<<<<<<< //

  static FastReader  sc  = new FastReader();
  static PrintWriter out = new PrintWriter(System.out);

  static int            mod = 1000000007;
  static ArrayList<dis> aa;
  static int            dis[][];

  public static void main(String[] args) throws Exception {
//    try {

    int t = sc.nextInt();
    while (t-- > 0)
      B.go();
    out.flush();
//    } catch (Exception e) {
//      return;
//    }
  }

  static void go() {
    int n = sc.nextInt();
    int k = sc.nextInt();
    int a[] = new int[n];

    LinkedHashSet<Integer> set = new LinkedHashSet<>();
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();

      set.add(a[i]);
    }

    int ans = Integer.MAX_VALUE;
    for (int j : set) {

      int i = 0;
      int c = 0;
      int s = j;
      while (i < n) {
        int maxx = 0;
        int count = 0;
        while (i < n && a[i] == s) {
          i++;
        }

        while (i < n && maxx < k && a[i] != s) {

          if (count == 0) {
            c++;
            count++;
          }
          maxx++;

          i++;
        }

      }

      ans = Math.min(ans, c);
    }
    System.out.println(ans);
  }

  static int solve(int a[], int l, int r) {
    if (r == l) {
      return 1;
    }
    int max = 0;
    for (int i = l; i <= r; i++) {
      max = Math.max(dis[l][i], max);
    }

    return max;
  }

  // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Code Ends <<<<<<<<<<<<<<<<<<<<<<<<<<<<< //

  static void sort(long[] a) {
    ArrayList<Long> aa = new ArrayList<>();
    for (long i : a) {
      aa.add(i);
    }
    Collections.sort(aa);
    for (int i = 0; i < a.length; i++)
      a[i] = aa.get(i);
  }

  static long pow(long x, long y) {
    long res = 1l;
    while (y != 0) {
      if (y % 2 == 1) {
        res = x * res;
      }
      y /= 2;
      x = x * x;
    }
    return res;
  }

}

class dis {
  int x;
  int y;

  dis(int x, int y) {
    this.x = x;
    this.y = y;
  }
}


//package codeforces.problem.nov;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

/*
https://codeforces.com/problemset/problem/1457/B
3
10 2
1 1 2 2 1 1 2 2 2 1
7 1
1 2 3 4 5 6 7
10 3
1 3 3 3 3 1 2 1 3 3
 */
public class TaskB_1457 {

    static void solve() {
        int n = FS.nextInt();
        int k = FS.nextInt();
        int[] c = FS.readArray(n);

        int ans = Integer.MAX_VALUE;
        for (int i = 1; i <= 100; i++) {
            int cur = 0;
            for (int j = 0; j < n; j++) {
                if (c[j] != i) {
                    j += k - 1;
                    cur++;
                }
            }
            ans = Math.min(cur, ans);
        }

        FS.pt.println(ans);
    }

    public static void main(String[] args) {
        int T = FS.nextInt();
        for (int tt = 0; tt < T; tt++) {
            solve();
        }
        FS.pt.close();
    }

    static class FS {
        private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        private static StringTokenizer st = new StringTokenizer("");
        static PrintWriter pt = new PrintWriter(System.out);

        static String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        static int nextInt() {
            return Integer.parseInt(next());
        }

        static int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        static int[][] read2Array(int n, int m) {
            int[][] a = new int[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    a[i][j] = nextInt();
                }
            }
            return a;
        }

        static long[][] read2ArrayL(int n, int m) {
            long[][] a = new long[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    a[i][j] = nextInt();
                }
            }
            return a;
        }

        void printArr(long[] arr) {
            for (long value : arr) {
                pt.print(value);
                pt.print(" ");
            }
            pt.println();
        }

        static long[] readArrayL(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        static void printArr(int[] arr) {
            for (int value : arr) {
                pt.print(value);
                pt.print(" ");
            }
            pt.println();
        }

        static void printArrL(int[] arr) {
            for (int value : arr) {
                pt.print(value);
                pt.print(" ");
            }
            pt.println();
        }

        static void print2Arr(int[][] arr, int n, int m) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    pt.print(arr[i][j]);
                    pt.print(" ");
                }
                pt.println();
            }
            pt.println();
        }

        static void print2Arr(long[][] arr, int n, int m) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    pt.print(arr[i][j]);
                    pt.print(" ");
                }
                pt.println();
            }
            pt.println();
        }

        static List<Long> readListLong(int n) {
            List<Long> list = new ArrayList<>(n);
            for (int i = 0; i < n; i++) {
                list.add(nextLong());
            }
            return list;
        }

        static List<Integer> readListInt(int n) {
            List<Integer> list = new ArrayList<>(n);
            for (int i = 0; i < n; i++) {
                list.add(nextInt());
            }
            return list;
        }

        static <T> void printList(List<T> list) {
            for (T value : list) {
                pt.print(value);
                pt.print(" ");
            }
            pt.println();
        }

        static void close() {
            pt.close();
        }

        static long nextLong() {
            return Long.parseLong(next());
        }
    }

    static class Pair<T, K> {
        T first;
        K second;

        public Pair(T first, K second) {
            this.first = first;
            this.second = second;
        }
    }
}


//package codeforces.problem.nov;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

/*
https://codeforces.com/problemset/problem/?/?
 */
public class TaskB_1457 {

    static void solve() {
        int n = FS.nextInt();
        int k = FS.nextInt();
        int[] a = new int[n];
        int[] col = new int[101];

        for (int i = 0; i < n; i++) {
            int c = FS.nextInt();
            col[c]++;
            a[i] = c;
        }

        int max = Integer.MIN_VALUE;
        int maxIdx = 0;
        for (int i = 0; i < col.length; i++) {
            max = Math.max(max, col[i]);
            if (max == col[i]) {
                maxIdx = i;
            }
        }

        int sum = 0;
        for (int i = 0; i < n;) {
            if (a[i] != maxIdx) {
                int prev = i;
                while (i < n && a[i] != maxIdx) {
                    i++;
                }
                sum += Math.ceil( ((double) i - prev) / k);
            } else {
                i++;
            }
        }
        FS.pt.println(sum);
    }

    public static void main(String[] args) {
        int T = FS.nextInt();
        for (int tt = 0; tt < T; tt++) {
            solve();
        }
        FS.pt.close();
    }

    static class FS {
        private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        private static StringTokenizer st = new StringTokenizer("");
        static PrintWriter pt = new PrintWriter(System.out);

        static String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        static int nextInt() {
            return Integer.parseInt(next());
        }

        static int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        static int[][] read2Array(int n, int m) {
            int[][] a = new int[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    a[i][j] = nextInt();
                }
            }
            return a;
        }

        static long[][] read2ArrayL(int n, int m) {
            long[][] a = new long[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    a[i][j] = nextInt();
                }
            }
            return a;
        }

        void printArr(long[] arr) {
            for (long value : arr) {
                pt.print(value);
                pt.print(" ");
            }
            pt.println();
        }

        static long[] readArrayL(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        static void printArr(int[] arr) {
            for (int value : arr) {
                pt.print(value);
                pt.print(" ");
            }
            pt.println();
        }

        static void printArrL(int[] arr) {
            for (int value : arr) {
                pt.print(value);
                pt.print(" ");
            }
            pt.println();
        }

        static void print2Arr(int[][] arr, int n, int m) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    pt.print(arr[i][j]);
                    pt.print(" ");
                }
                pt.println();
            }
            pt.println();
        }

        static void print2Arr(long[][] arr, int n, int m) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    pt.print(arr[i][j]);
                    pt.print(" ");
                }
                pt.println();
            }
            pt.println();
        }

        static List<Long> readListLong(int n) {
            List<Long> list = new ArrayList<>(n);
            for (int i = 0; i < n; i++) {
                list.add(nextLong());
            }
            return list;
        }

        static List<Integer> readListInt(int n) {
            List<Integer> list = new ArrayList<>(n);
            for (int i = 0; i < n; i++) {
                list.add(nextInt());
            }
            return list;
        }

        static <T> void printList(List<T> list) {
            for (T value : list) {
                pt.print(value);
                pt.print(" ");
            }
            pt.println();
        }

        static void close() {
            pt.close();
        }

        static long nextLong() {
            return Long.parseLong(next());
        }
    }

    static class Pair<T, K> {
        T first;
        K second;

        public Pair(T first, K second) {
            this.first = first;
            this.second = second;
        }
    }
}


#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {

	long long n, k, c{ 0 };
	string val;
	bool d;
	cin >> n >> k;

	while (n--){
		cin >> val;
		d = false;
		char e = '0';
		sort(val.begin(), val.end());
		//cout << val;
		//cout << "\t" << val << endl;
		for (size_t i = 0; i <= k; i++) {
			if (val[i] == val[i + 1])
				continue;
			else if (val[i] != e) {
				//cout << val[i] << "\t" << e << endl;
				d = true;
				e++;
				break;
			}
			e++;
		}
		if (!d)
			c++;
	}

	cout << c << endl;

//	system("pause");
}


#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {

	long long n, k, c{ 0 };
	string val;
	bool d;
	cin >> n >> k;

	while (n--){
		cin >> val;
		d = false;
		char e = '0';
		sort(val.begin(), val.end());
		//cout << val;
		//cout << "\t" << val << endl;
		for (size_t i = 0; i <= k; i++, e++) {
			if (val[i] == val[i + 1])
				continue;
			else if (val[i] != e) {
				//cout << val[i] << "\t" << val[i + 1] << endl;
				d = true;
				break;
			}
		}
		if (!d)
			c++;
	}

	cout << c << endl;

//	system("pause");
}


#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {

	int n, k, c{ 0 };
	string val;
	bool d;
	cin >> n >> k;

	while (n--){
		cin >> val;
		d = false;
		sort(val.begin(), val.end());
		//cout << val << endl;
		for (size_t i = 0; i < k; i++) {

			if (val[i] + 1 != val[i + 1]) {
				d = true;
				break;
			}
		}
		if (!d)
			c++;
	}

	cout << c << endl;

//	system("pause");
}


#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {

	long long n, k, c{ 0 };
	string val;
	bool d;
	cin >> n >> k;

	while (n--){
		cin >> val;
		d = false;
		sort(val.begin(), val.end());
		//cout << val << endl;
		for (size_t i = 0; i < k; i++) {

			if (val[i] + 1 != val[i + 1]) {
				d = true;
				break;
			}
		}
		if (!d)
			c++;
	}

	cout << c << endl;

//	system("pause");
}


#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {

	long long n, c{ 0 }, m;
	string val;
	bool d;
	char s;
	cin >> n >> s;
	while (n--) {
		m = 0;
		cin >> val;
		sort(val.begin(), val.end());
		d = false;
		for (size_t i = 48; i <= (int)s - 1; i++, m++){
			if (val[m] == val[m + 1])
				continue;
			else if (val[m] - 1 != i)
				d = true;
		}
		if (!d)
			c++;
	}

	cout << c << endl;

//		system("pause");
}


#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {

	long long n, c{ 0 }, m;
	string val;
	bool d;
	char s;
	cin >> n >> s;
	while (n--) {
		m = 0;
		cin >> val;
		d = false;
		for (size_t i = 48; i <= (int)s - 1; i++, m++){
			if (val[m] == val[m + 1])
				continue;
			else if (val[m] - 1 != i)
				d = true;
		}
		if (!d)
			c++;
	}

	cout << c << endl;

//		system("pause");
}


#include<bits/stdc++.h>
#include <sstream>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define ull unsigned long long int
#define ll long long
#define all(a) a.begin(),a.end()
using namespace std;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
ll MD=1000000007;
ll md=998244353;
const ll INF=1e18L+5;
ll exp(ll a,ll b){ll r=1ll;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}//put b as bmod(md-1) if md is prime}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll pow_2(ll a, ll b)
{
    ll res = 1;
    while(b)
    {
        if(b & 1)
            res = (res * a);
        a = (a * a);
        b >>= 1;
    }

    return res;
}
bool isPrime(ll a)
{
    for(ll i=3; (i*i)<=a; i+=2)
    {
        if( (a%i)==0 )
            return false;
    }
    if( ( a!=2 ) && ( (a%2)==0 ) )
        return false;
    if( a==1 )
        return false;

    return true;
}
string decToBinary(int n)
{
    // Size of an integer is assumed to be 32 bits
    string s="";
    for (int i = 31; i >= 0; i--) {
        int k = n >> i;
        if (k & 1)
            //cout << "1";
            s=s+"1";
        else
            //cout << "0";
            s=s+"0";
    }
    return s;
}
int decimalToBinary(int N)
{

    // To store the binary number
    ull B_Number = 0;
    int cnt = 0;
    while (N != 0) {
        int rem = N % 2;
        ull c = pow(10, cnt);
        B_Number += rem * c;
        N /= 2;

        // Count used to store exponent value
        cnt++;
    }

    return B_Number;
}
string toString(ull num)
{
    std::string number;
    std::stringstream strstream;
    strstream << num;
    strstream >> number;
    return number;
}
const double PI = acos(-1);
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    ll arr[n];
    for(int i=0;i<n;i++)cin>>arr[i];
    int counter=0;
    for(int i=0;i<n;i++)
    {
        vector<int> st;
        int x=arr[i];
        while(x>0)
        {
            st.PB(x%10);
            x/=10;
        }
        sort(all(st));
        bool boo=true;
        for(int i=0;i<=k;i++)
        {
            if(st[i]!=i){boo=false;break;}
        }
        if(boo)counter++;
    }
    cout<<counter<<endl;
return 0;}


#include<bits/stdc++.h>
#include <sstream>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define ull unsigned long long int
#define ll long long
#define all(a) a.begin(),a.end()
using namespace std;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
ll MD=1000000007;
ll md=998244353;
const ll INF=1e18L+5;
ll exp(ll a,ll b){ll r=1ll;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}//put b as bmod(md-1) if md is prime}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll pow_2(ll a, ll b)
{
    ll res = 1;
    while(b)
    {
        if(b & 1)
            res = (res * a);
        a = (a * a);
        b >>= 1;
    }

    return res;
}
bool isPrime(ll a)
{
    for(ll i=3; (i*i)<=a; i+=2)
    {
        if( (a%i)==0 )
            return false;
    }
    if( ( a!=2 ) && ( (a%2)==0 ) )
        return false;
    if( a==1 )
        return false;

    return true;
}
string decToBinary(int n)
{
    // Size of an integer is assumed to be 32 bits
    string s="";
    for (int i = 31; i >= 0; i--) {
        int k = n >> i;
        if (k & 1)
            //cout << "1";
            s=s+"1";
        else
            //cout << "0";
            s=s+"0";
    }
    return s;
}
int decimalToBinary(int N)
{

    // To store the binary number
    ull B_Number = 0;
    int cnt = 0;
    while (N != 0) {
        int rem = N % 2;
        ull c = pow(10, cnt);
        B_Number += rem * c;
        N /= 2;

        // Count used to store exponent value
        cnt++;
    }

    return B_Number;
}
string toString(ull num)
{
    std::string number;
    std::stringstream strstream;
    strstream << num;
    strstream >> number;
    return number;
}
const double PI = acos(-1);
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    ll arr[n];
    for(int i=0;i<n;i++)cin>>arr[i];
    int counter=0;
    for(int i=0;i<n;i++)
    {
        set<int> st;
        int x=arr[i];
        while(x>0)
        {
            st.insert(x%10);
            x/=10;
        }
        int current=0;
        bool boo=true;
        if(st.size()<k+1)boo=false;
        for(auto it:st)
        {
            if(it != current){boo=false;break;}
            if(current==k)break;
            current++;
        }
        if(boo)counter++;
    }
    cout<<counter<<endl;
return 0;}


#include<bits/stdc++.h>
#include <sstream>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define ull unsigned long long int
#define ll long long
#define all(a) a.begin(),a.end()
using namespace std;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
ll MD=1000000007;
ll md=998244353;
const ll INF=1e18L+5;
ll exp(ll a,ll b){ll r=1ll;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}//put b as bmod(md-1) if md is prime}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll pow_2(ll a, ll b)
{
    ll res = 1;
    while(b)
    {
        if(b & 1)
            res = (res * a);
        a = (a * a);
        b >>= 1;
    }

    return res;
}
bool isPrime(ll a)
{
    for(ll i=3; (i*i)<=a; i+=2)
    {
        if( (a%i)==0 )
            return false;
    }
    if( ( a!=2 ) && ( (a%2)==0 ) )
        return false;
    if( a==1 )
        return false;

    return true;
}
string decToBinary(int n)
{
    // Size of an integer is assumed to be 32 bits
    string s="";
    for (int i = 31; i >= 0; i--) {
        int k = n >> i;
        if (k & 1)
            //cout << "1";
            s=s+"1";
        else
            //cout << "0";
            s=s+"0";
    }
    return s;
}
int decimalToBinary(int N)
{

    // To store the binary number
    ull B_Number = 0;
    int cnt = 0;
    while (N != 0) {
        int rem = N % 2;
        ull c = pow(10, cnt);
        B_Number += rem * c;
        N /= 2;

        // Count used to store exponent value
        cnt++;
    }

    return B_Number;
}
string toString(ull num)
{
    std::string number;
    std::stringstream strstream;
    strstream << num;
    strstream >> number;
    return number;
}
const double PI = acos(-1);
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    ll arr[n];
    for(int i=0;i<n;i++)cin>>arr[i];
    int counter=0;
    for(int i=0;i<n;i++)
    {
        set<int> st;
        int x=arr[i];
        while(x>0)
        {
            st.insert(x%10);
            x/=10;
        }
        int current=0;
        bool boo=true;
        for(auto it:st)
        {
            if(*it != current){boo=false;break;}
            if(current==k)break;
            current++;
        }
        if(boo)counter++;
    }
    cout<<counter<<endl;
return 0;}


#include<bits/stdc++.h>
#include <sstream>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define ull unsigned long long int
#define ll long long
#define all(a) a.begin(),a.end()
using namespace std;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
ll MD=1000000007;
ll md=998244353;
const ll INF=1e18L+5;
ll exp(ll a,ll b){ll r=1ll;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}//put b as bmod(md-1) if md is prime}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll pow_2(ll a, ll b)
{
    ll res = 1;
    while(b)
    {
        if(b & 1)
            res = (res * a);
        a = (a * a);
        b >>= 1;
    }

    return res;
}
bool isPrime(ll a)
{
    for(ll i=3; (i*i)<=a; i+=2)
    {
        if( (a%i)==0 )
            return false;
    }
    if( ( a!=2 ) && ( (a%2)==0 ) )
        return false;
    if( a==1 )
        return false;

    return true;
}
string decToBinary(int n)
{
    // Size of an integer is assumed to be 32 bits
    string s="";
    for (int i = 31; i >= 0; i--) {
        int k = n >> i;
        if (k & 1)
            //cout << "1";
            s=s+"1";
        else
            //cout << "0";
            s=s+"0";
    }
    return s;
}
int decimalToBinary(int N)
{

    // To store the binary number
    ull B_Number = 0;
    int cnt = 0;
    while (N != 0) {
        int rem = N % 2;
        ull c = pow(10, cnt);
        B_Number += rem * c;
        N /= 2;

        // Count used to store exponent value
        cnt++;
    }

    return B_Number;
}
string toString(ull num)
{
    std::string number;
    std::stringstream strstream;
    strstream << num;
    strstream >> number;
    return number;
}
const double PI = acos(-1);
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    ll arr[n];
    for(int i=0;i<n;i++)cin>>arr[i];
    int counter=0;
    for(int i=0;i<n;i++)
    {
        set<int> st;
        int x=arr[i];
        while(x>0)
        {
            st.push(x%10);
            x/=10;
        }
        if(st.size()==k+1 && *st.begin()==0 && *--st.end()==k)counter++;
    }
    cout<<counter<<endl;
return 0;}


#include<bits/stdc++.h>
#include <sstream>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define ull unsigned long long int
#define ll long long
#define all(a) a.begin(),a.end()
using namespace std;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
ll MD=1000000007;
ll md=998244353;
const ll INF=1e18L+5;
ll exp(ll a,ll b){ll r=1ll;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}//put b as bmod(md-1) if md is prime}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll pow_2(ll a, ll b)
{
    ll res = 1;
    while(b)
    {
        if(b & 1)
            res = (res * a);
        a = (a * a);
        b >>= 1;
    }

    return res;
}
bool isPrime(ll a)
{
    for(ll i=3; (i*i)<=a; i+=2)
    {
        if( (a%i)==0 )
            return false;
    }
    if( ( a!=2 ) && ( (a%2)==0 ) )
        return false;
    if( a==1 )
        return false;

    return true;
}
string decToBinary(int n)
{
    // Size of an integer is assumed to be 32 bits
    string s="";
    for (int i = 31; i >= 0; i--) {
        int k = n >> i;
        if (k & 1)
            //cout << "1";
            s=s+"1";
        else
            //cout << "0";
            s=s+"0";
    }
    return s;
}
int decimalToBinary(int N)
{

    // To store the binary number
    ull B_Number = 0;
    int cnt = 0;
    while (N != 0) {
        int rem = N % 2;
        ull c = pow(10, cnt);
        B_Number += rem * c;
        N /= 2;

        // Count used to store exponent value
        cnt++;
    }

    return B_Number;
}
string toString(ull num)
{
    std::string number;
    std::stringstream strstream;
    strstream << num;
    strstream >> number;
    return number;
}
const double PI = acos(-1);
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    ll arr[n];
    for(int i=0;i<n;i++)cin>>arr[i];
    int counter=0;
    for(int i=0;i<n;i++)
    {
        set<int> st;
        int x=arr[i];
        while(x>0)
        {
            st.insert(x%10);
            x/=10;
        }
        if(st.size()==k+1 && *st.begin()==0 && *--st.end()==k)counter++;
    }
    cout<<counter<<endl;
return 0;}


#include<bits/stdc++.h>
#include <sstream>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define ull unsigned long long int
#define ll long long
#define all(a) a.begin(),a.end()
using namespace std;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
ll MD=1000000007;
ll md=998244353;
const ll INF=1e18L+5;
ll exp(ll a,ll b){ll r=1ll;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}//put b as bmod(md-1) if md is prime}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll pow_2(ll a, ll b)
{
    ll res = 1;
    while(b)
    {
        if(b & 1)
            res = (res * a);
        a = (a * a);
        b >>= 1;
    }

    return res;
}
bool isPrime(ll a)
{
    for(ll i=3; (i*i)<=a; i+=2)
    {
        if( (a%i)==0 )
            return false;
    }
    if( ( a!=2 ) && ( (a%2)==0 ) )
        return false;
    if( a==1 )
        return false;

    return true;
}
string decToBinary(int n)
{
    // Size of an integer is assumed to be 32 bits
    string s="";
    for (int i = 31; i >= 0; i--) {
        int k = n >> i;
        if (k & 1)
            //cout << "1";
            s=s+"1";
        else
            //cout << "0";
            s=s+"0";
    }
    return s;
}
int decimalToBinary(int N)
{

    // To store the binary number
    ull B_Number = 0;
    int cnt = 0;
    while (N != 0) {
        int rem = N % 2;
        ull c = pow(10, cnt);
        B_Number += rem * c;
        N /= 2;

        // Count used to store exponent value
        cnt++;
    }

    return B_Number;
}
string toString(ull num)
{
    std::string number;
    std::stringstream strstream;
    strstream << num;
    strstream >> number;
    return number;
}
const double PI = acos(-1);
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    ll arr[n];
    for(int i=0;i<n;i++)cin>>arr[i];
    int counter=0;
    for(int i=0;i<n;i++)
    {
        set<int> st;
        int x=arr[i];
        while(x>0)
        {
            st.insert(x%10);
            x/=10;
        }
        if(st.size()>=k+1 && *st.begin()==0 && *--st.end()>=k)counter++;
    }
    cout<<counter<<endl;
return 0;}


#include<bits/stdc++.h>
#include <sstream>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define ull unsigned long long int
#define ll long long
#define all(a) a.begin(),a.end()
using namespace std;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
ll MD=1000000007;
ll md=998244353;
const ll INF=1e18L+5;
ll exp(ll a,ll b){ll r=1ll;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}//put b as bmod(md-1) if md is prime}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll pow_2(ll a, ll b)
{
    ll res = 1;
    while(b)
    {
        if(b & 1)
            res = (res * a);
        a = (a * a);
        b >>= 1;
    }

    return res;
}
bool isPrime(ll a)
{
    for(ll i=3; (i*i)<=a; i+=2)
    {
        if( (a%i)==0 )
            return false;
    }
    if( ( a!=2 ) && ( (a%2)==0 ) )
        return false;
    if( a==1 )
        return false;

    return true;
}
string decToBinary(int n)
{
    // Size of an integer is assumed to be 32 bits
    string s="";
    for (int i = 31; i >= 0; i--) {
        int k = n >> i;
        if (k & 1)
            //cout << "1";
            s=s+"1";
        else
            //cout << "0";
            s=s+"0";
    }
    return s;
}
int decimalToBinary(int N)
{

    // To store the binary number
    ull B_Number = 0;
    int cnt = 0;
    while (N != 0) {
        int rem = N % 2;
        ull c = pow(10, cnt);
        B_Number += rem * c;
        N /= 2;

        // Count used to store exponent value
        cnt++;
    }

    return B_Number;
}
string toString(ull num)
{
    std::string number;
    std::stringstream strstream;
    strstream << num;
    strstream >> number;
    return number;
}
const double PI = acos(-1);
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    ll arr[n];
    for(int i=0;i<n;i++)cin>>arr[i];
    int counter=0;
    for(int i=0;i<n;i++)
    {
        set<int> st;
        int x=arr[i];
        while(x>0)
        {
            st.insert(x%10);
            x/=10;
        }
        if(st.size()==k+1 && *st.begin()==0 && *--st.end()>=k)counter++;
    }
    cout<<counter<<endl;
return 0;}


#include<bits/stdc++.h>
#include <sstream>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define ull unsigned long long int
#define ll long long
#define all(a) a.begin(),a.end()
using namespace std;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
ll MD=1000000007;
ll md=998244353;
const ll INF=1e18L+5;
ll exp(ll a,ll b){ll r=1ll;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}//put b as bmod(md-1) if md is prime}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll pow_2(ll a, ll b)
{
    ll res = 1;
    while(b)
    {
        if(b & 1)
            res = (res * a);
        a = (a * a);
        b >>= 1;
    }

    return res;
}
bool isPrime(ll a)
{
    for(ll i=3; (i*i)<=a; i+=2)
    {
        if( (a%i)==0 )
            return false;
    }
    if( ( a!=2 ) && ( (a%2)==0 ) )
        return false;
    if( a==1 )
        return false;

    return true;
}
string decToBinary(int n)
{
    // Size of an integer is assumed to be 32 bits
    string s="";
    for (int i = 31; i >= 0; i--) {
        int k = n >> i;
        if (k & 1)
            //cout << "1";
            s=s+"1";
        else
            //cout << "0";
            s=s+"0";
    }
    return s;
}
int decimalToBinary(int N)
{

    // To store the binary number
    ull B_Number = 0;
    int cnt = 0;
    while (N != 0) {
        int rem = N % 2;
        ull c = pow(10, cnt);
        B_Number += rem * c;
        N /= 2;

        // Count used to store exponent value
        cnt++;
    }

    return B_Number;
}
string toString(ull num)
{
    std::string number;
    std::stringstream strstream;
    strstream << num;
    strstream >> number;
    return number;
}
const double PI = acos(-1);
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    ll arr[n];
    for(int i=0;i<n;i++)cin>>arr[i];
    int counter=0;
    for(int i=0;i<n;i++)
    {
        set<int> st;
        int x=arr[i];
        while(x>0)
        {
            st.insert(x%10);
            x/=10;
        }
        int current=0;
        bool boo=true;
        for(auto it:st)
        {
            if(it != current){boo=false;break;}
            if(current==k)break;
            current++;
        }
        if(boo)counter++;
    }
    cout<<counter<<endl;
return 0;}


#include<bits/stdc++.h>
using namespace std;
int main()
{long long int n,k,b=0,p=0;cin >> n >> k;
while(n--)
{string s;cin >> s;
long long int i,x,y,a[10];

for(i=0;i<s.size();i++)
 {x=to_numb(s[i]);

  if(x>k)
  {break;
  b=1;
  }
  else
  {a[x]++;
  }
 }
 if(b==0)
 {
 for(i=0;i<=k;i++)
 {if(a[i]>=1)
  {y++;
  }
 }
 if(y==k+1)
  {p++;
  }
 }
}
cout << p;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{long long int n,k,b=0,p=0;cin >> n >> k;
while(n--)
{string s;cin >> s;
long long int i,x,y,a[10];

for(i=0;i<s.size();i++)
 {x=49-s[i];

  if(x>k)
  {break;
  b=1;
  }
  else
  {a[x]++;
  }
 }
 if(b==0)
 {
 for(i=0;i<=k;i++)
 {if(a[i]>=1)
  {y++;
  }
 }
 if(y==k+1)
  {p++;
  }
 }
}
cout << p;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{long long int n,k,b=0,p=0;cin >> n >> k;
while(n--)
{string s;cin >> s;
long long int i,y=0,a[11]={0};
char x;
for(i=0;i<s.length();i++)
 {x=s[i];
  {a[x-48]++;
  }
 }

 {
 for(i=0;i<=k;i++)
 {if(a[i]>=1)
  {y++;
  }
 }
 if(y==k+1)
  {p++;
  }
 }
}
cout << p;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{long long int n,k,b=0,p=0;cin >> n >> k;
while(n--)
{string s;cin >> s;
long long int i,y,a[11]={0};
char x;
for(i=0;i<s.length();i++)
 {x=s[i];
  {a[x-48]++;
  }
 }

 {
 for(i=0;i<=k;i++)
 {if(a[i]>=1)
  {y++;
  }
 }
 if(y==k+1)
  {p++;
  }
 }
}
cout << p;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{long long int n,k,b=0,p=0;cin >> n >> k;
while(n--)
{string s;cin >> s;
long long int i,x,y,a[11]={0};

for(i=0;i<s.length();i++)
 {x=48-s[i];

  if(x>k)
  {break;
  b=1;
  }
  else
  {a[x]++;
  }
 }
 if(b==0)
 {
 for(i=0;i<=k;i++)
 {if(a[i]>=1)
  {y++;
  }
 }
 if(y==k+1)
  {p++;
  }
 }
}
cout << p;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{long long int n,k,b=0,p=0;cin >> n >> k;
while(n--)
{string s;cin >> s;
long long int i,x,y,a[11]={0};
char x;
for(i=0;i<s.length();i++)
 {x=s[i];
  {a[48-x]++;
  }
 }

 {
 for(i=0;i<=k;i++)
 {if(a[i]>=1)
  {y++;
  }
 }
 if(y==k+1)
  {p++;
  }
 }
}
cout << p;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{long long int n,k,b=0,p=0;cin >> n >> k;
while(n--)
{string s;cin >> s;
long long int i,x,y,a[11]={0};

for(i=0;i<s.length();i++)
 {x=49-s[i];

  if(x>k)
  {break;
  b=1;
  }
  else
  {a[x]++;
  }
 }
 if(b==0)
 {
 for(i=0;i<=k;i++)
 {if(a[i]>=1)
  {y++;
  }
 }
 if(y==k+1)
  {p++;
  }
 }
}
cout << p;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{long long int n,k,b=0,p=0;cin >> n >> k;
while(n--)
{string s;cin >> s;
long long int i,x;a[10];

for(i=0;i<s.size();i++)
 {x=to_numb(s[i]);

  if(x>k)
  {break;
  b=1;
  }
  else
  {a[x]++;
  }
 }
 if(b==0)
 {
 for(i=0;i<=k;i++)
 {if(a[i]>=1)
  {y++;
  }
 }
 if(y==k+1)
  {p++;
  }
 }
}
cout << p;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{long long int n,k,b=0,p=0;cin >> n >> k;
while(n--)
{string s;cin >> s;
long long int i,y,a[11]={0};
char x;
for(i=0;i<s.length();i++)
 {x=s[i];
  {a[48-x]++;
  }
 }

 {
 for(i=0;i<=k;i++)
 {if(a[i]>=1)
  {y++;
  }
 }
 if(y==k+1)
  {p++;
  }
 }
}
cout << p;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{long long int n,k,b=0,p=0;cin >> n >> k;
while(n--)
{string s;cin >> s;
long long int i,x,y,a[11]={0};
char=x;
for(i=0;i<s.length();i++)
 {x=s[i];
  {a[48-x]++;
  }
 }

 {
 for(i=0;i<=k;i++)
 {if(a[i]>=1)
  {y++;
  }
 }
 if(y==k+1)
  {p++;
  }
 }
}
cout << p;
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int counter = 0, n, k;
    string x;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        cin >> x;
        sort(x.begin(), x.end());
        if (x[x.length() - 1] <= k + '0')
            counter++;
    }
    cout << counter;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#include <sstream>
#include <string>
using namespace std;

int main()
{
    int counter = 0, n, k, temp;
    string x;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        cin >> x;
        sort(x.begin(), x.end());
        x = x.substr(x.length() - 1, x.length() - 1);
        stringstream s (x);
        s >> temp;
        if (temp <= k )
            counter++;
    }
    cout << counter;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#include <sstream>
#include <string>
using namespace std;

int main()
{
        int counter = 0, n, k;
        string x, temp;
        cin >> n >> k;
        for (int i = 0; i < n; i++)
        {
            temp.clear();
            cin >> x;
            if (x.length() < k + 1)
                continue;
            sort(x.begin(), x.end());
            x.erase(unique(x.begin(), x.end()), x.end());
            x.erase(k + 1);
            for (int j = 0; j <= k; j++)
                temp.push_back(j + '0');
            temp.erase(k + 1);
            if (temp == x)
                counter++;
        }
        cout << counter;
        return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#include <sstream>
#include <string>
using namespace std;

int main()
{
        int counter = 0, n, k;
        string x, temp;
        cin >> n >> k;
        for (int i = 0; i < n; i++)
        {
            temp.clear();
            cin >> x;
            if (x.length() < k + 1)
                continue;
            sort(x.begin(), x.end());
            x.erase(unique(x.begin(), x.end()), x.end());
            if (x.length() > k + 1)
                x.erase(k + 1);
            for (int j = 0; j <= k; j++)
                temp.push_back(j + '0');
            temp.erase(k + 1);
            if (temp == x)
                counter++;
        }
        cout << counter;
        return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#include <sstream>
#include <string>
using namespace std;

int main()
{
    int counter = 0, n, k, flag, temp;
    string x;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        flag = 0;
        cin >> x;
        sort(x.begin(), x.end());
        if (x.length() < k + 1)
            continue;
        for (int j = 0; j <= k; j++)
        {
      /*      stringstream s (x.substr(j, j));
            s >> temp;
            cout << temp << "\n";*/
            if (x[j] != j + '0')
            {
                flag = 1;
                break;
            }
        }
        if (flag == 1)
            continue;
        else
            counter++;
    }
    cout << counter;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#include <sstream>
#include <string>
using namespace std;

int main()
{
    int counter = 0, n, k;
    string x, temp;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        temp.clear();
        cin >> x;
        if (x.length() < k + 1)
            continue;
        sort(x.begin(), x.end());
        x.erase(k + 1);
        for (int j = 0; j <= k; j++)
            temp.push_back(j + '0');
        if (temp == x)
            counter++;
    }
    cout << counter;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define uii             unordered_map<int,int>
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
void S_K_S()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int32_t main()
{
	S_K_S();
	int n,k;
	cin>>n>>k;
	int cnt=0;
	while(n--){
		int x;
		cin>>x;
		map<int,int>m;
		bool tg=true;
		while(x!=0){
			int r=x%10;
				if(r>k){
					tg=false;
					break;
				}
			m[r]++;
			x/=10;
		}
		// cout<<m.size()<<endl;
		if(tg==true && m.size()==k+1)
			cnt++;
			m.clear();
	}
	cout<<cnt;
}


#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define uii             unordered_map<int,int>
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
void S_K_S()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int32_t main()
{
	S_K_S();
	int n,k;
	cin>>n>>k;
	int cnt=0;
	while(n--){
		int x;
		cin>>x;
		map<int,int>m;
		bool tg=true;
		while(x!=0){
			int r=x%10;
				if(r>k){
					tg=false;
					break;
				}
			m[r]++;
			x/=10;
		}
		if(tg==true && m.size()>=k+1)
			cnt++;
			m.clear();
	}
	cout<<cnt;
}


#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define uii             unordered_map<int,int>
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
void S_K_S()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int32_t main()
{
	S_K_S();
	int n,k;
	cin>>n>>k;
	int cnt=0;
	while(n--){
		int x;
		cin>>x;
		map<int,int>m;
		bool tg=true;
		while(x!=0){
			int r=x%10;
				if(r>k){
					tg=false;
					break;
				}
			m[r]++;
			x/=10;
		}
		if(tg==true && m.size()>=k)
			cnt++;
			m.clear();
	}
	cout<<cnt;
}


#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define uii             unordered_map<int,int>
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
void S_K_S()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int32_t main()
{
	S_K_S();
	int n,k;
	cin>>n>>k;
	int cnt=0;
	while(n--){
		int x,t=0;
		cin>>x;
		bool tg=true;
		while(x!=0){
			int r=x%10;
				if(r>k){
					tg=false;
					break;
				}
			x/=10;
			t++;
		}
		if(tg==true && t>=k+1)
			cnt++;
	}
	cout<<cnt;
}


#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define uii             unordered_map<int,int>
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
void S_K_S()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int32_t main()
{
	S_K_S();
	int n,k;
	cin>>n>>k;
	int cnt=0;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		map<int,int>m;
		while(x!=0){
			int r=x%10;
			if(r<=k)
				m[r]++;
			x/=10;
		}
		if(m.size()==k+1)
			cnt++;
	}
	cout<<cnt;
}


#include<bits/stdc++.h>

using namespace std;
int main()
{
int n,k,a,j=0 ;
cin>>n>>k;
set<int>s ;
for (int i=0 ; i<n ; i++)
{
   cin>>a;

    if(a/10>=pow(10,k-1))
    while(true)
   {
       s.insert(a%10);
       a/=10;
       if(a==0)
         if(s.size()>=k+1)
         {  j++; break;}
          else
            break;
   }

}

cout<<j ;
return 0;
}


#include<bits/stdc++.h>

using namespace std;
int main()
{
int n,k;
long long a;
short x, j=0 ;
bool b;
cin>>n>>k;
set<int>s ;
for (int i=0 ; i<n ; i++)
{
   cin>>a;
    b=false;
    if(a>=pow(10,k))
    while(true)
   {
        if(a==0 )
           if(s.size()>=k+1 && b==true )
         {  j++; break;}
          else
            break;

        x=a%10;
       s.insert(x);
       if(x==0) b=true;
       //cout<<x<<endl;
       a/=10;

   }

}

cout<<j  ;
return 0;
}


#include<bits/stdc++.h>

using namespace std;
int main()
{
int n,k;
int a;
short x=0, j=0 ;
cin>>n>>k;
set<int>s ;
for (int i=0 ; i<n ; i++)
{
   cin>>a;
    if(a>=pow(10,k))
    while(true)
   {
        if(a==0 )
           if(s.size()==k+1)
         {  j++; break;}
          else
            break;
        else
        {

        x=a%10;
        if(x<=k)
          {s.insert(x);
          a/=10;}
          else
            a/=10;
        }
   }

}

cout<<j  ;
return 0;
}


#include<bits/stdc++.h>

using namespace std;
int main()
{
int n,k,a;
short x, j=0 ;
bool b;
cin>>n>>k;
set<int>s ;
for (int i=0 ; i<n ; i++)
{
   cin>>a;
    b=false;
    if(a/10>=pow(10,k-1))
    while(true)
   {
        if(a==0 )
           if(s.size()>=k+1 && b==true )
         {  j++; break;}
          else
            break;

        x=a%10;
       s.insert(x);
       if(x==0) b=true;
       //cout<<x<<endl;
       a/=10;

   }

}

cout<<j  ;
return 0;
}


#include<bits/stdc++.h>

    using namespace std;
    int main()
    {
        int n, k, x, j = 0;
        long long int a;
        cin >> n >> k;
        set <int> s;
        for (int i = 0; i < n; i++)
        {
            cin >> a;
            if (a >= pow(10, k))
            while (true)
            {
                x = a % 10;
                a /= 10;
                if (x <= k)
                s.insert(x);
                if (s.size() == k + 1 && a == 0)
                {
                    j++;
                    break;
                }
                else if (s.size() != k + 1 && a == 0)
                break;
            }
        }
        cout << j;
        return 0;
    }


#include<bits/stdc++.h>
using namespace std;

int main()
{
	int n, k, y = 0;
	scanf("%d %d", &n, &k);
	int g = k + 1;
	long long int  a[n];
	for (int i = 0; i < n; i++)
    {
        scanf("%I64d", &a[i]);
        int z = 1 + floor(log10(a[i]));
        int d[z], s = 0, p = 0;
        if (z >= g)
        {
            for (int j = 0; j < z; j++)
            {
                d[j] = a[i] % 10;
                a[i] /= 10;
            }
            for (int j = 0; j < g; j++)
            {
                s = 0;
                for (int f = 0; f < z; f++)
                if (d[f] == j)
                {
                    s = 1;
                    break;
                }
                if (s == 1)
                p++;
                if (g == p)
                {
                    y++;
                    break;
                }
            }
        }
    }
    cout << y;
    return 0;
}


#include<bits/stdc++.h>

using namespace std;
int main()
{
int n,k;
int a;
short x=0, j=0 ;
cin>>n>>k;
set<int>s ;
for (int i=0 ; i<n ; i++)
{
   cin>>a;
    s.clear();
    if(a>=pow(10,k))
    while(true)
   {
        if(a==0 )
           if(s.size()==k+1)
         {  j++; break;}
          else
            break;
        else
        {
        x=a%10;

        if(x<=k)
          {s.insert(x); a/=10;}
          else
            a/=10;
        }
   }

}

cout<<j  ;
return 0;
}


#include<bits/stdc++.h>

using namespace std;
int main()
{
int n,k;
long long a;
short x, j=0 ;
bool b;
cin>>n>>k;
set<int>s ;
for (int i=0 ; i<n ; i++)
{
   cin>>a;
    b=false;
    if(a>=pow(10,k))
    while(true)
   {
        if(a==0 )
           if(s.size()>=k+1 && b==true )
         {  j++; break;}
          else
            break;

        x=a%10;
        if(x<=k)
          s.insert(x);
       if(x==0) b=true;
       //cout<<x<<endl;
       a/=10;

   }

}

cout<<j  ;
return 0;
}


#include<bits/stdc++.h>

using namespace std;
int main()
{
int n,k;
long long a;
short x, j=0 ;
bool b;
cin>>n>>k;
set<int>s ;
for (int i=0 ; i<n ; i++)
{
   cin>>a;
    b=false;
    if(a>=pow(10,k))
    while(true)
   {
        if(a==0 )
           if(s.size()>=k+1 && b==true )
         {  j++; break;}
          else
            break;

        x=a%10;
        if(x<=4)
            s.insert(x);

       if(x==0) b=true;
       //cout<<x<<endl;
       a/=10;

   }

}

cout<<j  ;
return 0;
}


#include<bits/stdc++.h>

using namespace std;
int main()
{
int n,k;
long long a;
short x, j=0 ;
bool b;
cin>>n>>k;
set<int>s ;
for (int i=0 ; i<n ; i++)
{
   cin>>a;
    b=false;
    if(a>=pow(10,k))
    while(true)
   {
        if(a==0 )
           if(s.size()==k+1 && b==true )
         {  j++; break;}
          else
            break;

        x=a%10;
        if(x<=k)
          s.insert(x);
       if(x==0) b=true;
       //cout<<x<<endl;
       a/=10;

   }

}

cout<<j  ;
return 0;
}


#include<bits/stdc++.h>

using namespace std;
int main()
{
int n,k,a,j=0 ;
cin>>n>>k;
set<int>s ;
for (int i=0 ; i<n ; i++)
{
   cin>>a;
   if(a/10>=pow(10,k-1))
    while(true)
   {
       s.insert(a%10);
       a/=10;
       if(a==0)
         if(s.size()==k+1)
         {  j++; break;}
          else
            break;
   }

}

cout<<j;
return 0;
}


    #include<bits/stdc++.h>

    using namespace std;
    int main()
    {
        int n, k, x, y, j = 0;
        long long int a;
        cin >> n >> k;
        set <int> s;
        for (int i = 0; i < n; i++)
        {
            cin >> a;
            s.clear();
            if (a >= pow(10, k))
            while (true)
            {
                x = a % 10;
                a /= 10;
                if (x <= k)
                s.insert(x);
                y = s.size();
                if (y == k + 1)
                {
                    j++;
                    break;
                }
                else if (y != k + 1 && a == 0)
                break;
            }
        }
        cout << j;
        return 0;
    }


#include <bits/stdc++.h>
using namespace std;

#define fast_io  ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define sep      ' '
#define debug(x) cerr << #x << " = " << x << endl
#define getarr(arr, y) for(int i = 0; i < y; i++) cin >> arr[i]
#define printarr(arr, y) for(int i = 0; i < y; i++) cerr << i << " = " << arr[i] << endl

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

int main(){
    fast_io;
    str a, nums_, nums;
    bool is_k_good;
    int n, k, k_good = 0;
    cin >> n >> k;
    for(int j = 0; j <= k; j++) nums_ += to_string(j);
    // debug(nums_);
    for(int i = 0; i < n; i++){
        is_k_good = true;
        nums = nums_;
        cin >> a;
        for(int i = 0; i < a.length(); i++){
            if(nums.find(a[i]) == nums.npos){
                is_k_good = false;
                // cout << "/";
                break;
            }
            else{
                nums.erase(nums.find(a[i]));
            }
            // debug(nums);
        }
        if(!nums.empty() && is_k_good){
            is_k_good = false;
            // cout << "*";
        }
        k_good += is_k_good ? 1 : 0;
    }
    cout << k_good;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define fast_io  ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define sep      ' '
#define debug(x) cerr << #x << " = " << x << endl
#define getarr(arr, y) for(int i = 0; i < y; i++) cin >> arr[i]
#define printarr(arr, y) for(int i = 0; i < y; i++) cerr << i << " = " << arr[i] << endl

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

int main(){
    fast_io;
    bool is_k_good = true;
    int n, k, a, k_good = 0;
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> a;
        while(a != 0){
            if(a % 10 > k){
                is_k_good = false;
                break;
            }
            a /= 10;
        }
        k_good += is_k_good ? 1 : 0;
    }
    cout << k_good;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define fast_io  ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define sep      ' '
#define debug(x) cerr << #x << " = " << x << endl
#define getarr(arr, y) for(int i = 0; i < y; i++) cin >> arr[i]
#define printarr(arr, y) for(int i = 0; i < y; i++) cerr << i << " = " << arr[i] << endl

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

int main(){
    fast_io;
    str a, nums;
    bool is_k_good = true;
    int n, k, k_good = 0;
    cin >> n >> k;
    for(int i = 0; i <= k; i++) nums += to_string(i);
    // cout << nums;
    for(int i = 0; i < n; i++){
        cin >> a;
        for(int i = 0; i < a.length(); i++){
            if(nums.find(a[i]) == nums.npos){
                is_k_good = false;
                break;
            }
        }
        k_good += is_k_good ? 1 : 0;
    }
    cout << k_good;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define fast_io  ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define sep      ' '
#define debug(x) cerr << #x << " = " << x << endl
#define getarr(arr, y) for(int i = 0; i < y; i++) cin >> arr[i]
#define printarr(arr, y) for(int i = 0; i < y; i++) cerr << i << " = " << arr[i] << endl

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

int main(){
    fast_io;
    str a, nums_, nums;
    bool is_k_good;
    int n, k, k_good = 0;
    cin >> n >> k;
    for(int j = 0; j <= k; j++) nums_ += to_string(j);
    // debug(nums_);
    for(int i = 0; i < n; i++){
        is_k_good = true;
        nums = nums_;
        // debug(nums);
        cin >> a;
        for(int i = 0; i < a.length(); i++){
            if(nums.find(a[i]) == nums.npos){
                is_k_good = false;
                // cout << "/";
                break;
            }
            else{
                nums.erase(nums.find(a[i]), 1);
            }
            // debug(nums);
        }
        if(!nums.empty() && is_k_good){
            is_k_good = false;
            // cout << "*";
        }
        k_good += is_k_good ? 1 : 0;
    }
    cout << k_good;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define all(v) v.begin(),v.end()
#define X first
#define Y second

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        vector<char> mark(k + '0' + 1, false);
        string s;
        cin >> s;
        for (auto &c : s) if (c <= k + '0') mark[c] = true;
        cnt += all_of('0' + all(mark), [](auto &a) { return a; });
    }
    cout << cnt;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define fast_io  ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define sep      ' '
#define debug(x) cerr << #x << " = " << x << endl
#define getarr(arr, y) for(int i = 0; i < y; i++) cin >> arr[i]
#define printarr(arr, y) for(int i = 0; i < y; i++) cerr << i << " = " << arr[i] << endl

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

int main(){
    fast_io;
    str a, nums;
    bool is_k_good = true;
    int n, k, k_good = 0;
    cin >> n >> k;
    for(int i = 0; i <= k; i++) nums.push_back((char)i);
    for(int i = 0; i < n; i++){
        cin >> a;
        for(int i = 0; i < a.length(); i++){
            if(nums.find(a[i]) == nums.npos){
                is_k_good = false;
                break;
            }
        }
        k_good += is_k_good ? 1 : 0;
    }
    cout << k_good;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define all(v) v.begin(),v.end()
#define X first
#define Y second

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        vector<char> mark(k + '0' + 1, false);
        string s;
        cin >> s;
        for (auto &c : s) mark[c] = true;
        cnt += all_of('0' + all(mark), [](auto &a) { return a; });
    }
    cout << cnt;
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
int main(void)
{
	int n=0,k=0;
	scanf("%d %d",&n,&k);
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		char str[1000]={0};
		scanf("%s",str);
		int j=0;
		for(j=0;j<=k;j++)
		{
			int cheak=0;
			bool test=false;
			while(str[cheak])
			{
				if(str[cheak]-'0'==j)
				{
					test=true;
				}
				cheak++;
			}
			if(test==false)
				break;
		}
		if(j>k)
		{
			ans++;
		}
	}
	printf("%d",ans);
}


#include <stdio.h>
#include <stdlib.h>
int main(void)
{
	int n=0,k=0;
	scanf("%d %d",&n,&k);
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		char str[1000]={0};
		scanf("%s",str);
		int j=0;
		for(j=0;j<=k;j++)
		{
			int cheak=0;
			bool test=false;
			while(str[cheak])
			{
				if(str[cheak]-'0'==j)
				{
					test=true;
				}
				cheak++;
			}
			if(test==false)
				break;
		}
		if(j>=k&&j!=0)
		{
			ans++;
		}
	}
	printf("%d",ans);
}


#include <stdio.h>
#include <stdlib.h>
int main(void)
{
	int n=0,k=0;
	scanf("%d %d",&n,&k);
	int ans=0;
	char str[1000]={0};
	for(int i=1;i<=n;i++)
	{
		scanf("%s",str);
		int cheak=0,j=0;
		bool test=false;
		for(j=0;j<=k;j++)
		{
			while(str[cheak])
			{
				if(str[cheak]-'0'==j)
				{
					test=true;
				}
				cheak++;
			}
			if(test==false)
				break;
		}
		if(j>=k&&j!=0)
		{
			ans++;
		}
	}
	printf("%d",ans);
}


#include <stdio.h>
#include <stdlib.h>
int main(void)
{
	int n=0,k=0;
	scanf("%d %d",&n,&k);
	int ans=0;
	char str[1000]={0};
	for(int i=1;i<=n;i++)
	{
		scanf("%s",str);
		int j=0;
		for(j=0;j<=k;j++)
		{
			int cheak=0;
			bool test=false;
			while(str[cheak])
			{
				if(str[cheak]-'0'==j)
				{
					test=true;
				}
				cheak++;
			}
			if(test==false)
				break;
		}
		if(j>=k&&j!=0)
		{
			ans++;
		}
	}
	printf("%d",ans);
}


#include <stdio.h>
#include <stdlib.h>
int main(void)
{
	int n=0,k=0;
	scanf("%d %d",&n,&k);
	int ans=0;
	char str[1000]={0};
	for(int i=1;i<=n;i++)
	{
		scanf("%s",str);
		int cheak=0,j=0;
		while(str[j])
		{
			int num=str[j]-'0';
			if(cheak<num)
			{
				cheak=num;
			}
			j++;
		}
		if(cheak>=k)
		{
			ans++;
		}
	}
	printf("%d",ans);
}


#include <stdio.h>
#include <stdlib.h>
int main(void)
{
	int n=0,k=0;
	scanf("%d %d",&n,&k);
	int ans=0;
	char str[1000]={0};
	for(int i=1;i<=n;i++)
	{
		scanf("%s",str);
		int cheak=0,j=0;
		for(j=0;j<=k;j++)
		{
			bool test=false;
			while(str[cheak])
			{
				if(str[cheak]-'0'==j)
				{
					test=true;
				}
				cheak++;
			}
			printf("\n");
			if(test==false)
				break;
		}
		if(j>=k&&j!=0)
		{
			ans++;
		}
	}
	printf("%d",ans);
}


#include <stdio.h>
#include <stdlib.h>
int main(void)
{
	int n=0,k=0;
	scanf("%d %d",&n,&k);
	int ans=0;
	char str[1000]={0};
	for(int i=1;i<=n;i++)
	{
		scanf("%s",str);
		int cheak=0,j=0;
		bool test=false;
		for(j=0;j<=k;j++)
		{
			while(str[cheak])
			{
				if(str[cheak]-'0'==j)
				{
					test=true;
				}
				cheak++;
			}
			if(test==false)
				break;
		}
		if(j>=k)
		{
			ans++;
		}
	}
	printf("%d",ans);
}


#include <iostream>
#include <string>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
using namespace std;

int main()
{
    int n , a;
    cin >> n >> a;

    int counter1 = 0;
    int counter2 = 0;

    string s;

    for (int i = 0 ; i < n ; i++) {
        cin >> s;
        sort(s.begin(),s.end());
        counter1 = 0;

        if (a!=0){
        for (int j = 0 ; j < a ; j++) {
            if (s[0]=='0' && s[j] == s[j+1] -1) {
                counter1++;
            }
            if (counter1 == a) {
                counter2++;
        }
    }
    } else {
        for (int j = 0 ; j <= 1 ; j++) {
            if (s[j]=='0')
                counter2++;
        }
    }
}
    cout << counter2;

}


#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <cstring>

using namespace std;

int main() {
int n , k;
int c1 = 0, c2 = 0;

string num = "0123456789";

int flag = -1;

cin >> n >> k;

string s;

while (n--) {
	cin >> s;

for (int i = 0 ; i <= k ; i++) {
	flag = s.find(num[i]);

		if (flag != -1) {
			c1++;
			flag = -1;
		}
}

if (c1>=k+1){
	c2++;
}

c1 = 0;

}

cout << c2;

}


#include <iostream>
#include <string>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
using namespace std;

int main()
{
    int n , a;
    cin >> n >> a;

    int counter1 = 0;
    int counter2 = 0;

    string s;

    for (int i = 0 ; i < n ; i++) {
        cin >> s;
        sort(s.begin(),s.end());
        counter1 = 0;

        if (a!=0){
        for (int j = 0 ; j <= a ; j++) {
            if (s[0]=='0' && s[j] == s[j+1] -1) {
                counter1++;
            }
            if (j==a && counter1 == a) {

                counter2++;
        }
    }
    } else {
        for (int j = 0 ; j < 1 ; j++) {
            if (s[j]=='0')
                counter2++;
        }
    }
}
    cout << counter2;

}


#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <cstring>

using namespace std;

int main() {
int n , k;
int c1 = 0 , c2 = 0;
cin >> n >> k;

string s;

for (int i = 0 ; i < n ; i++) {
	cin >> s;
	sort(s.begin(),s.end());

	c1 = 0;

	if (k==0){

		for (int j = 0 ; j < 1 ; j++) {
			if (s[j]=='0')
				c2++;
		}

	}

	if (k!=0) {

	for (int j = 0 ; j < s.length() ; j++) {
		if (s[j]==s[j+1]){
			k++;
	}
	}

	for (int j = 0 ; j <= k ; j++) {
		if (s[0]=='0' && s[j] == s[j+1]-1 || s[j]==s[j+1])
			c1++;
		if (j==k)
			if(c1==k)
				c2++;
	}
}

}

cout << c2;

}


#include <iostream>
#include <string>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
using namespace std;

int main()
{
    int n , a;
    cin >> n >> a;

    int counter1 = 0;
    int counter2 = 0;

    string s;

    for (int i = 0 ; i < n ; i++) {
        cin >> s;
        sort(s.begin(),s.end());
        counter1 = 0;

        if (a!=0){
        for (int j = 0 ; j < a ; j++) {
            if (s[0]=='0' && s[j] == s[j+1] -1) {
                counter1++;
            }
            if (counter1 == a) {
                counter2++;
        }
    }
    } else {
        for (int j = 0 ; j < 1 ; j++) {
            if (s[j]=='0')
                counter2++;
        }
    }
}
    cout << counter2;

}


#include <iostream>
#include <string>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
using namespace std;

int main()
{
    int n , a;
    cin >> n >> a;

    int counter1 = 0;
    int counter2 = 0;

    string s;

    for (int i = 0 ; i < n ; i++) {
        cin >> s;
        sort(s.begin(),s.end());
        counter1 = 0;

        if (a!=0){
        for (int j = 0 ; j <= a ; j++) {
            if (s[0]=='0' && s[j] == s[j+1] -1) {
                counter1++;
            }
        if (j==a) {
            if ( counter1 == a) {

                counter2++;
        }
    }
    }
    } else {
        for (int j = 0 ; j < 1 ; j++) {
            if (s[j]=='0')
                counter2++;
        }
    }
}
    cout << counter2;

}


#include <iostream>
#include <string>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
using namespace std;

int main()
{
    int n , a;
    cin >> n >> a;

    int counter1 = 0;
    int counter2 = 0;

    string s;

    for (int i = 0 ; i < n ; i++) {
        cin >> s;
        sort(s.begin(),s.end());
        counter1 = 0;

        if (a!=0){
        for (int j = 0 ; j <= a ; j++) {
            if (s[0]=='0') {
                if (s[j]==s[j+1]-1)
                    counter1++;
                else if (s[j]==s[j+1])
                    a++;
            }
        if (j==a) {
            if ( counter1 >= a) {

                counter2++;
        }
    }
    }
    } else {
        for (int j = 0 ; j < 1 ; j++) {
            if (s[j]=='0')
                counter2++;
        }
    }
}
    cout << counter2;

}


#include <iostream>
#include <string>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
using namespace std;

int main()
{
    int n , a;
    cin >> n >> a;

    int counter1 = 0;
    int counter2 = 0;

    string s;

    for (int i = 0 ; i < n ; i++) {
        cin >> s;
        sort(s.begin(),s.end());
        counter1 = 0;

        if (a!=0){
        for (int j = 0 ; j < s.length() ; j++) {
            if (s[0]=='0') {
                if (s[j]==s[j+1]-1)
                    counter1++;
            }
        if (j==a) {
            if ( counter1 >= a) {

                counter2++;
        }
    }
    }
    } else {
        for (int j = 0 ; j < 1 ; j++) {
            if (s[j]=='0')
                counter2++;
        }
    }
}
    cout << counter2;

}


#include <iostream>
#include<bits/stdc++.h>
#include <string>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;

int main() {
int n , k;
cin >> n >> k;
int arr[n];
int counter = 0;

for (int i = 0 ; i < n ; i++) {
	cin >> arr[i];
}

for (int i = 0 ; i < n ; i++) {
	if (arr[i]%10!=k)
	counter++;
}

cout << counter;

}


#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <cstring>

using namespace std;

int main() {
int n , k;
int c1 = 0 , c2 = 0;
cin >> n >> k;

string s;

for (int i = 0 ; i < n ; i++) {
	cin >> s;
	sort(s.begin(),s.end());

	c1 = 0;

	if (k==0){

		for (int j = 0 ; j < 1 ; j++) {
			if (s[j]=='0')
				c2++;
		}

	}

	if (k!=0) {

	for (int j = 0 ; j < s.length() ; j++) {
		if (s[j]==s[j+1]){
			k++;
	}
}

	for (int j = 0 ; j <= k ; j++) {
		if (s[0]=='0') {
			if (s[j] == s[j+1]-1 || s[j]==s[j+1]) {
					c1++;
		}
	}
		if (j==k) {

			if(c1==k)
				c2++;

		}
	}
}

}

cout << c2;

}


#include <bits/stdc++.h>
using namespace std;
int n,k;
int main()
{
	cin>>n>>k;
	int ans=0;

	while (n--) {
		int a; cin>>a;
		set<int> s;
		while (a) {
			if(a%10<=k) s.insert(a%10);
			a/=10;
		}
		if(s.size()==k+1) ans++;
	}
	cout<<ans<<endl;
	return 0;
}


#include <bits/stdc++.h>
//#include "template.h"
using namespace std;
typedef long double   	  LD;
typedef vector<int>       VI;
typedef vector<double>    VD;
typedef vector< VI >      VVI;
typedef vector< VI >      VVD;
typedef vector<string>    VS;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef vector< PII > VPII;

#define PI 3.14159265359
#define mod 1000000007 // depend on your input
#define INF_MAX 2147483647
#define INF_MIN -2147483647
#define eps 1e-9

const LL OO = 1e8;

#define all(v) v.begin(),v.end()
#define srtva(v) sort(all(v))
#define srtvd(v) sort(v.rbegin(),v.rend())
#define srtaa(a,n) sort(a,a+n)
#define srtad(a,n) sort(a,a+n),reverse(a,a+n)

#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfi4(v1,v2,v3,v4) scanf("%d %d %d %d",&v1,&v2,&v3,&v4)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define sfll4(v1,v2,v3,v4) scanf("%I64d %I64d %I64d %I64d",&v1,&v2,&v3,&v4)
#define sfstr(v) scanf("%s", v)
#define sfch1(ch) scanf("%c",&ch)
#define chr getchar()
#define pi(x) printf("%d",x)
#define p2i(x,y) printf("%d %d",x,y)
#define pl(x) printf("%lld",x)
#define p2l(x,y) printf("%lld %lld",x,y)
#define pfstr(ch) printf("%s",ch)
#define pfch(ch) printf("%c",ch)
#define sf scanf
#define pf printf
void PLAY() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cout << fixed << setprecision(4);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

#define FI freopen("in.txt","r",stdin)
#define FO freopen("out.txt","w",stdout)
#define sz(v) (int)v.size()

#define nl printf("\n")
#define SS stringstream

#define pb push_back
#define mp make_pair

#define debug(x) cout<<#x<<" = { "<<x<<" }\n"

#define FOR(i,s,e) for(int i = s; i < e; i++)
#define FORD(i,e,s) for(int i=e-1,i>=s;i--)
#define lp(i,n) FOR(i,0,n)
#define lpd(i,n) FORD(i,n-1,0)
#define rev(i,s,e) FORD(i,s,e)
#define rep(i,v) FOR(i,0,sz(v))

LL gcd(LL a, LL b) { return !b ? a : gcd(b, a % b); }
LL lcm(LL a, LL b) { return (a / gcd(a, b)) * b; }

#define mem(ara,val) memset(ara,val,sizeof(ara))
#define ssz(a) strlen(a)

int n, k, res;
int main() {
    sfi2(n, k);
    while(n--){
        set<int> st;
        int num;
        sfi1(num);
        while(num!=0){
            st.insert(num%10);
            num/=10;
        }
        if(sz(st) >= k+1)
            res++;

    }
    pi(res);
    return 0;
}


#include <bits/stdc++.h>
//#include "template.h"
using namespace std;
typedef long double   	  LD;
typedef vector<int>       VI;
typedef vector<double>    VD;
typedef vector< VI >      VVI;
typedef vector< VI >      VVD;
typedef vector<string>    VS;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef vector< PII > VPII;

#define PI 3.14159265359
#define mod 1000000007 // depend on your input
#define INF_MAX 2147483647
#define INF_MIN -2147483647
#define eps 1e-9

const LL OO = 1e8;

#define all(v) v.begin(),v.end()
#define srtva(v) sort(all(v))
#define srtvd(v) sort(v.rbegin(),v.rend())
#define srtaa(a,n) sort(a,a+n)
#define srtad(a,n) sort(a,a+n),reverse(a,a+n)

#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfi4(v1,v2,v3,v4) scanf("%d %d %d %d",&v1,&v2,&v3,&v4)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define sfll4(v1,v2,v3,v4) scanf("%I64d %I64d %I64d %I64d",&v1,&v2,&v3,&v4)
#define sfstr(v) scanf("%s", v)
#define sfch1(ch) scanf("%c",&ch)
#define chr getchar()
#define pi(x) printf("%d",x)
#define p2i(x,y) printf("%d %d",x,y)
#define pl(x) printf("%lld",x)
#define p2l(x,y) printf("%lld %lld",x,y)
#define pfstr(ch) printf("%s",ch)
#define pfch(ch) printf("%c",ch)
#define sf scanf
#define pf printf
void PLAY() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cout << fixed << setprecision(4);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

#define FI freopen("in.txt","r",stdin)
#define FO freopen("out.txt","w",stdout)
#define sz(v) (int)v.size()

#define nl printf("\n")
#define SS stringstream

#define pb push_back
#define mp make_pair

#define debug(x) cout<<#x<<" = { "<<x<<" }\n"

#define FOR(i,s,e) for(int i = s; i < e; i++)
#define FORD(i,e,s) for(int i=e-1,i>=s;i--)
#define lp(i,n) FOR(i,0,n)
#define lpd(i,n) FORD(i,n-1,0)
#define rev(i,s,e) FORD(i,s,e)
#define rep(i,v) FOR(i,0,sz(v))

LL gcd(LL a, LL b) { return !b ? a : gcd(b, a % b); }
LL lcm(LL a, LL b) { return (a / gcd(a, b)) * b; }
//ohmibod
#define mem(ara,val) memset(ara,val,sizeof(ara))
#define ssz(a) strlen(a)

int n, k;
int main() {
    VI vec (10);
    sfi2(n, k);
    while(n--){
        int x;
        sfi1(x);
        while(x!=0){
            vec[x%10]++;
            x/=10;
        }
    }
    int mn = 999;
    lp(i, k+1)
        if(vec[i] < mn)
            mn = vec[i];

    cout<<mn;
    return 0;
}


#include <bits/stdc++.h>
//#include "template.h"
using namespace std;
typedef long double   	  LD;
typedef vector<int>       VI;
typedef vector<double>    VD;
typedef vector< VI >      VVI;
typedef vector< VI >      VVD;
typedef vector<string>    VS;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef vector< PII > VPII;

#define PI 3.14159265359
#define mod 1000000007 // depend on your input
#define INF_MAX 2147483647
#define INF_MIN -2147483647
#define eps 1e-9

const LL OO = 1e8;

#define all(v) v.begin(),v.end()
#define srtva(v) sort(all(v))
#define srtvd(v) sort(v.rbegin(),v.rend())
#define srtaa(a,n) sort(a,a+n)
#define srtad(a,n) sort(a,a+n),reverse(a,a+n)

#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfi4(v1,v2,v3,v4) scanf("%d %d %d %d",&v1,&v2,&v3,&v4)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define sfll4(v1,v2,v3,v4) scanf("%I64d %I64d %I64d %I64d",&v1,&v2,&v3,&v4)
#define sfstr(v) scanf("%s", v)
#define sfch1(ch) scanf("%c",&ch)
#define chr getchar()
#define pi(x) printf("%d",x)
#define p2i(x,y) printf("%d %d",x,y)
#define pl(x) printf("%lld",x)
#define p2l(x,y) printf("%lld %lld",x,y)
#define pfstr(ch) printf("%s",ch)
#define pfch(ch) printf("%c",ch)
#define sf scanf
#define pf printf
void PLAY() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cout << fixed << setprecision(4);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

#define FI freopen("in.txt","r",stdin)
#define FO freopen("out.txt","w",stdout)
#define sz(v) (int)v.size()

#define nl printf("\n")
#define SS stringstream

#define pb push_back
#define mp make_pair

#define debug(x) cout<<#x<<" = { "<<x<<" }\n"

#define FOR(i,s,e) for(int i = s; i < e; i++)
#define FORD(i,e,s) for(int i=e-1,i>=s;i--)
#define lp(i,n) FOR(i,0,n)
#define lpd(i,n) FORD(i,n-1,0)
#define rev(i,s,e) FORD(i,s,e)
#define rep(i,v) FOR(i,0,sz(v))

LL gcd(LL a, LL b) { return !b ? a : gcd(b, a % b); }
LL lcm(LL a, LL b) { return (a / gcd(a, b)) * b; }

#define mem(ara,val) memset(ara,val,sizeof(ara))
#define ssz(a) strlen(a)

int n, k;
int main() {
    sfi2(n, k);
    VI vec(k+1, 0);
    while(n--){
        int num;
        sfi1(num);
        while(num!=0){
            vec[num%10]++;
            num/=10;
        }
    }
    int res=99999;
    rep(i, vec)
        if(vec[i] < res)res=vec[i];

    pi(res);

    return 0;
}


#include <bits/stdc++.h>
//#include "template.h"
using namespace std;
typedef long double   	  LD;
typedef vector<int>       VI;
typedef vector<double>    VD;
typedef vector< VI >      VVI;
typedef vector< VI >      VVD;
typedef vector<string>    VS;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef vector< PII > VPII;

#define PI 3.14159265359
#define mod 1000000007 // depend on your input
#define INF_MAX 2147483647
#define INF_MIN -2147483647
#define eps 1e-9

const LL OO = 1e8;

#define all(v) v.begin(),v.end()
#define srtva(v) sort(all(v))
#define srtvd(v) sort(v.rbegin(),v.rend())
#define srtaa(a,n) sort(a,a+n)
#define srtad(a,n) sort(a,a+n),reverse(a,a+n)

#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfi4(v1,v2,v3,v4) scanf("%d %d %d %d",&v1,&v2,&v3,&v4)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define sfll4(v1,v2,v3,v4) scanf("%I64d %I64d %I64d %I64d",&v1,&v2,&v3,&v4)
#define sfstr(v) scanf("%s", v)
#define sfch1(ch) scanf("%c",&ch)
#define chr getchar()
#define pi(x) printf("%d",x)
#define p2i(x,y) printf("%d %d",x,y)
#define pl(x) printf("%lld",x)
#define p2l(x,y) printf("%lld %lld",x,y)
#define pfstr(ch) printf("%s",ch)
#define pfch(ch) printf("%c",ch)
#define sf scanf
#define pf printf
void PLAY() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cout << fixed << setprecision(4);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

#define FI freopen("in.txt","r",stdin)
#define FO freopen("out.txt","w",stdout)
#define sz(v) (int)v.size()

#define nl printf("\n")
#define SS stringstream

#define pb push_back
#define mp make_pair

#define debug(x) cout<<#x<<" = { "<<x<<" }\n"

#define FOR(i,s,e) for(int i = s; i < e; i++)
#define FORD(i,e,s) for(int i=e-1,i>=s;i--)
#define lp(i,n) FOR(i,0,n)
#define lpd(i,n) FORD(i,n-1,0)
#define rev(i,s,e) FORD(i,s,e)
#define rep(i,v) FOR(i,0,sz(v))

LL gcd(LL a, LL b) { return !b ? a : gcd(b, a % b); }
LL lcm(LL a, LL b) { return (a / gcd(a, b)) * b; }

#define mem(ara,val) memset(ara,val,sizeof(ara))
#define ssz(a) strlen(a)

int n, k, res;
int main() {
    sfi2(n, k);
    while(n--){
        set<int> st;
        int num;
        sfi1(num);
        while(num!=0){
            st.insert(num%10);
            num/=10;
        }
        if(sz(st) == k+1)
            res++;

    }
    pi(res);
    return 0;
}


#include <bits/stdc++.h>
//#include "template.h"
using namespace std;
typedef long double   	  LD;
typedef vector<int>       VI;
typedef vector<double>    VD;
typedef vector< VI >      VVI;
typedef vector< VI >      VVD;
typedef vector<string>    VS;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef vector< PII > VPII;

#define PI 3.14159265359
#define mod 1000000007 // depend on your input
#define INF_MAX 2147483647
#define INF_MIN -2147483647
#define eps 1e-9

const LL OO = 1e8;

#define all(v) v.begin(),v.end()
#define srtva(v) sort(all(v))
#define srtvd(v) sort(v.rbegin(),v.rend())
#define srtaa(a,n) sort(a,a+n)
#define srtad(a,n) sort(a,a+n),reverse(a,a+n)

#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfi4(v1,v2,v3,v4) scanf("%d %d %d %d",&v1,&v2,&v3,&v4)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define sfll4(v1,v2,v3,v4) scanf("%I64d %I64d %I64d %I64d",&v1,&v2,&v3,&v4)
#define sfstr(v) scanf("%s", v)
#define sfch1(ch) scanf("%c",&ch)
#define chr getchar()
#define pi(x) printf("%d",x)
#define p2i(x,y) printf("%d %d",x,y)
#define pl(x) printf("%lld",x)
#define p2l(x,y) printf("%lld %lld",x,y)
#define pfstr(ch) printf("%s",ch)
#define pfch(ch) printf("%c",ch)
#define sf scanf
#define pf printf
void PLAY() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cout << fixed << setprecision(4);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

#define FI freopen("in.txt","r",stdin)
#define FO freopen("out.txt","w",stdout)
#define sz(v) (int)v.size()

#define nl printf("\n")
#define SS stringstream

#define pb push_back
#define mp make_pair

#define debug(x) cout<<#x<<" = { "<<x<<" }\n"

#define FOR(i,s,e) for(int i = s; i < e; i++)
#define FORD(i,e,s) for(int i=e-1,i>=s;i--)
#define lp(i,n) FOR(i,0,n)
#define lpd(i,n) FORD(i,n-1,0)
#define rev(i,s,e) FORD(i,s,e)
#define rep(i,v) FOR(i,0,sz(v))

LL gcd(LL a, LL b) { return !b ? a : gcd(b, a % b); }
LL lcm(LL a, LL b) { return (a / gcd(a, b)) * b; }

#define mem(ara,val) memset(ara,val,sizeof(ara))
#define ssz(a) strlen(a)

int n, k, res;
int main() {
    sfi2(n, k);
    while(n--){
        VI vec(k+1, 0);
        int num;
        sfi1(num);
        while(num!=0){
            vec[num%10]++;
            num/=10;
        }
        bool flag = true;
        rep(i, vec)
            if(vec[i] == 0)
                flag = false;
        if(flag)
            res++;

    }
    pi(res);
    return 0;
}


#include <bits/stdc++.h>
//#include "template.h"
using namespace std;
typedef long double   	  LD;
typedef vector<int>       VI;
typedef vector<double>    VD;
typedef vector< VI >      VVI;
typedef vector< VI >      VVD;
typedef vector<string>    VS;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef vector< PII > VPII;

#define PI 3.14159265359
#define mod 1000000007 // depend on your input
#define INF_MAX 2147483647
#define INF_MIN -2147483647
#define eps 1e-9

const LL OO = 1e8;

#define all(v) v.begin(),v.end()
#define srtva(v) sort(all(v))
#define srtvd(v) sort(v.rbegin(),v.rend())
#define srtaa(a,n) sort(a,a+n)
#define srtad(a,n) sort(a,a+n),reverse(a,a+n)

#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfi4(v1,v2,v3,v4) scanf("%d %d %d %d",&v1,&v2,&v3,&v4)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define sfll4(v1,v2,v3,v4) scanf("%I64d %I64d %I64d %I64d",&v1,&v2,&v3,&v4)
#define sfstr(v) scanf("%s", v)
#define sfch1(ch) scanf("%c",&ch)
#define chr getchar()
#define pi(x) printf("%d",x)
#define p2i(x,y) printf("%d %d",x,y)
#define pl(x) printf("%lld",x)
#define p2l(x,y) printf("%lld %lld",x,y)
#define pfstr(ch) printf("%s",ch)
#define pfch(ch) printf("%c",ch)
#define sf scanf
#define pf printf
void PLAY() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cout << fixed << setprecision(4);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

#define FI freopen("in.txt","r",stdin)
#define FO freopen("out.txt","w",stdout)
#define sz(v) (int)v.size()

#define nl printf("\n")
#define SS stringstream

#define pb push_back
#define mp make_pair

#define debug(x) cout<<#x<<" = { "<<x<<" }\n"

#define FOR(i,s,e) for(int i = s; i < e; i++)
#define FORD(i,e,s) for(int i=e-1,i>=s;i--)
#define lp(i,n) FOR(i,0,n)
#define lpd(i,n) FORD(i,n-1,0)
#define rev(i,s,e) FORD(i,s,e)
#define rep(i,v) FOR(i,0,sz(v))

LL gcd(LL a, LL b) { return !b ? a : gcd(b, a % b); }
LL lcm(LL a, LL b) { return (a / gcd(a, b)) * b; }
//ohmibod
#define mem(ara,val) memset(ara,val,sizeof(ara))
#define ssz(a) strlen(a)

int n, k;
int main() {
    VI vec (10);
    sfi2(n, k);
    while(n--){
        int x;
        sfi1(x);
        set<int> st;
        while(x!=0){
            st.insert(x%10);
            x/=10;
        }
        set<int>::iterator it = st.begin();
        while(it != st.end()){
            vec[*it]++;
            it++;
        }
    }

    int mn = 999;
    lp(i, k+1)
        if(vec[i] < mn)
            mn = vec[i];
    cout<<mn;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
string tam(int n){

  string a="";

  for(int i=0;i<=n;i++){
    a+='0'+i;
  }

  return a;
}

int main(){

  int n,m;
  string k="";
  cin >> m;
  scanf("%d ",&n);
  int count =0;
  while(m--){
    char z;
    set<char>letras;
    while(scanf("%c",&z),z!='\n' && z!=' '){

      letras.insert(z);
    }
    for(auto p:letras){
      k+=p;
    }

    sort(k.begin(),k.end());

    string b = tam(n);
    //k[n+1] = '\0';

    if(b==k){
      count++;
    }
    k.clear();
  }
  //  cout << b << endl;
  cout << count;

  return 0;
}


#include<bits/stdc++.h>
using namespace std;
string tam(int n){

  string a="";

  for(int i=0;i<=n;i++){
    a+='0'+i;
  }

  return a;
}

int main(){

  int n,m;
  string k="";
  cin >> m;
  scanf("%d ",&n);
  int count =0;
  while(m--){
    char z;
    set<char>letras;
    while(scanf("%c",&z),z!='\n' && z!=' '){
      letras.insert(z);
    }
    for(auto p:letras){
      k+=p;
    }

    sort(k.begin(),k.end());
    string b = tam(n);
    bool v = true;

    for(int i=0;i<n;i++){
      if(k[i]!=b[i]) v = false;
    }
    v?count++:0;
    k.clear();
  }
  //  cout << b << endl;
  cout << count;

  return 0;
}


#include<bits/stdc++.h>
using namespace std;
string tam(int n){

  string a="";

  for(int i=0;i<=n;i++){
    a+='0'+i;
  }

  return a;
}

int main(){

  int n,m;
  string k="";
  cin >> m;
  scanf("%d ",&n);
  int count =0;
  while(m--){
    char z;
    set<char>letras;
    while(scanf("%c",&z),z!='\n' && z!=' '){
      letras.insert(z);
    }
    for(auto p:letras){
      k+=p;
    }

    sort(k.begin(),k.end());
    string b = tam(n);
    bool v = true;
    // cout << b << endl << k << endl << endl;
    for(int i=0;i<=n;i++){
      if(k[i]!=b[i]) v = false;
    }
    v?count++:0;
    k.clear();
  }
  //  cout << b << endl;
  cout << count;

  return 0;
}


#include<bits/stdc++.h>
using namespace std;
string tam(int n){

  string a="";

  for(int i=0;i<=n;i++){
    a+='0'+i;
  }
  a+='\0';
  return a;
}

int main(){

  int n,m;
  string k="";
  cin >> m;
  scanf("%d ",&n);
  int count =0;
  while(m--){
    char z;
    set<char>letras;
    while(scanf("%c",&z),z!='\n' && z!=' '){

      letras.insert(z);
    }
    for(auto p:letras){
      k+=p;
    }

    sort(k.begin(),k.end());

    string b = tam(n);
    k[n+1] = '\0';

    if(b==k){
      count++;
    }
    k.clear();
  }
  //  cout << b << endl;
  cout << count;

  return 0;
}


#include<bits/stdc++.h>
using namespace std;
string tam(int n){

  string a="";

  for(int i=0;i<=n;i++){
    a+='0'+i;
  }

  return a;
}

int main(){

  int n,m;
  string k="";
  cin >> m;
  scanf("%d ",&n);
  int count =0;
  while(m--){
    char z;
    set<char>letras;
    while(scanf("%c",&z),z!='\n' && z!=' '){

      letras.insert(z);
    }
    for(auto p:letras){
      k+=p;
    }

    sort(k.begin(),k.end());

    string b = tam(n);
    k[n+1] = '\0';

    if(b==k){
      count++;
    }
    k.clear();
  }
  //  cout << b << endl;
  cout << count;

  return 0;
}


#include<bits/stdc++.h>
using namespace std;
string tam(int n){

  string a="";

  for(int i=0;i<=n;i++){
    a+='0'+i;
  }
  a+='\0';
  return a;
}

int main(){

  int n,m;
  string k="";
  cin >> m;
  scanf("%d ",&n);
  int count =0;
  while(m--){
    char z;
    set<char>letras;
    while(scanf("%c",&z),z!='\n' && z!=' '){

      letras.insert(z);
    }
    for(auto p:letras){
      k+=p;
    }

    sort(k.begin(),k.end());

    string b = tam(n);
    k[n+1] = '\0';

    if(b==k){
      cout << "ha" << endl;
      count++;
    }
    k.clear();
  }
  //  cout << b << endl;
  cout << count;

  return 0;
}


#include <iostream>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
int main() {
    long long n , cnt=0;
    long long k;
    set<int>v;
    cin>>n>>k;
    string str ;
    for( int i=0 ; i<n ; i++) {
        cin >> str;
        for (int j = 0; j < str.size(); j++) {
            if(str[j]<=k+'0') {
                v.insert(str[j]);
            }
        }
        if (v.size() == k + 1) {
            cnt++;
        }
        v.clear();
    }
    cout<<cnt;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
int main() {
    int n , cnt=0;
    int k;
    set<int>v;
    cin>>n>>k;
    string str ;
    for( int i=0 ; i<n ; i++) {
        cin >> str;
        for (int j = 0; j < str.size(); j++) {
            if(str[j]<=k+'0') {
                v.insert(str[j]);
            }
        }
        if (v.size() == k + 1) {
            cnt++;
        }
    }
    cout<<cnt;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
int main() {
    int n , cnt=0;
    int k;
    set<int>v;
    cin>>n>>k;
    string str ;
    for( int i=0 ; i<n ; i++) {
        cin >> str;
        for (int j = 0; j < str.size(); j++) {
            if(str[j]<=k+'0') {
                v.insert(str[j]);
            }
        }
        if (v.size() == k + 1|| k==0) {
            cnt++;
        }
    }
    cout<<cnt;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
int main() {
    int n , cnt=0;
    int k;
    set<int>v;
    cin>>n>>k;
    string str ;
    for( int i=0 ; i<n ; i++) {
        cin >> str;
        int c=0;
        for (int j = 0; j < str.size(); j++) {
            if (str[j] < k + '0') {
                v.insert(str[j]);
            }
            if(str[j]=='0'){
                c++;
            }
        }
        if ( v.size() == k + 1 || c > 0 ) {
            cnt++;
        }
    }
    cout<< cnt;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
int main() {
    int n , cnt=0;
    int k;
    set<int>v;
    cin>>n>>k;
    string str ;
    for( int i=0 ; i<n ; i++) {
        cin >> str;
        for (int j = 0; j < str.size(); j++) {
            v.insert(str[j]);
        }
        if (v.size() == k + 1|| k==0) {
            cnt++;
        }
    }
    cout<<cnt;
    return 0;
}