第十三届JAVAB组决赛——2.数数
import java.io.*;
import java.util.*;
public class Main{
public static BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
public static PrintWriter stdOut = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
public static final int N = 110;
public static String[] s = new String[N];
public static int m;
public static boolean isLucky(int num) {
for(int i = 0; i < m; i++)
if(isSon(s[i], "" + num)) return false;
return true;
}
public static boolean isSon(String str, String o) {
StringBuffer o_ = new StringBuffer(o);
return o_.indexOf(str) != -1;
}
public static void main(String[] args) throws IOException{
long n = Long.parseLong(stdIn.readLine());
m = Integer.parseInt(stdIn.readLine());
for(int i = 0; i < m; i++)
s[i] = stdIn.readLine();
long ans = 0;
for(int num = 1; num <= n; num++)
if(isLucky(num)) ans++;
stdOut.println(ans);
stdOut.flush();
}
}