Super Lucky Numbers

Some people believe that 13 is an unlucky number. So they always want to avoid the number 13. In some buildings you will find that there is no 13-th floor. After 12-th floor there is 14-th floor. In a number if there is no 13 (i.e. no “1” is followed by a “3”) then we may call it a super lucky number. For example, 12345 is a super lucky number. But if any number contains 13 then it is not a super lucky number such as 13254 or 21345. Given the number of digits N in a number and a base B, you have to find out how many super lucky numbers are possible with N digits in the base B. B should be greater than 3, as because the digit 3 is present in only for base 4 or more. Note that leading 0s are not significant. So, 011 is not a valid three digit number. Input There will be several lines in the input each containing two positive integers B and N, where 4 ≤ B ≤ 128 and N ≤ 100. A pair of zero will indicate the end of input and it should not be processed. Output For each line in the input print the count of super lucky numbers of N digits in the base B. Sample Input 42 53 00 Sample Output 11 91