#B3739. Odd-Even Digit Count Difference

    ID: 11398 Type: Default 1000ms 256MiB

Odd-Even Digit Count Difference

Odd-Even Digit Count Difference

Given two integers (a) and (n), compute (a^n) (i.e. (a) raised to the power (n)). Let the decimal representation of (a^n) be converted to a string. Define (A) as the count of odd digits (i.e. (1, 3, 5, 7, 9)) and (B) as the count of even digits (i.e. (0, 2, 4, 6, 8)) in that string. Your task is to calculate and output (A - B).

For example, when (a = 3) and (n = 12), we have (3^{12} = 531441). The odd digits are highlighted as (\boxed{5},\boxed{3},\boxed{1},4,4,\boxed{1}) (4 odd digits) and the even digits as (5,3,1,\boxed{4},\boxed{4},1) (2 even digits), so the answer is (4 - 2 = 2).

inputFormat

Input consists of a single line containing two integers (a) and (n) separated by a space.

outputFormat

Output a single integer which is the value of (A - B), where (A) is the count of odd digits and (B) is the count of even digits in the decimal representation of (a^n).

sample

3 12
2