This page is still under construction.

Parts of this page are still being built. What you see may change.

K 2K Game

Interview

Time limit1sMemory limit256 MB

Summary
Print how many integers from 1 to N have a units digit different from both the units digits of K and 2K, then list those integers.
Level

Easy2 of 10

Topics
Implementation, Math, Brute force
Solved
No attempts yet

Problem

To test the concentration of new students, Psychim developed the following simple game.

  • Two integers NN and KK are given.
  • For a positive integer xx, let f(x)f(x) be the units digit of xx. You say all integers xx with 1≤x≤N1 \le x \le N such that f(x)≠f(K)f(x) \neq f(K) and f(x)≠f(2K)f(x) \neq f(2K), in increasing order.

Since you find it tedious to work out units digits one by one, you decide to write a program in secret to win the game. Write a program that prints the full list of numbers you must say.

Input

Two integers NN and KK are given, separated by a space.

Output

On the first line, print the count of numbers you must say.

On the second line, print all the numbers you must say on one line. If there are no numbers to say, leave the second line empty. The numbers must be printed in increasing order.

Constraints

  • 1≤N,K≤1051 \le N, K \le 10^5

Examples2

  1. Example 1

    Input
    9 4
    
    Expected output
    7
    1 2 3 5 6 7 9
    
  2. Example 2

    Input
    16 12
    
    Expected output
    12
    1 3 5 6 7 8 9 10 11 13 15 16