<commit_before><commit_msg>BOJ #1107: 리모컨<commit_after>/*
 * Author: <NAME> (ISKU)
 * Date: December 2, 2018
 * E-mail: <EMAIL>
 *
 * https://github.com/ISKU/Algorithm
 * https://www.acmicpc.net/problem/1107
 */

import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();

		Set<Integer> set = new HashSet<>();
		while (M-- > 0)
			set.add(sc.nextInt());

		int answer = Math.abs(N - 100);
		if (!set.contains(0)) {
			answer = Math.min(answer, N + 1);
		}

		for (int i = 1; i <= 999999; i++) {
			int n = i;
			int count = 0;
			boolean check = true;
			while (n > 0) {
				if (set.contains(n % 10)) {
					check = false;
					break;
				}
				n /= 10;
				count++;
			}

			if (check)
				answer = Math.min(answer, Math.abs(N - i) + count);
			answer = Math.min(answer, Math.abs(N - 100));
		}

		System.out.print(answer);
	}
}
{'fraction_non_alphanumeric': 0.18809776833156217, 'fraction_numerical': 0.03719447396386823, 'mean_word_length': 2.5413533834586466, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2835223', 'n_tokens_mistral': 458, 'n_tokens_neox': 376, 'n_words': 92}