phi-phi-phi
Tag(s):

## Easy, Math, Number Theory

Problem
Editorial
Analytics

Given n and k, calculate $\varphi(\varphi(...\varphi(n)...))$, where $\varphi$ applied exactly k times.

$\varphi(n)$ is Euler's totient function. $\varphi(1)=1$ by definition.

You can find the definition of Euler's totient function here.

### Input format

The only line of input contains two integers n and k ($1 \le n \le 10^{18}$, $1 \le k \le 10^{18}$).

### Output format

Print one integer - answer to the problem.

### Scoring

$n \le 10^{3}$, $k \le 10^{3}$ - 10 points

$n \le 10^{6}$, $k \le 10^{18}$ - 15 points

$n \le 10^{12}$, $k = 1$ - 10 points

$n \le 10^{12}$, $k \le 10^{18}$ - 10 points

$n \le 10^{15}$, $k = 1$ - 5 points

$n \le 10^{15}$, $k \le 10^{18}$ - 40 points

$n \le 10^{18}$, $k \le 10^{18}$ - 10 points

SAMPLE INPUT
12 2

SAMPLE OUTPUT
2

Explanation

$\varphi(12) = 4$ and $\varphi(4) = 2$

Time Limit: 2.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, Visual Basic

## CODE EDITOR

Initializing Code Editor...

## This Problem was Asked in

Challenge Name

October Clash '16

OTHER PROBLEMS OF THIS CHALLENGE
• Data Structures > Advanced Data Structures
• Algorithms > Graphs
• Algorithms > Graphs