This page is still under construction.

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

Ones

Time limit1sMemory limit128 MB

Summary
Given p and n, count how many times 2 and 3 divide the repunit 1 + p + ... + p^(n-1) in base p.
Level

Hard8 of 10

Topics
Number theory, Math
Solved
No attempts yet

Problem

Let aa be the natural number whose representation in base pp consists of the digit 11 repeated nn times in a row. In other words,

a=11⋯1⏟n=1+p+p2+⋯+pn−1=∑i=0n−1pia = \underbrace{11\cdots1}_{n} = 1 + p + p^2 + \cdots + p^{n-1} = \sum_{i=0}^{n-1} p^{i}

Find the greatest exponents of 22 and of 33 that divide aa. That is, write a program that finds the largest integer xx with 2x∣a2^{x} \mid a and the largest integer yy with 3y∣a3^{y} \mid a.

Input

The first line contains two natural numbers pp and nn separated by a space. (1<p<1091 < p < 10^9, 1≤n<1091 \le n < 10^9)

Output

Print two non-negative integers separated by a space: the greatest exponent xx of 22 that divides aa, followed by the greatest exponent yy of 33 that divides aa.

Examples2

  1. Example 1

    Input
    17 2
    
    Expected output
    1 2
    
  2. Example 2

    Input
    10 4
    
    Expected output
    0 0