#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,k;
ll mul(ll a,ll b,ll p)
{
    if (b == 0) return 0;
    ll tmp = mul(a,b>>1,p);
    tmp = (tmp*2)%p;
    if (b&1) tmp = (tmp+a)%p;
    return tmp;
}
ll pow(ll a,ll t,ll p)
{
    if (t == 0) return 1;
    ll tmp = pow(a,t >> 1,p);
    tmp = mul(tmp,tmp,p);
    if (t&1) tmp = mul(tmp,a,p);
    return tmp;
}
int isprime(ll x)
{
    if (x == 1) return 0;
    int t = 20;
    while (t--)
    {
        ll tmp = rand()%(x-1)+1;
        ll y = pow(tmp,x-1,x);
        if (y != 1) return 0;
    }
    return 1;
}
ll f(ll x)
{
    ll tmp = x;
    for (ll i = 1;i*i <= x;i++)
    {
        if (x%i) continue;
        if (isprime(i)) tmp = (tmp/i)*(i-1);
        ll another = x/i;
        if (another != i)
            if (isprime(another))
                tmp = (tmp/another)*(another-1);
    }
    return tmp;
}
int main()
{
    cin >> n >> k;
    k = (k+1)/2;
    for (ll i = 1;i <= k;i++)
    {
        if (k-i+1 >= n) {n = 1; break;}
        n = f(n);
    }
    printf("%lld",n%1000000007);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define finish(x) {cout << x << endl; exit(0);}

ll n, k, ans;

ll phi(ll x){
    ll ret = 1;
    for(ll i = 2 ; i*i <= x ; i++){
        ll power = 1;
        while(x%i == 0){
            x /= i;
            power *= i;
        }
        ret *= power - power/i;
    }
    if(x != 1) ret *= x-1;
    return ret;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> k;
    k = (k+1)/2;
    while(n != 1 && k--)
        n = phi(n);
    cout << n%1000000007 << endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define ll long long int
const int mod = 1e9+7;

ll phi(ll num) {
    ll res = num;
    for (ll i = 2; i * i <= num; i++) {
        if (num %i == 0) {
            while (num % i == 0) {
                num /= i;
            }
            res -= res / i;
        }
    }
    if (num > 1) {
        res -= res/num;
    }
    return res;
}

int main() {
    ll n,k;
    scanf("%lld  %lld",&n,&k);
    if (k == 1 || n == 1) {
        printf("%lld\n", phi(n)%mod);
        return 0;

    }
    ll ans = 0;
    while (n > 1 && k > 0) {
        if (k % 2 == 1) {
            ans = phi(n);
            n = ans;
        }
        k--;
    }
    printf("%lld\n",ans%mod);
    return 0;

}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1e9+7;
void sprint(string s) {for (int i = 0; i < s.size(); ++i)	printf("%c",s[i]); printf("\n");}
ll power(ll a, ll b){
    ll x = 1, y = a;
    while (b > 0){
        if (b%2){
            x = (x*y);
        }
        y = (y*y);
        b /= 2;
    }
    return x;
}
ll f(ll n){
	if(n==1) return 1;
	ll ans=1;
	ll temp=n;
	for (ll i = 2; i*i <= n; ++i)
	{
		if(i>temp) break;
		ll c=0;
		while(temp%i==0){
			c++;
			temp/=i;
		}
		if(c) ans*=(power(i,c)-power(i,c-1));
	}
	if(temp==n)	return n-1;
	else if(temp!=1) return ans*(temp-1);
	else return ans;
}
int main(){
	ll n,k;
	cin>>n>>k;
	k=(k+1)/2;
	while(k--){
		n=f(n);
		if(n==1){
			cout<<1<<endl;
			return 0;
		}
	}
	cout<<n%mod<<endl;
	return 0;
}

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<cmath>
#include<cstring>
using namespace std;
#define maxn 10010
#define llg long long
#define md 1000000007
#define yyj(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout);

llg phi(llg x)
{
	llg m=sqrt(x+0.5);
	llg ans=x;
	for (llg i=2;i<=m;i++)
		if (x%i==0)
		{
			ans=ans/i*(i-1);
			while (x%i==0) x/=i;
		}
	if (x>1) ans=ans/x*(x-1);
	return ans;
}
llg n,m,k;
int main()
{
	//yyj("E");
	cin>>n>>k;
	llg ans=phi(n);
	for (llg i=2;i<=k;i++)
	{
		if (i%2) ans=phi(ans);
		if (ans==phi(ans)) break;
	}
	cout<<ans%md;
	return 0;
}

#include <bits/stdc++.h>

#define LL long long
#define MOD (LL)(1e9+7)

using namespace std;

const int N=2011110;
bool pr[N];
LL n,k;

void eratos(){
    memset(pr,true,sizeof(pr));
    pr[1]=false;
    for(int i=2;i<sqrt(N);i++)
        if(pr[i])
        for(int j=i*i;j<N;j+=i)
            pr[j]=false;
}

LL f(LL n){
    LL ans=1;
    for(LL i=1;i<=sqrt(n);i++)
    if(pr[i]&&n%i==0){
        LL cur=1,sub=0;
        while(n%i==0){
            n/=i;
            cur*=i;
        }
        ans*=(cur-(cur-1)/i-1);
    }
    if(n>1) ans*=(n-1);
    return ans;
}

LL g(LL n){
    return n;
}

int main(){
    #ifndef ONLINE_JUDGE
        freopen("776e.inp","r",stdin);
        freopen("776e.out","w",stdout);
    #endif // ONLINE_JUDGE
    eratos();
    cin>>n>>k;
    while(n>1&&k>0){
        n=f(n);
        k-=2;
    }
    cout<<n%MOD<<endl;
}

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define modd 1000000007
using namespace std;
long long n,k;
long long f(long long n)
{
	long long temp=n;
	for (long long i=2;i*i<=n;i++)
	if (n%i==0)
	{
		temp=temp/i*(i-1);
		while (n%i==0) n/=i;
	}
//	cout<<temp<<endl;
	if (n!=1)
	temp=temp/n*(n-1);
	return temp;
}
int main()
{
	cin>>n>>k;
	while (n!=1&&k>0)
	n=f(n),k-=2;//,cout<<n<<endl;
	cout<<n%modd<<endl;
	return 0;
}

#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <deque>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <cassert>
#include <unordered_set>
#include <climits>
#include <iomanip>
#include <unordered_map>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;
#define mset(a,b) memset(a,b,sizeof a)
#define pb push_back
#define mp make_pair
typedef vector<ll> vll;
const ll mod = 1000000007;
ll phi(ll n){
    ll ans = n;
    for(ll p = 2; p*p <= n; p++) if(n%p == 0){
        while(n%p == 0) n /= p;
        ans -= ans/p;
    }
    if(n > 1) ans -= ans/n;
    return ans;
}
ll G(ll n){
    ll ans = 0;
    ll lim = sqrt(n);
    for(ll e = 1; e <= lim; e++){
        if(n%e == 0){
            ans += phi(e);
            if(e*e != n) ans += phi(n/e);
        }
    }
    return ans;
}
int main(){
    ll n, k; cin >> n >> k;
    while(k > 0 && n > 1){
        if(k%2 == 1) n = phi(n);
        else n = G(n);
        k--;
    }
    cout << n%mod << endl;
    return 0;
}

#include <bits/stdc++.h>
#define PII pair<int,int>

using namespace std;
#define PN 1000000

bool isprime[PN+5];
vector<long long> prime;
void primechk(){
	for(int i=2;i<=PN;i++) isprime[i] = true;
	for(long long i=2;i<=PN;i++)
		if(isprime[i]){
            prime.push_back(i);
			for(long long j=i*i;j<=PN;j+=i)
				isprime[j] = false;
        }
}

long long n,k;

long long process(long long v){
    long long ret=1;
    for(auto now: prime){
        long long n1=1;
        while(v%now==0){
            v/=now;
            n1*=now;
        }
        if(n1!=0){
            ret*=(n1-(n1/now));
        }
    }
    if(v!=1) ret*=(v-1);
    return ret;
}

int main(){
	primechk();
    scanf("%lld %lld",&n,&k);
    k = (k+1)/2;
    while(k--){
        if(n!=1) n = process(n);
        if(k>n) n=1,k=1;
    }
    printf("%lld",n%1000000007);
	return 0;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
ll phi(ll n){
    ll ans=n,i;
    for(i=2;i*i<=n;i++){
        if(n%i==0){
            ans=ans-ans/i;
            while(n%i==0)n/=i;
        }
    }
    if(n>1)ans=ans-ans/n;
    return ans;
}
int main(){
	ll n,k;
	cin>>n>>k;
	while(k>0&&n>1){
		if(k%2==1)n=phi(n);
		k--;
	}
	cout<<n%1000000007<<endl;
	return 0;
}

/**************************
┆  ┏┓　　　┏┓        ┆
┆┏┛┻━━━┛┻┓      ┆
┆┃　　　　　　　┃      ┆
┆┃　　　━　　　┃      ┆
┆┃　┳┛　┗┳　┃      ┆
┆┃　　　　　　　┃      ┆
┆┃　　　┻　　　┃      ┆
┆┗━┓　  　┏━┛      ┆
┆　　┃　  　┃　　      ┆
┆　　┃　  　┗━━━┓  ┆
┆　　┃　  　　　　　┣┓┆
┆　　┃　        　　┏┛┆
┆　　┗┓┓┏━┳┓┏┛  ┆
┆　　　┃┫┫　┃┫┫    ┆
┆　　　┗┻┛　┗┻┛    ┆
***************************/
// 写这段代码的时候，只有上帝和我知道它是干嘛的
// 现在只有上帝知道
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstdio>
#include <iostream>
using namespace std;
//求单点n的欧拉函数 小于n且和n互质的正整数（包括1）的个数
long long euler(long long n) {
	long long i, ans = 1;
	for (i = 2; i*i <= n; i++) {
		if (n%i == 0) {
			n /= i; ans *= i - 1;
			while (n%i == 0) { n /= i; ans *= i; }
		}
	}
	if (n > 1)ans *= n - 1;
	return ans;
}
int main() {
	long long n, k; cin >> n >> k;
	k = (k + 1) / 2;
	while (k--)
	{
		if (n == 1)break;
		n = euler(n);
	}
	cout << n % 1000000007 << endl;
	return 0;
}

#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vc vector<char>
#define vll vector<ll>
#define pb push_back
#define sf scanf
#define pf printf
#define mp make_pair
#define all(V) V.begin,V.end
#define mod 1000000007
using namespace std;

/*ll phi(ll n)
{
    ll result = n;
    for (ll p=2; p*p<=n; ++p)
    {
        if (n % p == 0)
        {
            while (n % p == 0)
                n /= p;
            result -= result / p;
        }
    }
    if (n > 1)
        result -= result / n;
    return result;
}*/

ll  phi(ll x)
 {
   ll ret = 1,i,Pow;
   for (i = 2; x != 1; i++)
   {
     Pow = 1;
     if(i>sqrt(x))break;
     while (!(x%i))
     {
       x /= i;
       Pow *= i;
     }
     ret *= (Pow - (Pow/i));
    }
    if(x!=1)ret*=(x-1);
    return ret;
}

int main()
{
	ll n,k;
	cin>>n>>k;
	ll p=k/2 + k%2;
	while(p--)
	{
		if(n==1)
			break;
		n=phi(n);
//		n=n%mod;
	}
	cout<<n%mod<<endl;
	return 0;
}

//Okazaki Tomoya
//1.048596  Okabe Rintarou
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<ctime>
#include<queue>
#include<cmath>
using namespace std;
typedef long long LL;

inline LL getlong()
{
    bool f=0;LL x=0;char c=getchar();if(c==EOF) return EOF;
    while(c<'0'||c>'9'){if(c=='-')f=1;c=getchar();if(c==EOF) return EOF;}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    if(f)return -x;return x;
}

const int mod=1000000007;
LL n,k;
inline LL phi(LL u)
{
    LL ans=u;
    for(LL i=2;i*i<=u;i++)
        if(!(u%i)) {
            ans/=i,ans*=(i-1);
            while(!(u%i)) u/=i;
        }
    if(u>1) ans/=u,ans*=(u-1);
    return ans;
}

int main()
{
    n=getlong(),k=getlong();
    for(LL i=1;i<=k;i+=2) {
        n=phi(n); if(n==1) break;
    }
    cout<<n%mod;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;

#define sd(mark) scanf("%d",&mark)
#define ss(mark) scanf("%s",&mark)
#define sl(mark) scanf("%lld",&mark)
#define debug(mark) printf("check%d\n",mark)
#define clr(mark) memset(mark,0,sizeof(mark))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define LIM 1000000
#define ll long long
#define mod 1000000007
#define N 1000010

int isprime[N+10];
int List[N+10],pcnt=0;
int phi[N+10];

ll PHI(ll n)
{
	if(n<N)	return phi[n];
	ll sqrtn = sqrt(n)+5;
	ll ret=n;
	for(int i=0;i<pcnt && List[i] <= sqrtn;i++)
	{
		if(n%List[i] == 0)
		{
			ret=(ret/List[i])*(List[i]-1);
			while(n%List[i]==0)
				n/=List[i];
		}
	}
	if(n > 1)
		ret=(ret/n)*(n-1);
	return ret;
}

int main()
{
	int i,j;
	phi[1]=1;
	for(i=2;i<N;i++)
	{
		phi[i]=i;
		isprime[i]=1;
	}

	for(i=2;i<N;i++)
	{
		if(isprime[i]==0)	continue;
		List[pcnt++]=i;
		for(j=i;j<N;j+=i)
		{
			isprime[j]=0;
			phi[j] = (phi[j]/i)*(i-1);
		}
	}

	ll n,k;
	sl(n);sl(k);

	for(i=0;i<(k+1)/2;i++)
	{
		if(n==1)	break;
		n=PHI(n);
	}
	printf("%lld\n",n%mod);
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;
ll euler(ll n){
    ll res=n;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            res=res/i*(i-1);
            while(n%i==0)
                n/=i;
        }
    }
    if(n>1)
        res=res/n*(n-1);
    return res;
}
int main()
{
    ll n,k;
    scanf("%lld %lld",&n,&k);
    ll c=(k+1)/2;
    while(c--)
    {
        n=euler(n);
     // printf("%lld\n")
        if(n==1)
            break;
    }
    printf("%lld\n",n%mod);
}

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<int, LL> PIL;
typedef pair<LL, int> PLI;
typedef vector<int> VI;
typedef vector<PII> VPII;
typedef double DB;

#define pb push_back
#define mset(a, b) memset(a, b, sizeof a)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1 << (x))
#define bitl(x) (1LL << (x))
#define sqr(x) ((x) * (x))
#define sz(x) ((int)(x.size()))
#define cnti(x) (__builtin_popcount(x))
#define cntl(x) (__builtin_popcountll(x))
#define clzi(x) (__builtin_clz(x))
#define clzl(x) (__builtin_clzll(x))
#define ctzi(x) (__builtin_ctz(x))
#define ctzl(x) (__builtin_ctzll(x))

#define X first
#define Y second

#define Error(x) cout << #x << " = " << x << endl

template <typename T, typename U>
inline void chkmax(T& x, U y) {
	if (x < y) x = y;
}

template <typename T, typename U>
inline void chkmin(T& x, U y) {
	if (y < x) x = y;
}

long long calc(long long n, long long m) {
	if (m == 0) return n;
	if (n == 1) return 1;
	long long ret = n;
	for (int i = 2; 1LL * i * i <= n; i++) {
		if (n % i == 0) {
			ret -= ret / i;
			while (n % i == 0) n /= i;
		}
	}
	if (n > 1) ret -= ret / n;
	return calc(ret, m - 1);
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	long long n, m; scanf("%lld%lld", &n, &m);
	printf("%lld\n", calc(n, (m + 1) / 2) % 1000000007);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
const ll maxn = 1e5 + 5;
#define endl '\n'
#define ld long double
#define int ll
#define all(x)  (x).begin(),(x).end()

int phi(int n) {
    int result = n;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            while (n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if (n > 1)
        result -= result / n;
    return result;
}

int32_t main(){

  IOS

  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
  int n, k;
  cin >> n >> k;
  k = (k+1)>>1;
  for(int i  = 1;i<=k;i++){
    n = phi(n);
    if(n == 1) break;
  }
  cout << n%mod << endl;

}

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
using namespace std;
typedef long long LL;
#define sqr(x) ((x)*(x))
#define int long long
#define mp make_pair
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
int n,k;
inline int f(int x){
	int zs=x;
	for(int i=2;i*i<=x;i++)if(x%i==0){
		zs=zs/i*(i-1); while(x%i==0)x/=i;
	}
	if(x>1)zs=zs/x*(x-1);
	return zs;
}
inline int g(int x){
	return x;
}
inline int fk(int n,int k){
	int ans=g(n);
	for(int i=1;i<=k;i++){if(i&1)ans=f(ans); else ans=g(ans); if(ans==1)return 1;}
	return ans;
}
signed main(){
	int n=read(),k=read();
	cout<<fk(n,k)%1000000007<<endl;
}

#include<bits/stdc++.h>
#define ll long long

using namespace std;

ll phi(ll a)
{
    ll b=a;
    for(ll i=2;i*i<=a;i++)
    {
    	if(a%i==0)
    	{
        	while(a%i==0)
            a/=i;
        	b-=b/i;
    	}
    }
	if(a>1)
    {
    	b-=b/a;
    }
    return b;
}

int main(void)
{
	ll n,k,ans;
	cin>>n>>k;
	ans = n;

	k = (k+1)/2;
	while(k--)
	{
		ans = phi(ans);
		if(ans == phi(ans))
			break;
	}
	ans = ans%1000000007;
	cout<<ans<<endl;
}

#include <bits/stdc++.h>

using namespace std;

#define int long long

// f(n) is phi(n)
// g(n) is n

const int mod = 1e9 + 7;

int n, k;

int phi(int n)
{
	int ans = n;
	for (int i=2;i*i<=n;i++)
	{
		if (n%i == 0)
		{
			ans = ans - ans / i;
			while(n%i == 0)
				n /= i;
		}
	}
	if (n != 1)
		ans = ans - ans / n;
	return ans;
}

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	cin >> n >> k;
	while(k && n != 1)
	{
		if (k%2 == 1)
			n = phi(n);
		k--;
	}
	cout << n % mod;
}

#include<bits/stdc++.h>
#define LL long long
using namespace std;

LL n,k;

LL euler(LL n)
{
    LL ret=n;
    for(LL i=2; i*i<= n; i++)
        if(n%i==0)
        {
            ret-=ret/i;
            while(n%i==0) n/= i;
        }
    if(n>1) ret-=ret/n;
    return ret;
}

int main()
{
    cin >> n >> k;
    LL ans = euler(n);
    for(LL i = 2;i <= k;i++)
    {
        if(i%2) ans = euler(ans);
        if(ans == euler(ans))   break;
    }
    cout << ans%1000000007 << endl;
    return 0;
}

/**
▂▃▅▇█▓▒░۩۞۩ ۩۞۩░▒▓█▇▅▃▂
Make it happen now, not tomorrow.
Tomorrow is a  loser's excuse.
▂▃▅▇█▓▒░۩۞۩ ۩۞۩░▒▓█▇▅▃▂
**/
#ifndef _GLIbCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplu >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <cstring>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include<random>
#include <chrono>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplu >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <time.h>
#endif
#define __ ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
// #define INF 0x7f7f7f7f
#define ull unsigned long long int
#define pii pair<int,int>
#define ll long long int
#define ld long double
#define MSET(x,y) memset(x,y,sizeof(x))
// #define l long
#define se second
#define AlphaSize 26
#define fi first
#define NIL 0
#define UNVISITED -1
#define EXPOLORED 0
#define mk make_pair
#define pb push_back
#define sc(n) scanf("%d",&n)
#define NIL 0
#define pii pair<int,int>
#define eps 1e-8
#define all(x) x.begin(),x.end()
#define me(u,v,w) make_pair(w,make_pair(u,v))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define inrange(x,y,row,col) (x>=0 && y>=0 && x<row && y<col)
#define foreach(e, x) for(__typeof(x.begin()) e = x.begin(); e != x.end(); ++ e)
// #define add(a,b) (a + b >= MOD ? a+b-MOD:a+b)
#define hs(c1,c2) (256*min(c1,c2) + max(c1,c2))
typedef struct{ int sum,suf,pre,max;} Node;
int toint(const string &s) { stringstream ss; ss << s; int x; ss >> x; return x; }
const int MAXN = 2e5+100;
const int UP = 31;
// const ll inf = 1e18;
// const int mod = 1e9+7;
const ll highest = 1e18;
// const int inf = 1e9+10;
// const dou    ble pi = 3.141592653589793238462643383;
const double pi = acos(-1);
const double Phi =  1.618033988749894;
const int logn = 20;
const double root5 = 2.236067977;
const int inf = 1e9;
const int ini = -1e9;
/**
▂▃▅▇█▓▒░۩۞۩ ۩۞۩░▒▓█▇▅▃▂
Make it happen now, not tomorrow.
Tomorrow is a loser's excuse.
▂▃▅▇█▓▒░۩۞۩ ۩۞۩░▒▓█▇▅▃▂
**/
const ll mod = 1e9+7;
ll phi(ll n){
    ll i,res = n;
    for(i=2;i*i<=n;++i){
        if(n%i==0){
            while(n%i==0)n/=i;
            res -= (res/i);
        }
    }
    if(n != 1){
        res -= res/n;
    }
    return res;
}
int main(){
    ll n, k;
    cin>>n>>k;
    k = (k+1)/2;
    while(k--){
        n = phi(n);
        if(n==1)break;
    }
    cout<<n%mod<<endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,k;
    cin>>n>>k;
    ll no = (k+1)/2;
    while((n!=1)&&(no>0))
    {
        ll temp = n;
        if(temp%2==0)
        {
            n = n/2;
            while(temp%2==0)
            {
                temp/=2;
            }
        }
        for(ll i=3;i<=sqrt(temp);i+=2)
        {
            if(temp%i==0)
            {
                n = n/i;
                n = n*(i-1);
                while(temp%i==0)
                {
                    temp/=i;
                }
            }
        }
        if(temp>2)
        {
            n = n/temp;
            n = n*(temp-1);
        }
        no--;
    }
    n = n%1000000007;
    cout<<n<<"\n";
}

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,pair<ll,ll> >
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 1000009;
ll n,k,i;
ll phi(ll n)
{
    ll ans = n;
    if(n%2 == 0){
        while(n%2 == 0) n /= 2;
        ans /= 2;
    }
    for(ll i = 3;i <= sqrt(n);i += 2) if(n%i == 0){
        ans /= i;
        ans *= (i - 1);
        while(n%i == 0) n /= i;
    }
    if(n > 2){
        ans /= n;
        ans *= (n - 1);
    }
    return ans;
}
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n>>k;
    while(i < (k + 1) / 2 and n > 1){
        n = phi(n);
        i += 1;
    }
    cout<<n % mod;
    return 0;
}

#include<iostream>
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define int long long int
#define double long double
void fun(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
   #endif
}
int md=1e9+7;
int __gcd(int a, int b) {if(b==0) return a; return __gcd(b, a%b);}
int poww(int a, int b, int md) {if(b<0) return 0; if(a==0) return 0; int res=1;while(b) {if(b&1){res=(1ll*res*a)%md;}a=(1ll*a*a)%md;b>>=1;}return res;}
int poww(int a, int b) {if(b<0) return 0; if(a==0) return 0; int res=1;while(b) {if(b&1){res=(1ll*res*a);}a=(1ll*a*a);b>>=1;}return res;}
void ainp(int arr[], int n) {for(int i=1;i<=n;i++) cin>>arr[i];}
int divide(int a, int b, int md) {int rr=a*(poww(b, md-2, md));rr%=md;return rr;}

//important stuff
int totient(int num)
{
	int ans=num;
	for(int i=2;i*i<=num;i++)
	{
		int count=0;
		while(num%i==0) num/=i, count++;
		if(count) ans=ans-(ans/i);
	}
	if(num>1) ans=ans-ans/num;
	return ans;
}
signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);fun();
	int n, k;
	cin>>n>>k;
	k=(k+1)/2;
	while(k--&&n>1)
		n=totient(n);
	cout<<n%md<<"\n";

	return 0;
}

//f[i]-->phi[i]
//g[i]-->i
//ans=(k+1)/2层phi函数
//注意phi函数运算中不能取模，同时注意数据range
//O(min(k+1>>1,logk)*sqrt(n))
#include<iostream>
using namespace std;
typedef long long LL;
const int mod = 1e9 + 7;
LL phi (LL a){ // O(logn)
	LL ret = a;
	for (int i = 2; (LL)i*i <= a; i++)
		if (a % i == 0){
			ret = ret / i * (i - 1);
			while (a % i == 0) a /= i;
		}
	if (a > 1) ret = ret / a * (a - 1);
	return ret;
}
int main(){
	LL n, k;
	cin >> n >> k;
	k = k + 1 >> 1;
	for (int i = 1; i <= k && n > 1; i++)
		n = phi (n);
	cout << n % mod << endl;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long INT;

int main() {

	INT n, k;

	scanf("%I64d%I64d\n", &n, &k);

	INT ans=n;

	INT cnt=0;

	while (cnt<k) {

		for (INT i=2; i*i<=n; i++) {

			if (n%i) continue;

			while (n%i==0) n/=i;

			ans=ans/i*(i-1);

		}

		if (n>1) ans=ans/n*(n-1);

		n=ans;

		if (ans==1) break;

		cnt+=2;

	}

	cout << ans%1000000007 << endl;

	return 0;

}

#include<bits/stdc++.h>
using namespace std;

#define int long long
int n,k;

int qphi(int x)
{
	int ans = x;
	int qwq = x;
	for(int i = 2; i*i <= qwq; i ++) {
		if(x%i == 0) {
			ans = ans/i*(i-1);
	//		cout<<i<<"qwq\n";
		}
		while(x%i == 0)  {
			x /= i;
		}
		//cout<<x<<"\n";549755813888
	}
	if(x != 1) {
		ans = ans/x*(x-1);
	}
	return ans;
}

signed main()
{
	cin >> n >> k;
	int ans = n;
	for(k; k >= 1; k --) {
		if(k&1)
		{
			ans = qphi(ans);
		} else ;
		if(ans == 1)
		{
			cout<<ans;
			return 0;
		}
	}
	cout<<ans%1000000007;
	return 0;
}
/*
549755813888 2
f2(549755813888) = g()
*/

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

ll phi(ll n)
{
    ll result = n;
    for (ll i = 2; i * i <= n; i++)
    {
        if(n % i == 0) {
            while(n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if(n > 1)
        result -= result / n;
    return result;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	ll n,k;
	cin>>n>>k;

	k = ll((k+1LL)/2LL);

	while(k--&&n!=1)
	{
		n=phi(n);
	}

	cout << n%1000000007LL << endl;
}

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <cstring>
using namespace std;

#define pb push_back
#define ll long long

const int MOD=1e9+7;
const int MAX=1e6;

ll N,K;
int nonp[MAX+1];
vector<int> primes;
vector<int> exps;

void sieve(){
  for(int i=2;i<=MAX;i++){
    if(nonp[i]) continue;
    for(int j=i*2;j<=MAX;j+=i){
      nonp[j]=1;
    }
  }
  for(int i=2;i<=MAX;i++){
    if(!nonp[i]){
      primes.pb(i);
      exps.pb(0);
    }
  }
}

long long next(long long n){
  long long m=n;
  bool isprime=true;
  for(int i=0;i<primes.size();i++){
    if(n%primes[i]) continue;
    while(n%primes[i]==0) n/=primes[i];
    m=(m/primes[i])*(primes[i]-1);
  }
  if(n>1) m=m/n*(n-1);
  return m;
}
int main(){
    ios::sync_with_stdio(0);

    sieve();

    cin>>N>>K;
    for(ll i=0;i<(K+1)/2;i++){
      N=next(N);
      if(N==1) break;
    }

    cout<<(N%MOD)<<'\n';
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
const int N=3e6+1500;
typedef long long ll;
ll mod=1e9+7;
bool vis[N];
ll prime[N],phi[N];
ll cnt=0;
void Prime()
{
    ll n=3000150;
    vis[1]=1;phi[1]=1;
    for(int i=2;i<=n;i++)
    {
        if(!vis[i])
        {
            prime[++cnt]=i;
            phi[i]=i-1;
        }
        for(int j=1;j<=cnt&&i*prime[j]<=n;j++)
        {
            vis[i*prime[j]]=1;
            phi[i*prime[j]]=phi[i]*phi[prime[j]];
            if(i%prime[j]==0)
            {
                phi[i*prime[j]]=phi[i]*prime[j];
                break;
            }
        }
    }
    //cout<<cnt<<endl;
}
int main()
{
    Prime();
    ll n,k;
    cin>>n>>k;
    k=k+1;  k/=2;
    ll t=k,x=n,ans=n;
    while(t--)
    {
        x=ans,ans=1;
        if(x==1)
        {
            ans=1;  break;
        }
        if(x<=3000000)
        {
            ans=phi[x]; continue;
        }
        for(int i=1;i<=cnt;i++)
        {
            if(ll(prime[i]*prime[i])>x)
            {
                if(x!=1)
                {
                    ans*=(x-1); x=1;
                }
                break;
            }
            if(x%prime[i]==0)
            {
                ans*=(prime[i]-1);  x/=prime[i];
                while(x%prime[i]==0)
                {
                    x/=prime[i];ans*=prime[i];
                }
            }
        }
    }
    ans%=mod;
    cout<<ans<<endl;
    return 0;
}

#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<algorithm>
#include<ctime>
#define int long long
using namespace std;
const int mod=1e9+7;
int read()
{
	int kkk=0,x=1;
	char c=getchar();
	while((c<'0' || c>'9') && c!='-')
		c=getchar();
	if(c=='-')
		c=getchar(),x=-1;
	while(c>='0' && c<='9')
		kkk=(kkk<<3)+(kkk<<1)+(c-'0'),c=getchar();
	return kkk*x;
}
int n,K,pd[1000001],num[1000001],lim=1e6;
int ksm(int x,int y)
{
	int z=1;
	while(y)
	{
		if(y%2)
			z=z*x;
		x=x*x;
		y/=2;
	}
	return z;
}
int calc(int v)
{
	int bck=1;
	for(int i=1;i<=num[0] && num[i]<=v;++i)
		if(v%num[i]==0)
		{
			int cnt=0;
			while(v%num[i]==0)
			{
				++cnt;
				v/=num[i];
			}
			bck*=(num[i]-1)*ksm(num[i],cnt-1);
		}
	return bck*(v==1?1:v-1);
}
signed main()
{
	for(int i=2;i<=lim;++i)
	{
		if(!pd[i])
			num[++num[0]]=i;
		for(int j=1;j<=num[0] && i*num[j]<=lim;++j)
		{
			pd[i*num[j]]=1;
			if(i%num[j]==0)
				break;
		}
	}
	n=read(),K=(read()+1)/2;
	while(n!=1 && K)
	{
		--K;
		n=calc(n);
	}
	printf("%lld\n",n%mod);
	return 0;
}

#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cctype>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <string>
#include <queue>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <iomanip>
#include <utility>
#include <functional>

using namespace std;

#define mp make_pair
#define pb push_back
#define pf push_front
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int (i)=0;(i)<(n);++(i))
#define rep(i,st,ed) for(register int (i)=(st);(i)<=(ed);++(i))
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template<typename T> inline T qmin(const T a,const T b) {return a<b?a:b;}
template<typename T> inline T qmax(const T a,const T b) {return a>b?a:b;}
template<typename T> inline void getmin(T &a,const T b) {if(a>b) a=b;}
template<typename T> inline void getmax(T &a,const T b) {if(a<b) a=b;}

inline void fileio(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=1e9+7;
const ll linf=1e17+7;

ll phi(ll n){
	ll ans=n;
	for(ll i=2,ed=floor(sqrt(n));n!=1&&i<=ed;++i){
		if(n%i!=0) continue;
		while(n%i==0) n/=i;
		ans=ans/i*(i-1);
	}
	if(n!=1) ans=ans/n*(n-1);
	return ans;
}

int main(){
	ll n,k,times;
	cin>>n>>k;
	times=k+1>>1ll;
	while((times--)&&(n!=1)) n=phi(n);
	cout<<n%inf<<endl;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

ll f(ll n);
ll g(ll n);
ll h(ll n, ll k);

ll f(ll n) {
    if(n == 1) return 1;

    ll ans = 0;
    for(ll i = 1; i < n; i++) {
        if(__gcd(i,n-i) == 1) ans++;
    }

    return ans;
}

ll g(ll n) {
    ll ans = 0;
    // UNSURE OF BOUNDS
    for(ll i = 1; i <= n; i++) {
        if(n % i == 0) {
            ans += f(n/i);
        }
    }
    return ans;
}

string wrap(ll n) {
    string s;
    while(n > 0) {
        s.push_back((n % 10) + '0');
        n /= 10;
    }
    reverse(s.begin(),s.end());
    while(s.length() < 3) {
        s.push_back(' ');
    }
    return s;
}

ll h(ll n, ll k) {
    if(k == 1) {
        return f(g(n));
    }
    else if(k % 2 == 0) {
        return g(h(n,k-1));
    }
    else {
        return f(h(n,k-1));
    }
}

ll phi(ll n) {
    ll tempN = n;
    ll result = n;
    for(ll i = 2; i*i <= tempN; i++) {
        if(n % i == 0) {
            while(n % i == 0) {
                n /= i;
            }
            result -= result / i;
        }
    }
    if(n > 1) result -= result / n;
    return result;
}

int main() {
    /*
    for(ll n = 1; n <= 640; n++) {
        cout << "n = " << n << ":\t";
        for(ll k = 1; k < 16; k++) {
            cout << wrap(h(n,k)) << " ";
        }
        cout << endl;
    }
    */

    // Solution appears to be to apply Euler's Totient (k+1)/2 times (or until value is 1)

    ll n, k;
    cin >> n >> k;

    k++;
    k /= 2;

    while(k--) {
        n = phi(n);
        if(n == 1) break;
    }

    cout << (n % 1000000007) << endl;
}

#include<bits/stdc++.h>

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define len(s) s.length()
#define forp(i,a,b) for( i=a;i<=b;i++)
#define FOR(tt,a,b) for(int tt=a;tt<=b;tt++)
#define rep(i,n)    for( i=0;i<n;i++)
#define ren(i,n)    for( i=n-1;i>=0;i--)
#define forn(i,a,b) for( i=a;i>=b;i--)
#define all(v) v.begin(),v.end()
#define b(v) v.begin()
#define e(v) v.end()
#define mem(n,m) memset(n,m,sizeof(n))
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define pll pair<long long,long long>
#define vii vector<int>
#define vll vector<long long>
#define gl(cin,s)  getline(cin,s);
#define bitc(n) __builtin_popcountll(n)
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define boost ios_base::sync_with_stdio(0)
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define SIZE 100001

typedef long long  ll;
typedef unsigned long long ull;
typedef long double  ldo;
typedef double  db ;
using namespace std;
long long phi (long long n) {
    long long result = n;
    for (long long i=2; i*i<=n; ++i)
        if (n % i == 0) {
                    while (n % i == 0)
                        n /= i;
                    result -= result / i;
                }
    if (n > 1)
        result -= result / n;
    return result;
}
int main()
{
	/* #ifndef ONLINE_JUDGE
	freopen(fi, "r", stdin);
	#endif */
	//freopen("route.in","r",stdin);
	//freopen("route.out","w",stdout);
	//cin.ignore();
	//cin.clear();
	boost;
	//cin.tie(0);
	//cout<<"Case #"<<tt<<": ";
	ll n,k;
	cin>>n>>k;
	ll i=1;
	while(1){
		if(n==1 or i>k)
		break;
		if(i%2)
		n=phi(n);
		i++;
	}
	cout<<n%MOD<<endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define sz(a) (int)((a).size())
#define fuck() cout<<"--------"<<endl
#define see(x) cout<<#x<<" = "<<x<<endl
#define see2(x,y) cout<<#x<<" = "<<x<<"::"<<#y<<" = "<<y<<endl
const int mod=1000000007;
typedef pair<int,int> pii;
const int inf=1e18;
const int N=1e5+5;
int phi(int n){
	int res=n;
	for(int i=2;i*i<=n;i++){
		if(n%i==0){
			while(n%i==0)
				n/=i;
			res-=res/i;
		}
	}
	if(n>1)res-=res/n;
	return res;
}
int go(int n,int k){
	if(n==1)return 1;
	if(k==0)return n;
	return go(phi(n),k-1);
}
void HyperBeast(){
	int n,k;
	cin>>n>>k;
	k++;k/=2;
	cout<<go(n,k)%mod;
}
int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	int T=1;
	//cin>>T;
	while(T--){
		HyperBeast();
		cout<<endl;
	}
}

#include<bits/stdc++.h>
using namespace std;
const int mod=1000000007;
long long f(long long n)
{
	long long phi=1;
	for(int i=2;i*1ll*i<=n;++i)
	{
		if(n%i==0)
		{
			n/=i;
			phi*=i-1;
			while(n%i==0)
			{
				n/=i;
				phi*=i;
			}
		}
	}
	if(n>1)
		phi*=n-1;
	return phi;
}
int main()
{
	long long n,k,F=0;
	cin>>n>>k;
	F=f(n);
	for(long long i=2;i<=k;++i)
	{
		if(F==1)
			break;
		if(i%2)
			F=f(F);
	}
	cout<<F%mod<<endl;
	return 0;
}

#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<string>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>
#define MAXN 1000000
#define INF 1000000000000LL
#define pii pair<int,int>
#define MP(a,b) make_pair((a),(b))
#define lowbit(x) ((x)&(-(x)))
using namespace std;
bool vis[MAXN+80];
int pri[MAXN+80];
void prepare(int x)
{
	int k=sqrt(MAXN+0.5),i,j;
	for(i=2;i<=k;i++)
		if(vis[i]==0)
		{
			pri[++pri[0]]=i;
			for(j=i*i;j<=x;j+=i)
				vis[j]=1;
		}
	while(i<=MAXN)
	{
		if(vis[i]==0)
			pri[++pri[0]]=i;
		i++;
	}
	return ;
}
long long phi(long long x,long long K)
{
	if(x==1||x<K)
		return 1;
	int k=sqrt(x+0.5),i;
	long long ret=1;
	for(i=1;i<=pri[0]&&pri[i]<=k;i++)
		if(x%pri[i]==0)
		{
			ret*=pri[i]-1;
			x/=pri[i];
			while(x%pri[i]==0)
			{
				x/=pri[i];
				ret*=pri[i];
			}
		}
	if(x>1)
		ret*=(x-1);
	if(K==1)
		return ret;
	else
		return phi(ret,K-2);
}
int main()
{
	long long n,k;
	cin>>n>>k;
	prepare(sqrt(n+0.5));
	cout<<phi(n,k-((k&1)==0))%1000000007;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define pb(x)           push_back(x)
#define mp              make_pair
#define sz(x)           x.size()
#define mem(x ,y)       memset(x , y , sizeof x )
#define all(a )         a.begin() , a.end()
#define endl            "\n"
#define pii             pair<int,int>
#define clr(x)          x.clear()
#define sl(x )          scanf("%I64d" ,&x)
#define si(x )          scanf("%d" ,&x)
#define forn(i ,x,n )   for(int i = x ; i <= n ; i++ )
#define ford(i ,x,n )   for(int i = x ; i >= n ; i-- )
#define rep(i,n )       for(int i= 0; i<n ; i++ )
#define repi(i,n )      for(int i= 1; i<=n ; i++ )
#define repit(i, c)     for( __typeof((c).begin()) i = (c).begin(); i != (c).end();++i )
#define dbg(args...)    do {   cerr << #args << ' ' ;  print(args); } while(0); cerr<< endl ;
typedef long long ll  ;
ll mod1 =  1e9+7, mod2 = 998244353 ;
ll  mod  =  mod1 ;
typedef unsigned long long  ull ;
int setbit(int n, int pos  ) { return n = n|(1<< pos) ; }
int resetbit(int n,int pos ) {  return n =  n & ~(1<<pos ); }
bool checkbit(int  n,int pos ) { return (bool ) (n&(1<<pos))  ; }
template < typename T > T mul(T x, T y, T mod = mod ) { x %= mod ; y %= mod ; return (x*y)%mod  ;  }
template < typename T > T add(T x, T y, T mod = mod ) { x %= mod ; y %= mod ; return (x+y)%mod ;  }
template < typename T > T sub(T x, T y, T mod = mod ) { x %= mod ; y %= mod ; return ((x-y)%mod+mod )%mod;  }
template < typename T > T ext_gcd(T num1 , T num2, T &X , T &Y ) { T r2,r1, q2, q1 , x2, x1, y2 ,y1 , x,  y, r   ; x2 = 1; y2 = 0;  x1 = 0; y1 = 1; for( r2 =num1 ,r1 = num2 ;r1 != 0 ; y2 = y1, y1 = y,x2 = x1 ,x1 = x ,r2 = r1, r1 = r) {q1 = r2/r1; x = x2 - q1*x1; y = y2 - q1*y1; r = r2%r1 ; } X = x2 ; Y = y2 ; return r2 ;  }
template < typename T > void print(const T& v) {    cerr << v << ' ' ;}
template < typename T1, typename... T2 > void print( const T1& first, const T2&... rest ){ print(first); print(rest...) ;}
template<class T> string to_str(T t){stringstream ss; ss<<t; return ss.str();}
template < typename T >
T  bigmod(T x, T k ,T mod = mod) {
    if(k == 0 ) return (T)1;
    if(k&1  ) {
        return ( (x%mod)*bigmod(x,k-1, mod )%mod )%mod ;
    } else {
        T ret = bigmod(x,k/2  , mod ) ;
        ret %= mod ;
        return (ret*ret )%mod;
    }

}
template < typename T >
T  invmod( T x , T m) {
    return bigmod(x,m-2 , m) ;
    // long long ret, t ;//
    // ext_gcd( x, m ,ret ,t  ) ;
    // ret %= m ; if(ret<0) ret += m  ;
    // return ret;
}
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// typedef tree< int   ,     // change type
//               null_type,
//               less_equal  < int >  ,  // change type ..
//               rb_tree_tag,
//               tree_order_statistics_node_update> ordered_set;
// less for set and  less_equal  for multiset
// order_of_key (k) : Number of items strictly smaller than k
// find_by_order(k) : K-th element in a set (counting from zero) returns iterator
// debuging ...
template<typename T >
void dbg_a(T a[] ,int n=10 ) {
    cerr << "[ ";
        for(int i=0;i < n ; i++ )
            cerr<<a[i]<<' ' ;
                cerr<< " ]" <<  endl;
}
template < typename F,  typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "[ " << p.first << ", " << p.second << " ]";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "[ ";
        for(int i=0; i<sz(v) ; i++ )
            os << v[i] << ' ' ;
                return os << " ]\n" ;
}
template < typename T >
ostream &operator << ( ostream & os, const map< T ,T> &Map  ) {
    os << "[ ";
        repit(it , Map )
            os << "[" <<(*it).ff << ' ' << (*it).ss << "] "    ;
                return os << "]\n" ;
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &Set  ) {
    os << "[ ";
        repit(it , Set )
            os <<  *it  << ' ' ;
                return os << " ]\n" ;
}
// int dx[] = {0 , 0 ,+1, -1 } ;
// int dy[] = {-1, +1,0 , 0 };
// int dx[ 10 ] =  {-2,-2, 2, 2  ,+ 1, -1  , +1, -1 }  ;
// int dy[ 10 ] =  {+1,-1, 1, -1 , +2,+2 , -2,-2  }  ;
const int maxn  = (int )1e6+123 ;
const int inf  =  1e9+1223 ;

#define  int  ll
///////////////////////////////////////////////////////////////

int  n ,k ;
int func(int x )  {
    int ans = x;
    for(int i = 2 ; i*i <= x; i++) {
        int cnt = 0 ;
        if(x%i == 0 ) {
            ans /=  i ;
            ans *= (i-1 ) ;
            while(x%i ==0  ) x/=i ;

        }

    }
    if( x> 1  )  ans/=x  ,ans *=  (x-1 ) ;
    return ans ;

}
void solve( ) {
    int x, y, q  ,m  ;
    cin >> n >>  k  ;

    k = (k+1)/2LL   ;

    forn(i,  1, k ) {
        if(n==1 ) break;
        n = func(n) ;

    }

    cout << n%mod  << endl;
}
signed main() {
    #ifndef ONLINE_JUDGE
       freopen("in.txt", "r", stdin);
          // freopen("out.txt", "w", stdout);
    #endif
    ios :: sync_with_stdio(false);  cin.tie(0);
    cout.tie(0) ;
    clock_t st = clock() ;
    // cout << fixed << setprecision(12) ;
    int  c = 0 ,t = 1 ;
    // cin>>t ;
    while(t--) {
        solve()  ;
    }
    // cerr << "Execution time : " << (double  )  (clock()-st )/CLOCKS_PER_SEC << endl ;
    // 25f  486 26 5

    return 0 ;

}

#include<bits/stdc++.h>
using namespace std;
#define test() int t;scanf("%d",&t);for(int tno=1;tno<=t;tno++)
#define mp make_pair
#define pb push_back
#define wl(n) while(n--)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long ll;
typedef unsigned long long llu;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,pair<int,int> > piii ;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
#define sz(a) int((a).size())
#define ini(a,v) memset(a,v,sizeof(a))
#define sc(x) scanf("%d",&x)
#define sc2(x,y) scanf("%d%d",&x,&y)
#define sc3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define scl(x) scanf("%lld",&x)
#define scl2(x,y) scanf("%lld%lld",&x,&y)
#define scl3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define scs(s) scanf("%s",s);
#define gcd __gcd
#define debug() printf("here\n")
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define tr(container, it)  for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define MOD 1000000007
#define inf ((1<<29)-1)
#define linf ((1LL<<60)-1)
const double eps = 1e-9;
//-----------------------------------------------------------------------------------------------

const int MAX = 1000009;

ll a[MAX]={0};
ll prime[MAX],cp=0;
void sieve(){
	int i,j;
	a[0] = a[1] = 1;
	for(i=2;i<MAX;i++){
		if(!a[i]){
			for(j=2*i;j<MAX;j+=i){
				a[j] = 1;
			}
		}
	}
	prime[cp++] = 2;
	for(i=3;i<MAX;i+=2){
		if(!a[i]){
			prime[cp++] = i;
		}
	}
}
ll phi(ll x){
	ll i,j;
	ll ans = x;
	for(i=0;prime[i]*prime[i]<=x;i++){
		ll y = prime[i];

		if(x%y==0){

			ans = ans/y;
			ans = ans*(y-1);
			while(x%y==0)
				x/=y;
		}
	}
	if(x>1)
		ans = ans/x,ans*=(x-1);
	return ans;
}
int main()
{
	int i,j;
	ll n,k;
	sieve();
	scl2(n,k);

	for(i=1;i<=k&&n>1;i+=2){

		n = phi(n);
	}
	printf("%lld\n",n%MOD);
	return 0;
}
/*
500000000023 2
999996529
*/

//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=1000005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int phi(int n)
{
    int result = n;
    for (int i = 2; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            while (n % i == 0)
            n /= i;
            result -= result / i;
        }
    }
    if (n > 1)
    result -= result / n;
    return result;
}
int32_t main()
{
    IOS;
    int n,k;
    cin>>n>>k;
    k=(k+1)/2;
    for(int i=0;i<k&&n>1;i++)
    n=phi(n);
    cout<<n%mod;
}

#include<bits/stdc++.h>
using namespace std;
#define mst memset
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define F5 fflush(stdout)
#define pc putchar
#define ptf printf
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
inline void scf(int &x){scanf("%d",&x);}
inline void scf(ll &x){scanf("%I64d",&x);}
inline void scf(double &x){scanf("%lf",&x);}
inline void scf(char &x){scanf("%c",&x);}
inline void scf(char *x){scanf("%s",x);}
const int N=2e5+7;
const int mars=0x3c3c3c3c;
typedef int Arr[N];
typedef char Err[N];
typedef bool Brr[N];
ll m,n,k,w,a,b,c,l,s,t,r,p,q,x,y,cnt;
ll Ola(ll t){
	ll i,m,s=1;
	for(i=2;i*i<=t;i++){
		m=1;
    	while(t%i==0)m*=i,t/=i;
    	if(m>1)s*=m-m/i;
	}
    if(t>1)s*=t-1;
    return s;
}
ll P(ll n,ll k){
	if(n==1)return 1;
	if(k==1)return Ola(n);
	else if(k&1)return Ola(P(n,k-1));
	else return P(n,k-1);
}
int main(){
	int i,j;
	scf(n),scf(k);
	while(k){
		if(n==1)break;
		if(k&1)n=Ola(n);
		k--;
	}
	printf("%I64d",n%1000000007ll);
}

// powered by c++11
// by Isaunoya

#include<bits/stdc++.h>
#define rep(i , x , y) for(register int i = (x) ; i < (y) ; i ++)
using namespace std ;
using db = double ;
using ll = long long ;
using uint = unsigned int ;
#define int long long
using pii = pair < int , int > ;
#define ve vector
#define Tp template
#define all(v) v.begin() , v.end()
#define sz(v) ((int)v.size())
#define pb emplace_back
#define fir first
#define sec second

// the cmin && cmax
Tp < class T > void cmax(T & x , const T & y) {
	if(x < y) x = y ;
}
Tp < class T > void cmin(T & x , const T & y) {
	if(x > y ) x = y ;
}

// sort , unique , reverse
Tp < class T > void sort(ve < T > & v) {
	sort(all(v)) ;
}
Tp < class T > void unique(ve < T > & v) {
	sort(all(v)) ;
	v.erase(unique(all(v)) , v.end()) ;
}
Tp < class T > void reverse(ve < T > & v) {
	reverse(all(v)) ;
}

int qwq(int x) {
	int res = x ;
	for(int i = 2 ; i <= sqrt(x) ; i ++) {
		if(! (x % i)) {
			res = res / i * (i - 1) ;
			while(! (x % i)) x /= i ;
		}
	}
	if(x > 1) res = res / x * (x - 1) ;
	return res ;
}
signed main() {
	ios_base :: sync_with_stdio(false) ;
	cin.tie(nullptr) , cout.tie(nullptr) ;
// code begin.
	int n , k ;
	cin >> n >> k ;
	while(k && n > 1) {
		if(k & 1) n = qwq(n) ;
		k -- ;
	}
	cout << n % 1000000007 << '\n' ;
	return 0 ;
// code end.
}

#include"bits/stdc++.h"
using namespace std;

typedef long long LL;
LL n,k;

LL phi (LL n){
	LL res = 1;
	for (int i=2; 1ll*i*i<=n; i++){
		if (n%i==0){
			res = res * (i-1), n /= i;
			while (n % i == 0)
				res = res * i, n /= i;
		}
	}
	if (n > 1) res *= n-1;
	return res;
}

int main(){
	cin>>n>>k;
	while (k > 0 && n != 1){
		n = phi(n);
		k -= 2;
	}
	cout << n%1000000007 << endl;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define MODULUS 1000000007

ll gcd(ll a, ll b) {
  ll mi = min(a,b);
  ll mx = max(a, b);
  if(mx % mi == 0) {
    return mi;
  }
  return gcd(mi, mx % mi);
}

ll f(ll n) {
  if(n == 1) {
    return 1;
  }
  for(ll i = 2; i * i <= n; i++ ) {
    if(n % i == 0) {
      ll arg1 = i;
      while(n % arg1 == 0) {
        arg1 *= i;
      }
      arg1 /= i;
      // printf("n = %lld, arg1 = %lld, arg2 = %lld\n", n, arg1, n / arg1);
      if(n / arg1 == 1) {
        return arg1 - arg1 / i;
      }
      return f(arg1) * f(n / arg1);
    }
  }
  return n - 1;
}

ll F(ll n, ll k) {
  if(k == 1 || k == 2) {
    return f(n);
  }
  // compose f(n) k / 2 times
  ll currentAns = n;
  for(ll i = 1; i <= (k + 1) / 2; i++ ) {
    currentAns = f(currentAns);
    if(currentAns == 1) break;
  }
  return currentAns;
}

int main() {
  ll N, K;
  cin >> N >> K;
  cout << F(N, K) % MODULUS << endl;
  // for(int i = 1; i <= 100; i++ ) {
  //   cout << f(i) << endl;
  // }
  // cout << f(3) << endl;
  return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <climits>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cassert>
#include <cmath>
using namespace std;

#define trace(x) {cerr << #x << "=" << x <<endl;}
#define trace2(x, y) {cerr << #x << "=" << x << " " << #y << "=" << y <<endl;}
template <typename T> ostream& operator<<(ostream& os, const vector<T> &p){os << "[ "; for (T x: p) os << x << " "; os << "]" << endl; return os;}
template <typename T> ostream& operator<<(ostream& os, const set<T> &p){os << "{ "; for (T x: p) os << x << " "; os << "}" << endl; return os;}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const map<Tk, Tv> &p){os << "{ "; for (pair<Tk, Tv> x: p) os << x << " "; os << "}" << endl; return os;}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const pair<Tk, Tv> &p){os << "{" << p.first << ',' << p.second << "}";return os;}

typedef long long ll;

const int MOD = 1000000000+7;
const int INF = 1000000000;
const int MAX = 100005;

/*int f1(int n) {
    if (n == 1) return 1;
    int count = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++) {
            if (__gcd(i, j) == 1) {
                if (i + j == n) {
                    count++;
                }
            }
        }
    }
    return count;
}

ll g1(vector<int> &f, int n) {
    ll count = 0;
    for (int i = 1; i <= n; i++) {
        if (n % i == 0) {
            count += f[i];
        }
    }
    return count;
}

int main() {
    int n = 100;
    vector<int> f(n+1);
    vector<ll> g(n+1);
    for (int i = 1; i <= n; i++) {
        f[i]=f1(i);
    }
    for (int i = 1; i <= n; i++) {
        g[i]=g1(f, i);
    }
    cout << f << endl;
    cout << g << endl;
    ll F[105][105];
    for (int k = 1; k <= n; k++) {
        for (int i = 1; i <= n; i++) {
            if (k == 1) {
                F[k][i] = f[i];
            } else if (k % 2 == 0){
                F[k][i] = g[F[k-1][i]];
            } else if (k % 2 == 1) {
                F[k][i] = f[F[k-1][i]];
            }
        }
    }
    for (int i = 1; i <= 20; i++) {
        for (int j = 0; j <= 25; j++) {
            cout << F[i][j] << " ";
        }
        cout << endl;
    }
}*/

vector<bool> isprime;
vector<int> primes;
void sieve(int n) {
	isprime.resize(n + 1);
	for (int i = 0; i <= n; i++) {
		isprime[i] = true;
	}
	isprime[1] = false; isprime[2] = true;
	for (int i = 2; i <= n; i++) {
		if (isprime[i]) {
			for (int j = 2*i;  j < n; j+=i) {
					isprime[j] = false;
			}
		}
	}
	for (int i = 2; i < n; i++) {
		if (isprime[i]) {
			primes.push_back(i);
		}
	}
	return;
}

/**
 * Description: Calculates n^m (Binary exponentiation)
 * Usage: power O(lg(M))
 * Source: https://github.com/dragonslayerx
 */

#define MOD 1000000007
long long power(long long n, long long m)
{
    if (m == 0) return 1;
    long long x = power(n, m / 2);
    if (!(m & 1)) return (x * x) % MOD;
    else return (((x * x) % MOD) * n) % MOD;
}

long long euler(long long n) {
    long long Answer = n;
    for (int i = 0; i < primes.size(); i++) {
        if (n % primes[i] == 0) {
            Answer *= primes[i]-1;
            Answer /= primes[i];
        }
        while (n % primes[i] == 0) n /= primes[i];
        if (n == 1) break;
    }
    if (n == 1) {
        return Answer;
    } else {
        return Answer/n * (n-1);
    }
}

int main() {
    sieve(1000005);
    long long n, k;
    cin >> n >> k;
    if (k >= 100000000) {
        cout << 1 << endl;
    } else {
        long long Answer = n;
        for (int i = 1; i <= k; i += 2) {
            Answer = euler(Answer);
        }
        cout << Answer % MOD << endl;
    }
}

#include <iostream>
using LL = long long;
LL n, k;
LL phi(LL n) {
    LL res = n;
    for (LL i = 2; i * i <= n; i++) if (n % i == 0) {
        res = res / i * (i - 1);
        do n /= i; while (n % i == 0);
    }
    if (n > 1) res = res / n * (n - 1);
    return res;
}
int main() {
    std::cin >> n >> k;
    for (k = k + 1 >> 1; k && n > 1; k--) n = phi(n);
    std::cout << n % 1000000007 << std::endl;
    return 0;
}

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const long long maxn = 1000010, p = 1000000007;
long long n, k, MX = 1000001;
long long prime[maxn], pcnt;
bool is[maxn];
void init(){
	is[1] = 1;
	for(int i = 2; i <= MX; i ++){
		if(is[i] == 0) prime[++pcnt] = i;
		for(int j = 1; i*prime[j] <= MX; j ++){
			is[i*prime[j]] = 1;
			if(i%prime[j] == 0) break;
		}
	}
}
long long phi(long long n){
	if(n == 1) return 1;
	long long res = n;
	for(int i = 1; i <= pcnt && i <= n/prime[i]; i ++){
		if(n%prime[i] == 0){
			res = res / prime[i] * (prime[i] - 1);
			while(n%prime[i] == 0) n /= prime[i];
		}
	}
	if(n != 1) res = res / n * (n-1);
	return res;
}
int main(){
	scanf("%I64d%I64d", &n, &k);
	k = (k+1)/2; MX = min(n, 1000005LL); init();
	while(k --){
		n = phi(n);
		if(n == 1) break;
	}
	printf("%I64d", n%p);
	return 0;
}

#include <bits/stdc++.h>
#define ll long long
using namespace std;

ll n, k;

ll phi(ll n){
    ll res = n;
    for (ll i = 2; i*i <= n; ++i) {
        if(n%i) continue;
        while(n%i == 0){
            n /= i;
        }
        res = res/i*(i-1);
    }
    if(n > 1) res = res/n*(n-1);
    return res;
}

int main()
{
    cin >> n >> k;

    for (int i = 1; i <= k; i += 2) {
        n = phi(n);
        if(n == 1) break;
    }

    cout << n%1000000007 << endl;

    return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;

#define N 100005
#define mod 1000000007

vector<int>v;

int a[N];

long long n,m,k,z,t,i,j,x,y,l,r,mid,ans,now;

long long euler(long long x){
     long long res=x,p=x;
     for(i=2;i*i<=p;i++){
         if(p%i==0){
             res=res/i*(i-1);
             while(p%i==0)p/=i;
         }
     }
     if(p>1)res=res/p*(p-1);
     return res;
}

int main()
{
	scanf("%I64d%I64d",&n,&k);
	if(!(k%2))k--;
	while(n>1&&k>0)
	{
		n=euler(n);
		k-=2;
	}
	printf("%I64d\n",n%mod);
	return 0;
}

#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<bitset>
#include<algorithm>
#include<map>
using namespace std;
const int maxn = 1234567;
long long md = 1000000007;
map<long long, long long> f;
long long F(long long x){
	if (f[x] != 0) return f[x];
	long long num = x;
	long long ed = (long long)sqrt(x);

	for (long long i = 1; i <= ed; i ++){
		if (x % i == 0){
			num -= F(i);
			if (i * i != x && i != 1)
				num -= F(x / i);
		}
	}

	return f[x] = num;
}
long long k, n;
int main(){
	cin >>n >>k;
	k = (k - 1) / 2;
	f[1] = 1;
	long long ans = F(n);
	for (long long i = 1; i <= k; i ++){
		if (ans == 1) break;
		ans = F(ans);
	}
	cout <<ans % md<<endl;

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define MOD         1000000007
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        '\n'
#define PI          3.14159265359d
#define sz(x)       (int)x.size()
ll phi(ll n)
{
    ll i,res=n;
    for(i=2;i*i<=n;i++)
        if(n%i==0)
    {
        while(n%i==0)
            n/=i;
        res-=res/i;
    }
    if(n>1)
        res-=res/n;
    return res;
}
int main()
{
    ll n,k,res;
    cin>>n>>k;
    res=n;
    k=(k+1)/2;
    while(k--)
    {
        res=phi(res);
        if(res==1)
            break;
    }
    cout<<res%MOD;
    return 0;
}

#include <bits/stdc++.h>
#define mod 1000000007
#define inf 1e13
using namespace std;
typedef long long ll;
ll n,k;
ll phi(ll n){
    ll ans=n;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            ans=ans/i*(i-1);
            while(n%i==0) n/=i;
        }
    }
    if(n>1) ans=ans/n*(n-1);
    return ans;
}
int main()
{
    scanf("%I64d %I64d",&n,&k);
    ll ans=n;
    for(ll i=1LL;i<=k;i++){
        if(i%2) ans=phi(ans);
        if(ans==1) break;
    }
    printf("%I64d\n",ans%mod);
}

#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <vector>
#include <set>
#include <algorithm>
#include <iomanip>
#include <map>
#include <cassert>
#include <stack>
#include <cmath>
#include <bitset>
#include <ctime>
#include <unordered_map>
using namespace std;
typedef long long Long;

int gcd(int a,int b){
	return b==0 ? a : gcd(b,a%b);
}
int eu(int n){
	int cnt = 0;
	for(int i = 1; i <= n; ++i){
		cnt += gcd(i,n) == 1;
	}
	return cnt;
}
Long fastTotient(Long n){
	if(n <= 0)return 0;
	Long f = 1;
	for (Long i = 2; i*i <= n; ++i) {
		if(n%i == 0){
			Long c = 0, p = 1;
			while(n % i == 0){
				n /= i;
				c++;
				p *= i;
			}
			f *= (i*p - p) / i;
		}
	}
	if(n != 1){
		f *= (n - 1);
	}
	return f;
}
int F(int n){
	return eu(n);
}
int S(int n){
	int r = 0;
	for(int i = 1; i <= n; ++i){
		if(n%i == 0){
			r += F(n/i);
		}
	}
	return r;
}
int main() {

	Long N,K;
	cin >> N >> K;
	vector<Long> V(1,fastTotient(N));
	while(V.back() != 1){
		Long n = V.back();
		V.push_back(n);
		n = V.back();
		V.push_back(fastTotient(n));
	}
	K--;
//	for (int i = 0; i < V.size(); ++i) {
//		cout << V[i] << endl;
//	}
	if(K < V.size()){
		cout << V[K] % 1000000007 << endl;
	}else{
		cout << 1 << endl;
	}

    return 0;
}

#include<stdio.h>
typedef long long lnt;
lnt phi(lnt n)
{
	lnt ret=n;
	for(lnt i=2;i*i<=n;i++)
		if(n%i==0)
		{
			ret=ret/i*(i-1);
			while(n%i==0)
				n/=i;
		}
	return n>1?ret/n*(n-1):ret;
}
int main()
{
	lnt i,k,n;
	scanf("%I64d%I64d",&n,&k);
	k=(k+1)/2;
	while((k--)&&n>1)
		n=phi(n);
	printf("%I64d\n",n%1000000007);
	return 0;
}

#include <set>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <string>
#include <map>
#include <algorithm>
#include <stdlib.h>
//#include <optimization.h>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <deque>

using namespace std;

const long long mod = 1000000007;

int main(){
    //freopen("sat3.in", "r", stdin);
    //freopen("sat3.out", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0);
    long long n, k;
    cin >> n >> k;
    long long num = (k+1)/2ll;
    vector<long long> v;
    for (int i = 0; i < num; i++){
        v.clear();
        long long nn = n;
        for (int j = 2; j*1ll*j<=nn; j++)
            if (nn%j==0){
                v.push_back(j);
                while (nn % j == 0)
                    nn /= j;
            }
        if (nn != 1)
            v.push_back(nn);
        long long ans = 0;
        for (int m = 0; m < (1ll<<v.size()); m++){
                long long p = 1;
                int sz = 0;
                for (int j = 0; j < v.size(); j++)
                    if ((m& (1 << j)) != 0){
                        p *= v[j];
                        sz++;
                    }
                if (sz % 2 == 0)
                    ans += n/p;
                else
                    ans -= n/p;
        }
        n = ans;
        if (n==1){
            cout << 1;
            return 0;
        }
    }
    cout << n%mod;
    return 0;
}

#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
const long long H = 1e9 + 7;
long long n,k;
bool snt[1000005];
vector <long long> m;
void read()
{
    scanf("%I64d%I64d",&n,&k);
    if(k > 200) k = 200;
    return;
}

void san()
{
    for (int i = 2;i <= 1000000;i++) snt[i] = true;
    snt[1] = false;
    for (int i = 1;i <= 1000;i++)
    if(snt[i])
        for (int j = i;j <= 1000000/i ;j++) snt[i * j] = false;
    for (int i = 1;i <= 1000000;i++) if(snt[i]) m.push_back(i);
    return;
}

long long ff(long long so)
{
    long long kq = so;
    for (int i = 0 ; i < m.size();i++)
        if(so % m[i] == 0)
        {
            long long tim = m[i];
            kq = kq / m[i] * (m[i] - 1);
            while (so % m[i] == 0) so /= m[i];
        }
    if(so > 1) kq = kq / so * (so - 1);
    return kq;
}

long long tinhf(long long bac,int so)
{
    if(bac == 0) return n;
    if(so == 1) return ff(tinhf(bac - 1,1 - so)); else return tinhf(bac - 1,1 - so);
}

void solve()
{
    if(k % 2 == 0) printf("%I64d",tinhf(k,0) % H); else printf("%I64d",tinhf(k,1) % H);
    return;
}

int main()
{
    san();
    read();
    solve();
    return 0;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<set>
#include <queue>
#include <map>
#include <algorithm>
#include <vector>
#include <cmath>
#define maxnum 150000

using namespace std;

long long gcd(long long m,long long n){
    if(m==0) return n;
    if(n==0) return m;
    if(m%2==0&&n%2==0) return 2*gcd(m/2,n/2);
    else if(m%2==0) return gcd(m/2,n);
    else if(n%2==0) return gcd(m,n/2);
    else
        return gcd( min(m,n), fabs(m-n) );
}
long long  lcm(long long x , long long y ){
    return x/gcd(x,y)*y;
}
long long Euler(long long t ){
    long long k = (long long) sqrt( t );
    while( k*k <= t)
        k++ ;
    k--;
    long long ans = t ;
    for( long long i = 2 ; i <= k ; i ++ ){
        if( t % i == 0){
            ans = ans / i * ( i - 1 ) ;
            while( t % i == 0)
                t = t/i;
        }
    }
    if( t > 1 ) ans = ans / t* (t - 1 );
    return  ans ;
}
int main()
{
    long long i ,  j, k , n ;
    while( ~ scanf("%lld %lld" , &n , &k)){
            k = ( k+1 )/2;
    while( (k--) && n > 1 )
        n = Euler(n);
    cout << (n%1000000007);
    }
    return 0;
}

#include <cstdio>
#include <string.h>
#include <vector>
using namespace std;

typedef long long ll;
const ll mod = 1e9+7;
const int MAXX = 2e6+10;

ll phi(ll n) {
	ll ret = n;
	for(ll i=2;i*i<=n;i++) {
		if(n%i==0) {
			while(n%i==0) n/=i;
			ret -= ret/i;
		}
	}
	if(n>1) ret -= ret/n;
	return ret;
}

int main() {
	ll n, k;
	scanf("%lld %lld", &n, &k);

	k = (k+1)/2;
	ll ans = n;
	while(k--) {
		ans = phi(ans);
		if(ans==1) break;
	}
	printf("%lld", ans%mod);

	return 0;
}

#pragma warning(disable:4786)
#pragma comment(linker, "/STACK:102400000,102400000")
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<cmath>
#include<string>
#include<sstream>
#include<bitset>
#define LL long long
#define FOR(i,f_start,f_end) for(int i=f_start;i<=f_end;++i)
#define mem(a,x) memset(a,x,sizeof(a))
#define lson l,m,x<<1
#define rson m+1,r,x<<1|1
using namespace std;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const double PI = acos(-1.0);
const double eps=1e-6;
const int maxn = 1e6 + 5;
int isprime[maxn],prime[maxn];
int pnum ;
void find_prime(int n)
{
    pnum = 0;
    mem(prime, 0);
    mem(isprime, 1);
    for(int i = 2 ; i < n ; i++){
        if(isprime[i])      prime[pnum++] = i;
        for(int j = 0; j<pnum && i * prime[j] < n ; j++){
            isprime[i * prime[j] ] = 0;
            if(i % prime[j] == 0)       break;
        }
    }
}
LL phi(LL n)
{
    LL ret = n;
    for(int i = 0 ; prime[i] * prime[i] <= n && i < pnum; i++){
        if(n % prime[i] == 0){
            ret = ret / prime[i] * (prime[i] - 1);
            while(n % prime[i] == 0){
                n /= prime[i];
            }
        }
    }
    if(n > 1)   ret = ret / n * (n - 1) ;
    return ret;
}
LL solve(LL time , LL n)
{
    LL last = n , cur = n;
    for(LL i = 1 ;i <= time;i ++){
        cur = phi(cur);
        if(cur == last)     return cur;
        last = cur;
    }
    return cur;
}
int main()
{
    LL k , n;
    scanf("%lld %lld" , &n , &k);
    find_prime(1e6 + 2);
    LL ans = solve((k + 1)/ 2 , n);
    printf("%lld\n",ans % mod);
    return 0;
}

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <iostream>
#include <cassert>
#include <cmath>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>

using namespace std;

#define INF 1e+9
#define mp make_pair
#define pb push_back
#define fi first
#define fs first
#define se second
#define i64 long long
#define li long long
#define lint long long
#define pii pair<int, int>
#define vi vector<int>

#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define fore(i, b, e) for (int i = (int)b; i <= (int)e; i++)

const int limit = 1e6;

map <i64, i64> M;
bool mark[limit + 5];
vi primes;

int gcd(int x, int y) {
    return y == 0 ? x : gcd(y, x % y);
}

int f1(int x) {
    if (x == 1)
        return 1;
    int ans = 0;
    fore(j, 1, x - 1)
        if (gcd(j, x - j) == 1)
            ans++;
    return ans;
}

i64 f(i64 x) {
    i64 result = x;
    for (int d = 2; (i64)d * d <= x; ++d) {
        if (x % d == 0) {
            while(x % d == 0)
                x /= d;
            result -= result / d;
        }
    }
    if (x != 1)
        result -= result / x;
    return result;
}

int main() {
#ifdef LOCAL
    //freopen("outp", "w", stdout);
#else
    // freopen(TASKNAME ".in", "r", stdin);
    // freopen(TASKNAME ".out", "w", stdout);
#endif
    i64 n, k;
    cin >> n >> k;
    for (i64 it = 0; it < (k + 1) / 2; ++it) {
        if (n == 1)
            break;
        n = f(n);
    }
    int MOD = 1e9+7;
    cout << n % MOD;
}

#include <bits/stdc++.h>
using namespace std;
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define dforr(i, a, b) for(int i = (int)(b-1); i >= (a); i--)
#define dforn(i, n) dforr(i, 0, n)
#define db(v) cerr << #v << " = " << v << endl
#define pb push_back
#define sz(x) ((int)x.size())
#define fst first
#define snd second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
const int MAXN = -1;

ll n, k;

map<ll, int> F;
void fact(ll n){
    F.clear();
    for(ll p = 2; p*p <= n; p++){
        while(n%p == 0)F[p]++, n/=p;
    }
    if(n > 1)F[n]++;
}

ll Phi(ll n){
    fact(n);
    for(auto t : F) n -= n/t.fst;
    return n;
}

vector<int> D;
void getdiv(ll n){
    D.clear();
    for(ll d = 1; d*d <= n; d++){
        if(n%d == 0)D.pb(d), D.pb(n/d);
        if(d*d == n)D.pop_back();
    }
    sort(D.begin(), D.end());
}

int main(){
//	freopen("input.txt", "r", stdin);
	while(scanf("%lld %lld", &n, &k) >= 1){
        k = (k+1)/2;
        while(k && n > 1) n = Phi(n), k--;
        printf("%lld\n", n%((int)1e9+7));
	}
	return 0;
}

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <istream>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <cmath>
#include <queue>
#include <set>
#include <utility>
#include <time.h>
#include <iomanip>
#define st(x) do{ x } while (__LINE__ == -1)
#define CHS(x,y) CHS2(x,y)
#define CHS2(x,y) x##y
#define COUNT_PARMS2(_1,_2,_3,_4,_5,_6,_,...) _
#define COUNT_PARMS(...) COUNT_PARMS2(__VA_ARGS__,6,5,4,3,2,1)
#define PFV_1(_1) printf(" "#_1"=%lld",_1)
#define PFV_2(_1,...) st(PFV_1(_1);PFV_1(__VA_ARGS__);)
#define PFV_3(_1,...) st(PFV_1(_1);PFV_2(__VA_ARGS__);)
#define PFV_4(_1,...) st(PFV_1(_1);PFV_3(__VA_ARGS__);)
#define PFV_5(_1,...) st(PFV_1(_1);PFV_4(__VA_ARGS__);)
#define PFV_6(_1,...) st(PFV_1(_1);PFV_5(__VA_ARGS__);)
#define pfv(...) st( printf("line:%d ",__LINE__);\
                    CHS(PFV_,COUNT_PARMS(__VA_ARGS__))(__VA_ARGS__);\
                    printf("\n");)
typedef long long ll;
typedef long double ld;
using namespace std;
const double eps = 1e-6;
//const double PI = acos(-1);
const int mod = 1e9;
const int INF = 0x3f3f3f3f;
const int seed = 131;
const ll INF64 = ll(1e18);
const int maxn = 1e5+5;
typedef pair<ll,ll> PII;
int dx[] = {1,0,-1,0,0};
int dy[] = {0,-1,0,1,0};
int arr[maxn];
ll phi1(ll n){
    ll ans = n,i;
    for( i = 2; i*i <= n; i++){
        if(n%i == 0){
            ans = ans/i*(i-1);
            while(n%i == 0)
                n/=i;
        }
    }
    if(n > 1) ans = ans/n*(n-1);
    return ans;
}
ll n,k;
void solve()
{
    cin.sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    k = (k+1)/2;
    ll res = n;
    while(k--){
        res = phi1(res);
        if(res == 1LL) break;
    }
    cout << res%1000000007 << endl;
}

int main()
{
    solve();

    return 0;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define fo(i,a,b) for(int i=a;i<b;i++)
#define fo_(i,a,b) for(int i=a;i>b;i--)
#define M(a) memset(a,0,sizeof a)
#define M_(a) memset(a ,-1,sizeof a)
#define debug(x)  cerr << #x << " = " << x << endl
#define pb push_back
#define F first
#define S second
#define OK order_of_key
#define FO find_by_order
#define PI 3.14159265
#define nmax 100100
const ll inf = std::numeric_limits<ll>::max();
const int infint = std::numeric_limits<int>::max();
const ll mod = 1e9+7;
using namespace __gnu_pbds;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ll f(ll n){
    if(n==1) return 1;
    vector<pll> v;
    fo(i,2,min(n,(ll)1e6)+1){
        if(n%i == 0){
            int c = 0;
            while(n%i == 0){
                n/=i;
                c++;
            }
            v.pb({i,c});
        }
    }
    if(n!=1){
        v.pb({n,1});
    }
    ll out = 1;
    for(auto i : v){
        ll now = 1;
        fo(j,0,i.S-1) now*=i.F;
        out *= now;
        out *= i.F - 1;
    }
    return out;
}

int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    ll n,k;
    cin >> n >> k;
    k++;
    k /= 2;
    while(n!=1 && k > 0){
        k--;
        n = f(n);
    }
    cout << n%mod;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;

const int MOD = 1e9 + 7;

int i, j;
long long n, k;
bool c[1000005];
vector<int> primes;

long long phi(long long x) {
  long long ans = x;

  for(auto it : primes) {
    if(1LL * it * it > x) break;
    if(x % it) continue;

    ans -= ans / it;
    while(x % it == 0) x /= it;
  }

  if(x > 1) ans -= ans / x;

  return ans;
}

int main() {
  ios_base::sync_with_stdio(0);

  for(i = 2; i <= 1e6; ++i)
    if(!c[i]) for(primes.push_back(i), j = i + i; j <= 1e6; j += i) c[j] = 1;

  cin >> n >> k;

  k = (k + 1) / 2;
  while(k && n > 1) n = phi(n), --k;

  cout << n % MOD << '\n';

  return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <vector>
#include <bitset>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

ll n,k;

ll f(ll N)
{
	ll r = N;
	for (ll i = 2;i * i <= N;i++)
		if (N % i == 0)
		{
			r = r / i * (i - 1);
			while (N % i == 0)
				N /= i;
		}
	if (N > 1)
		r = r / N * (N - 1);
	return r;
}

ll F(ll N,ll K)
{
	if (K == 1)
		return f(N);
	if (N == 1)
		return 1;
	return (K & 1) ? F(f(N),K - 1) : F(N,K - 1);
}

int main()
{
	scanf("%lld%lld",&n,&k);
	printf("%lld\n",F(n,k) % 1000000007);
	return 0;
}

/**************************
┆  ┏┓　　　┏┓        ┆
┆┏┛┻━━━┛┻┓      ┆
┆┃　　　　　　　┃      ┆
┆┃　　　━　　　┃      ┆
┆┃　┳┛　┗┳　┃      ┆
┆┃　　　　　　　┃      ┆
┆┃　　　┻　　　┃      ┆
┆┗━┓　  　┏━┛      ┆
┆　　┃　  　┃　　      ┆
┆　　┃　  　┗━━━┓  ┆
┆　　┃　  　　　　　┣┓┆
┆　　┃　        　　┏┛┆
┆　　┗┓┓┏━┳┓┏┛  ┆
┆　　　┃┫┫　┃┫┫    ┆
┆　　　┗┻┛　┗┻┛    ┆
***************************/
// 写这段代码的时候，只有上帝和我知道它是干嘛的
// 现在只有上帝知道
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstdio>
#include <iostream>
using namespace std;
//求单点n的欧拉函数 小于n且和n互质的正整数（包括1）的个数
long long euler(long long n) {
	long long i, ans = 1;
	for (i = 2; i*i <= n; i++) {
		if (n%i == 0) {
			n /= i; ans *= i - 1;
			while (n%i == 0) { n /= i; ans *= i; }
		}
	}
	if (n > 1)ans *= n - 1;
	return ans;
}
int main() {
	long long n, k; cin >> n >> k;
	k = (k + 1) / 2;
	while (k--)
	{
		if (n == 1)break;
		n = euler(n);
	}
	cout << n % 1000000007 << endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
long long euler(long long n){
    long long i,ans=1;
    for(i=2;i*i<=n;i++){
        if(n%i==0){
            n/=i;ans*=i-1;
            while(n%i==0){n/=i;ans*=i;}
        }
    }
    if(n>1)ans*=n-1;
    return ans;
}
int main(){
//	freopen("a.txt","r",stdin);
	long long n,k;
	cin>>n>>k;
	while(k>=1&&n!=1)n=euler(n),k-=2;
	cout<<n%1000000007<<endl;
	return 0;
}

#include <iostream>

using namespace std;

#define long long long

const long MOD = 1e9+7;

long n, k;

long Euler(long n)
{
    long tmp = n, re = n;
    for (long i = 2; i*i <= tmp; ++i)
        if (n % i == 0)
        {
            while (n % i == 0) n /= i;
            re -= re / i;
        }
    if (n > 1) re -= re / n;
    return re;
}

void Solve()
{
    if (!(k & 1)) --k;
    while (k > 0 && n > 1)
    {
        n = Euler(n);
        k -= 2;
    }
    cout << n % MOD;
}

int main()
{
    cin >> n >> k;
    Solve();
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

static long long N, K;

inline long long phi(long long x)
{
    long long ret = x;
    for (long long i = 2; i * i <= x; i++)
        if (x % i == 0)
        {
            ret = ret / i * (i - 1);
            while (x % i == 0)
                x /= i;
        }
    if (x != 1)
        ret = ret / x * (x - 1);
    return ret;
}

int main()
{
    scanf("%lld%lld", &N, &K);
    K = (K + 1) / 2;
    for (auto i = 0; i < K; i++)
    {
        if ((N = phi(N)) == 1)
            break;
    }
    printf("%lld\n", N % 1000000007);
    return 0;
}

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

ll totient(ll x) {
  ll ret = 1;
  long long p = 2;
  ll v = x;
  while (v > 1 && p * p <= v) {
    int cnt = 0;
    while (v % p == 0) {
      cnt++;
      v /= p;
    }
    if (cnt > 0) {
      REP(i, 0, cnt - 1) {
	ret *= p;
      }
      ret *= p - 1;
    }
    p += p == 2 ? 1 : 2;
  }
  if (v > 1) {
    ret *= v - 1;
  }
  return ret;
}

ll calc(ll n, ll k) {
  ll cur = n;
  // This loop will not continue so long; cur decreases quickly.
  for (ll i = 0; i < k; ++i) {
    ll res = totient(cur);
    cur = res;
    if (cur == 1) {
      break;
    }
  }
  return cur % mod;
}

int main(void){
  ll n, k;
  cin >> n >> k;
  k = (k + 1) / 2;
  // I want f^k(n)!
  cout << calc(n, k) << endl;
}

#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define PI 3.14159265358979
#pragma 03
using namespace std;
ll mod = 1e9 + 7;
ll n, k, phi;
int main(){
    ll i;
    cin >> n >> k;
    for (ll tt = 1; tt <= k && n != 1; tt += 2){
        phi = n;
        for (ll i = 2; i<=sqrt(n); i++){
            if (n % i == 0){
                phi = phi / i * (i - 1);
                while (n % i == 0) n /= i;
            }
        }
        if (n != 1) phi = phi / n * (n - 1);
        n = phi;
    }
    cout << n % mod;
}

#include <bits/stdc++.h>

#define FOR(i,n)    for(lli i=0;i<(lli)(n);++i)
#define FORU(i,j,k) for(lli i=(j);i<=(lli)(k);++i)
#define FORD(i,j,k) for(lli i=(j);i>=(lli)(k);--i)

#define pb push_back
#define mt make_tuple

using namespace std;

using lli = long long int;
using pll = pair<lli, lli>;

using vi = vector<lli>;
using vvi = vector<vi>;
using pii = tuple<lli, lli>;
using vii = vector<pii>;
using vvii = vector<vii>;

#define X(a) get<0>(a)
#define Y(a) get<1>(a)
#define Z(a) get<2>(a)

string TYPE(const int*)          { return "%d";   }
string TYPE(const lli*)          { return "%lld"; }
string TYPE(const char*)         { return "%c";   }
string TYPE(const char**)        { return "%s";   }
string TYPE(const unsigned int*) { return "%u";   }

const int MAX_BUF = 100*1000+42;
char buf[MAX_BUF];

void RD() {}
template<typename T, typename... Args>
void RD(T* v, Args... args)
{
    scanf((" " + TYPE(v)).c_str(), v);
    RD(args...);
}
template<typename... Args>
void RD(string* v, Args... args)
{
    scanf(" %s", buf);
    (*v) = buf;
    RD(args...);
}

void PR(bool nl = true)
{ if(nl) printf("\n"); }
template<typename T, typename... Args>
void PR(bool nl, T v, Args... args)
{
    printf((TYPE(&v) + " ").c_str(), v);
    PR(nl, args...);
}
template<typename... Args>
void PR(bool nl, string& v, Args... args)
{
    printf("%s", v.c_str());
    PR(nl, args...);
}
template<typename... Args>
void PR(Args... args)
{ PR(true, args...); }

const long long int oo = 1000*1000*1000;

struct Coord {
    int x, y;
    Coord(int x = 0, int y = 0) : x(x), y(y) {}
    Coord operator + (const Coord& droite) const
    { return Coord(x + droite.x, y + droite.y); }
};

struct AB {
    int k; vector<lli> arbre;
    AB(int _k = 20, lli def = 0) { k = _k;
        FOR(i, 1 << k)
            arbre.push_back(i < (1 << (k-1)) ? 0LL : def);
        FORD(i, ((1 << (k-1)) - 1), 1)
            arbre[i] = arbre[i << 1] + arbre[(i << 1) ^ 1];
    }
    void set(int i, lli x) { int feuille = i + (1 << (k-1));
        arbre[feuille] = x;
        iset(feuille >> 1);
    }
    void iset(int noeud) {
        if(noeud) {
            arbre[noeud] = arbre[noeud << 1] + arbre[(noeud << 1)  ^ 1];
            iset(noeud >> 1);
    }   }
    lli sum(int deb, int fin, int noeud = 1, int p = 0, int q = -1) {
        if(q < p) q = 1 << (k-1);
        if(deb <= p && q <= fin) return arbre[noeud];
        if(deb >= q || fin <= p) return 0LL;
        int mil = (p + q) / 2;
        return sum(deb, fin, noeud << 1, p, mil) + sum(deb, fin, (noeud << 1) ^ 1, mil, q);
    }
};

using ull = unsigned long long;

// Utility function to do modular exponentiation.
// It returns (x^y) % p
lli power(lli x, ull y, lli p)
{
    lli res = 1;      // Initialize result
    x = x % p;  // Update x if it is more than or
                // equal to p
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

// This function is called for all k trials. It returns
// false if n is composite and returns false if n is
// probably prime.
// d is an odd number such that  d*2r = n-1
// for some r >= 1
bool miillerTest(lli d, lli n, lli a)
{
    // Pick a random number in [2..n-2]
    // Corner cases make sure that n > 4
    //lli a = 2 + rand() % (n - 4);
    a = 2 + a %(n-4);

    // Compute a^d % n
    lli x = power(a, d, n);

    if (x == 1  || x == n-1)
       return true;

    // Keep squaring x while one of the following doesn't
    // happen
    // (i)   d does not reach n-1
    // (ii)  (x^2) % n is not 1
    // (iii) (x^2) % n is not n-1
    while (d != n-1LL)
    {
        x = (x * x) % n;
        d *= 2LL;

        if (x == 1LL)      return false;
        if (x == n-1LL)    return true;
    }

    // Return composite
    return false;
}

// It returns false if n is composite and returns true if n
// is probably prime.  k is an input parameter that determines
// accuracy level. Higher value of k indicates more accuracy.
bool is_prime(lli n, lli k)
{
    // Corner cases
    if (n <= 1LL || n == 4LL)  return false;
    if (n <= 3LL) return true;

    // Find r such that n = 2^d * r + 1 for some r >= 1
    lli d = n - 1LL;
    while (d % 2LL == 0LL)
        d /= 2LL;

    // Iterate given nber of 'k' times
    for (lli i = 0LL; i < k; i++)
         if (miillerTest(d, n, i) == false)
              return false;

    return true;
}

const lli MOD = 1E9+7;

vector<lli> primes;

lli phi(const lli n)
{
  // Base case
  if ( n < 2LL )
    return 1;

  // Lehmer's conjecture
  if ( is_prime(n, 50) )
    return n-1LL;

  // Even number?
  if ( (n & 1) == 0 ) {
    lli m = n >> 1LL;
    return !(m & 1LL) ? phi(m)<<1LL : phi(m);
  }

  // For all primes ...
  for ( std::vector<lli>::iterator p = primes.begin();
        p != primes.end() && *p <= n;
        ++p )
  {
    lli m = *p;
    if ( n % m  ) continue;

    // phi is multiplicative
    lli o = n/m;
    lli d = __gcd(m, o);
    return d==1? phi(m)*phi(o) : phi(m)*phi(o)*d/phi(d);
  }
  return n-1;
}

int main()
{
    lli n, k;
    RD(&n, &k);
    primes.push_back(2);
    FORU(i, 3, 1E6)
    {
        bool p = true;
        for(auto q : primes)
        {
            if(q*q > i) break;
            if(i%q==0){p=false;break;}
        }
        if(p) primes.push_back(i);
    }
    lli r = n;
    FOR(i, (k+1LL)/2LL)
    {
        r = phi(r);
        if(r == 1LL) break;
    }
    PR(r%MOD);
    return 0;
}

#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
ll f(ll n){
	ll res = n;
	for(ll i = 2; i * i <= n; i++){
    	if(n % i == 0){
       		res = res / i * (i - 1);
       		while(n % i == 0) {
           		n /= i;
        	}
    	}
	}
	if (n > 1) {
    	res = res / n * (n - 1);
	}
	return res;
}
int main(){
	ll n, k;
	scanf("%lld%lld", &n, &k);
	ll cnt = (k + 1) / 2;
	while(cnt--){
		n = f(n);
		if(n == 1){
			break;
		}
	}
	printf("%lld\n", n % mod);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll n,k;
ll mul(ll a,ll b,ll p)
{
    ll k = ((ld)a*(ld)b)/(ld)p;
    ll tmp = (unsigned ll)a*(unsigned ll)b-(unsigned ll)k*(unsigned ll)p;
    tmp %= p;
    if (tmp < 0) tmp += p;
    return tmp;
}
ll pow(ll a,ll t,ll p)
{
    if (t == 0) return 1;
    ll tmp = pow(a,t >> 1,p);
    tmp = mul(tmp,tmp,p);
    if (t&1) tmp = mul(tmp,a,p);
    return tmp;
}
int isprime(ll x)
{
    if (x == 1) return 0;
    int t = 20;
    while (t--)
    {
        ll tmp = rand()%(x-1)+1;
        ll y = pow(tmp,x-1,x);
        if (y != 1) return 0;
    }
    return 1;
}
ll f(ll x)
{
    ll tmp = x;
    for (ll i = 1;i*i <= x;i++)
    {
        if (x%i) continue;
        if (isprime(i)) tmp = (tmp/i)*(i-1);
        ll another = x/i;
        if (another != i)
            if (isprime(another))
                tmp = (tmp/another)*(another-1);
    }
    return tmp;
}
int main()
{
    cin >> n >> k;
    k = (k+1)/2;
    for (ll i = 1;i <= k;i++)
    {
        if (k-i+1 >= n) {n = 1; break;}
        n = f(n);
    }
    printf("%lld",n%1000000007);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
long long x,y;
int main()
{
	scanf("%lld%lld",&x,&y);
	y=(y+1)>>1;
	for(;y;y--)
	{
		long long z=x,a=x;
		for(long long i=2;i*i<=a;i++)
			if(a%i==0)
			{
				a/=i;
				z*=i-1;
				z/=i;
				while(a%i==0) a/=i;
			}
		if(a>1) z/=a,z*=a-1;
		x=z;
		if(x==1) break;
	}
	x%=1000000007;
	printf("%lld",x);
}

#include <iostream>
#include <cmath>
#include <map>
#include <set>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string.h>
using namespace std;
typedef long long LL;
#define fastio ios::sync_with_stdio(false)
#define INF 1e18
const LL MOD = 1000000007;
const int MAXN = 1000000 + 10;
LL prime[MAXN];
LL f[MAXN][2];
void getPrim()
{
    memset(prime, 0, sizeof(prime));
    for(int i=2;i<MAXN;i++)
    {
        if(!prime[i])
        {
            prime[++prime[0]] = i;
        }
        for(int j=1;(j<=prime[0])&&(prime[j]<=(MAXN/i));j++)
        {
            prime[prime[j]*i] = 1;
            if(i%prime[j]==0) break;
        }
    }
}
LL getFactor(LL x)
{
    LL cnt = 0, i;
    LL tmp = x;
    for(i = 1; prime[i] * prime[i] <=tmp && (i <= prime[0]) ;i++)
    {
        if(tmp % prime[i] == 0)
        {
            f[++cnt][1] = 0;
            f[cnt][0] = prime[i];
            while(tmp % prime[i] == 0)
            {
                f[cnt][1]++;
                tmp /= prime[i];
            }
        }
    }
    if(tmp!=1)
    {
        f[++cnt][0] = tmp;
        f[cnt][1] = 1;
    }
    return cnt;
}

LL getEuler(LL x)
{
    int cnt = getFactor(x), i;
    for(i = 1; i <= cnt; i++)
    {
        x = x / f[i][0] * (f[i][0] - 1);
    }
    return x;
}

LL n, k;
int main()
{
    getPrim();
    cin >> n >> k;
    LL t = (k+1)/2;
    LL ans = n;
    for(LL i=1;i<=t;i++)
    {
        ans = getEuler(ans);
        if(ans == 1) break;
    }
    ans %= MOD;
    cout << ans << endl;
}

#include<bits/stdc++.h>
#define int long long
const int mod=1e9+7;
using namespace std;
int phi(int x){
	int ans=x,x1=x;
	for(int i=2;i*i<=x1;i++){
		if(x1%i==0){
			ans/=i;
			ans*=(i-1);
			while(x1%i==0){
				x1/=i;
			}
		}
	}
	if(x1!=1){
		ans/=x1;
		ans*=(x1-1);
	}
	return ans;
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,k,i,j,l;
	cin>>n>>k;
	k=(k+1)/2;
	for(i=1;i<=k;i++){
		n=phi(n);
		if(n==1){
			break;
		}
	}
	cout<<n%mod;
}

#include <map>
#include <iterator>
#include <utility>
#include <cstdio>
#include <functional>
#include <vector>
#include <array>

template<typename T>
struct Mapper
{
    int operator[](const T& v) { int& ret = table[v]; if(!ret) rtable[ret = table.size()] = v; return ret - 1; }
    template<typename... Args> int operator()(Args... args) { return (*this)[T(args...)]; }
    T rev(int idx){return rtable[idx + 1];}
    std::map<T, int> table;
    std::map<int, T> rtable;
};

template<typename T, int S>
struct ReferenceArray
{
    struct It {typename std::array<T*, S>::iterator it; T& operator*(){return **it;} void operator++(){it++;} bool operator!=(const It& other){return it != other.it;} };
    int size()const{return _ptr.size();}
    It begin()const{return {_ptr.begin()};}
    It end()const{return {_ptr.end()};}
    T& operator[](int idx)const{return *_ptr[idx];}
    mutable std::array<T*, S> _ptr;
};
template<typename T, typename... Args>
ReferenceArray<T, sizeof...(Args) + 1> MAKEV(T& arg1, Args&... args) {return {&arg1, &args...};}

struct Range
{
    struct It {   int num, step; int operator*(){return num;} void operator++(){num += step;} bool operator!=(const It& other){return num != other.num;} };
    Range(int ee):b(0),e(ee){}
    Range(int bb, int ee):b(bb), e(ee){}
    It begin(){return {b, (b < e? 1: -1)};}
    It end(){return {e, 0};}
    int b, e;
};

template<typename T> inline T& UMAX(T& x, T y){if(x < y)x = y; return x;}
template<typename T> inline T& UMIN(T& x, T y){if(y < x)x = y; return x;}
template<typename T, typename... Args> struct ArithmiticPromotion { typedef decltype(T() + typename ArithmiticPromotion<Args...>::type()) type; };
template<typename T, typename U> struct ArithmiticPromotion<T, U> { typedef decltype(T() + U()) type; };
template<typename T> struct ArithmiticPromotion<T, T> { typedef T type; };
template<typename T> struct ArithmiticPromotion<T> { typedef T type; };
template<typename T, typename U> typename ArithmiticPromotion<T, U>::type MAX(T a, U b) { return a < b? b: a; }
template<typename T, typename... Args> typename ArithmiticPromotion<T, Args...>::type MAX(T a, Args... args) { return MAX(a, MAX(args...)); }
template<typename T, typename U> typename ArithmiticPromotion<T, U>::type MIN(T a, U b) { return a < b? a: b; }
template<typename T, typename... Args> typename ArithmiticPromotion<T, Args...>::type MIN(T a, Args... args) { return MIN(a, MIN(args...)); }

template<typename T> struct ScanfSpecifier{};
#define DEF(T,V) template<> struct ScanfSpecifier<T>{static constexpr const char* value = V;};
DEF(char*,"%s")DEF(int,"%d")DEF(double,"%lf")DEF(float,"%f")DEF(char,"%c")DEF(const char*,"%s")DEF(unsigned long,"%lu")DEF(unsigned int, "%u")
#ifdef _MSC_VER
DEF(long long int,"%I64d")
#else
DEF(long long int,"%lld")
#endif
#undef DEF
template<typename T> int RD(T& arg){return std::scanf(ScanfSpecifier<T>::value, &arg);}
template<int S> int RD(char (&arg)[S]){return std::scanf("%s", arg);}
int RD(char* arg){return std::scanf("%s", arg);}
template<> int RD<char>(char& arg){return std::scanf(" %c", &arg);}
template<typename T, typename... Args> int RD(T& arg1, Args&... args) {return RD(arg1) + RD(args...);}
template<typename T> T RD(){T ret; RD(ret); return ret;}
template<typename It> void RDV(It begin, It end) { while(begin != end) RD(*begin++); }
template<typename C> void RDV(C& c) {RDV(std::begin(c), std::end(c));}
template<typename T> void WT(T arg) {std::printf(ScanfSpecifier<T>::value, arg); }
template<typename T, typename U> void WT(std::pair<T, U> arg) {std::printf("("); WT(arg.first); std::printf(", "); WT(arg.second); std::printf(")");}
template<typename... Args> void WT(Args... args) { int alc = 0; int dummy[] = {((alc++? std::printf(" "): 0), WT(args), 0)...}; }

template<typename... Args> void WTL(Args... args) { WT(args...); std::printf("\n"); }
template<typename It> void WTV(It begin, It end) { int alc = 0; while(begin != end) (alc++? std::printf(" "): 0), WT(*begin++); }
template<typename C> void WTV(const C& c) {WTV(std::begin(c), std::end(c));}
template<typename It> void WTVL(It begin, It end) { WTV(begin, end); std::printf("\n"); }
template<typename C> void WTVL(const C& c) {WTVL(std::begin(c), std::end(c));}

//alias
using RG = Range;
//RD[L],RDV[L],WT[L],WTV[L] for i/o
//template
#include <vector>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <cstdlib>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long int ll;

const int SIZE = 1000009;

bool ptable[SIZE];
ll primes[SIZE];
int total;
int buf[128];
ll f(ll n)
{
    ll ret = 1;
    for(int i = 0; i < total && primes[i] * primes[i] <= n; i++)
        if(n % primes[i] == 0)
        {
            ll v = 1;
            while(n % primes[i] == 0)
            {
                n /= primes[i];
                v *= primes[i];
            }
            ret *= v - v / primes[i];
        }

    if(n > 1)
        ret *= n - 1;
    return ret;
}

int main()
{
    for(ll i = 2; i < SIZE; i++)
        if(!ptable[i])
        {
            primes[total++] = i;
            for(ll j = i * i; j < SIZE; j += i)
                ptable[j] = true;
        }

    ll N, K;
    RD(N, K);

    for(ll i = 0; i < K && N != 1; i += 2)
        N = f(N);

    WTL(N % 1000000007);
}

#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define loop(s, v, it) for (s::iterator it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (int i = head[x]; i; i = e[i].nxt)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define iv inline void
#define enter cout << endl
#define siz(x) ((int)x.size())
#define file(s) freopen(s".in", "r", stdin), freopen(s."out", "w", stdout)
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <int, int> pii ;
typedef vector <int> vi ;
typedef vector <pii> vii ;
typedef queue <int> qi ;
typedef set <int> si ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 100010 ;
const int INF = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const int MOD = 1000000007 ;
void print(int x) { cout << x << endl ; exit(0) ; }
void PRINT(string x) { cout << x << endl ; exit(0) ; }
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }

ll n, k ;

ll calc(ll n) {
	ll res = n ;
	for (ll i = 2; i * i <= n; i++)
	if (n % i == 0) {
		res = res / i * (i - 1) ;
		while (n % i == 0) n /= i ;
	}
	if (n > 1) res = res / n * (n - 1) ;
	return res ;
}

signed main(){
	/* f(n) 则 对应着 Σgcd(x,n)=1, 相当于欧拉函数
     * 显然 g(n) 为 n 的 因子 的 欧拉函数 之和
     * 那么相当于问题就转化成了 f(f(f(f(f(f(...(n))))))), 一共 (k+1) / 2 次, 直接 暴力 应该就 过了 吧 ？
     */
    scanf("%lld%lld", &n, &k) ;
    for(ll i = 1; i <= k; i += 2) {
    //	cout << i << " " << n << endl ;
    	n = calc(n) ;
    //	cout << "ok\n" ;
    	if (n == 1) break ;
	}
	printf("%lld\n", n % MOD) ;
	return 0 ;
}

/*
写代码时请注意：
	1.ll？数组大小，边界？数据范围？
	2.精度？
	3.特判？
	4.至少做一些
思考提醒：
	1.最大值最小->二分？
	2.可以贪心么？不行dp可以么
	3.可以优化么
	4.维护区间用什么数据结构？
	5.统计方案是用dp？模了么？
	6.逆向思维？
*/

#include <iostream>
#include <cstdio>
#include <cstring>

/* G - The Holmes Children(暴力求欧拉数) */

typedef long long int ll;

ll findphi(ll n)
{
	ll i, res;

	res = n;
	for (i = 2; i * i <= n; i ++)
	{
		if (n % i == 0)
		{
			res = res / i * (i - 1);
			while (n % i == 0)
				n /= i;
		}
	}
	if (n > 1)
		res = res / n * (n - 1);
	return res;
}
/*
ll find(ll n, ll k)
{
	ll tmp;

	if (k == 1)
		return findphi(n);
	if (k % 2 == 0)
	{
		if (k > 3)
		{
			return findphi(find(n, k - 3));
		}
		else
			return find(n, k - 1);
	}
	else
	{
		return findphi(find(n, k - 2));
	}
}
*/
int main(int argc, char** argv)
{
	ll n, k, res, i;

	scanf("%I64d%I64d", &n, &k);
	for (i = 1; i <= k; i ++)
	{
		if (i == 1)
			res = findphi(n);
		else if (i % 2 == 1)
			res = findphi(res);
		if (res == 1)
			break;
	}
	printf("%I64d\n", res % 1000000007);
	return 0;
}

#include <bits/stdc++.h>

#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

int phi(int n) {
	int result = n;
	for (int i=2; i*i<=n; ++i)
		if (n % i == 0) {
			while (n % i == 0)
				n /= i;
			result -= result / i;
		}
	if (n > 1)
		result -= result / n;
	return result;
}

int32_t main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < (k + 1) / 2; ++i) {
		n = phi(n);
		if (n == 1) break;
	}
	cout << (n % (1000000007)) << "\n";
	return 0;
}

#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
vector<pii>get(ll num)
{
	vector<pii>vec;
	for (ll i = 2;; i++)
	{
		if (i*i > num)break;
		if (num%i != 0)continue;
		vec.push_back(make_pair(i, 0));
		for (;;)
		{
			if (num%i != 0)break;
			vec[vec.size() - 1].second++;
			num /= i;
		}
	}
	if (num != 1)vec.push_back(make_pair(num, 1));
	return vec;
}
int main()
{
	ll num,kai;
	scanf("%I64d%I64d", &num, &kai);
	kai = (kai + 1) / 2;
	for (int i = 0; i < min(kai, 1000LL); i++)
	{
		vector<pii>vec = get(num);
		ll t = 1;
		for (int j = 0; j < vec.size(); j++)
		{
			t *= vec[j].first - 1;
			for (int k = 0; k < vec[j].second - 1; k++)t *= vec[j].first;
		}
		num = t;
	}
	printf("%I64d\n", num % 1000000007);
}

#pragma comment(linker, "/STACK:216000000")
#include <iostream>
#include <cstdio>
#include <fstream>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <numeric>
#include <set>
#include <bitset>
#include <sstream>
#include <array>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
const ll MAX = numeric_limits<ll>::max();
const ll MIN = numeric_limits<ll>::min();
const double PI = 3.1415926535;
const ll MOD = 1000000007;

template<class T>
ostream& operator<<(ostream& out, vector<T>& v) {
	for (int i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << endl;
	return out;
}

template<class T>
istream& operator>>(istream& in, vector<T>& v) {
	for (int i = 0; i < v.size(); ++i)
		in >> v[i];
	return in;
}

template<class T>
T lexical_cast(string& s) {
	stringstream ss(s);
	T t;
	ss >> t;
	return t;
}

ll gcd(ll a, ll b) {
	if (b == 0)
		return a;
	return gcd(b, a % b);
}

ll ceil(ll a, ll b) {
	if (a % b)
		return a / b + 1;
	return a / b;
}

ll f(ll n) {
	if (n == 1)
		return 1;
	ll result = n;
	for (ll i = 2; i * i <= n; ++i)
	if (n % i == 0) {
		while (n % i == 0)
			n /= i;
		result -= result / i;
	}
	if (n > 1)
		result -= result / n;
	return result;
}

int main() {
	ios_base::sync_with_stdio(false);
#ifdef DEBUG
	ifstream cin{ "input.txt" };
	ofstream cout{ "output.txt" };
#endif
	ll n, k;
	cin >> n >> k;
	ll current = n;
	while (k >= 1) {
		if (k % 2) {
			current = f(current);
		}
		if (k == 1 || current == 1)
			break;
		k--;
	}

	cout << current % MOD;
}

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
long long mod = 1e9 + 7, n, k;
long long phi(long long x) {
    long long re = x;
    for (long long i = 2; i * i <= x; i++) {
        if(x % i == 0){
        	re = re / i * (i - 1);
			while(x % i == 0) x /= i;

        }
    }
    if (x > 1) re = re / x * (x - 1);
    return re;
}
int main() {
    scanf("%I64d%I64d", &n, &k);
    long long ans = phi(n);
    for (int i = 2; i <= k; i++) {
        if(i & 1) {
			ans = phi(ans);
		}
        if(phi(ans) == ans) break;
    }
    printf("%I64d\n", ans % mod);
    return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<numeric>
#include<set>
#include<map>
#include<time.h>
#include<cmath>
#include<queue>
#include<complex>
#define li long long
#define mp make_pair
using namespace std;

li phi(li n) {
	li result = n;
	for (li i = 2; i*i <= n; ++i)
		if (n % i == 0) {
			while (n % i == 0)
				n /= i;
			result -= result / i;
		}
	if (n > 1)
		result -= result / n;
	return result;
}

int main() {
	//freopen("subgraph.in", "r", stdin);
	//freopen("subgraph.out", "w", stdout);
	li n, k;
	cin >> n >> k;
	for (int i = 0; i < min((k + 1) / 2 , (li)1000); i++) {
		n = phi(n);
	}
	cout << n % 1000000007;
}

#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
using namespace std;
bool p [ 1000004 ] ;
vector<int> P ;
ll euler ( ll a ) {
	ll e = 1;
	for ( int i = 0 ; P[i]*P[i] <= a && i < (int)P.size() ; i ++ ){
		if ( a % P [ i ] == 0 ) {
			e *= P [ i ] - 1 ;
			a /= P [ i ] ;
			while ( a % P [ i ] == 0 ) a /= P[i] ,  e *= P[i];
		}
	}
	if ( a > 1 ) return e * ( a - 1 );
	return e ;
}

int main(){
	ios::sync_with_stdio(0);
	for ( int i = 2 ; i *i <= 1000004 ; i ++ ){
		if ( p [ i ] == 0 )for ( int j = i*i ; j <= 1000004 ; j += i ) p [ j ] = 1 ;
	}
	for ( int i = 2 ; i <= 1000000 ; i ++ ) {
		if ( p [ i ] == 0 ) P.push_back(i);
	}
	int e ;
	ll n , k  ;
	cin >> n >> k ;
	while ( k > 0 && n > 1 ) n = euler(n) , k -= 2;
	cout << n % mod<< endl ;
}

#include<bits/stdc++.h>

using namespace std;

#define ull unsigned long long
#define LL long long int
#define pii pair<int,int>
#define mp make_pair
#define pb(x) push_back(x)
#define F(i,a,n) for(int i=(a);i<(n);++i)
#define FD(i,a,n) for(int i=(a);i>=(n);--i)
#define FE(it,x) for(it=x.begin();it!=x.end();++it)
#define V(x) vector<x>
#define S(x) scanf("%d",&x)
#define Sl(x) scanf("%llu",&x)
#define M(x,i) memset(x,i,sizeof(x))
#define fr first
#define se second
#define MOD 1000000007

long long  phi(long long n) {
    long long i,res=n;
    for(i=2;i*i<=n;i++) {
        if(n%i==0) {
        while(n%i==0)
            n/=i;
        res-=res/i;
       }
   }
    if(n>1)
        res-=res/n;
    return res;
}
int main() {
	long long n,k;
	cin >> n >> k;
	long long temp = min(50LL,(k+1)/2);
	long long ans = n;
	while(temp--){
		ans = phi(ans);
	}
	cout << ans % MOD<< endl;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll Mod =  1000000007;
ll ouler(ll n)
{
    if(n == 1) return 1;
    ll t = (ll)sqrt(n*1.0) + 1;
    ll ans = n;
    ll tmp = n;
    for(int i = 2; i < t; ++i)
    {
        if(n%i == 0)
        {
            while(n%i == 0) n/=i;
            ans = ans /i * (i-1);
        }
    }
    if(n!=1) ans = ans/n*(n-1);
    //cout << "ouler" << tmp << ' ' << ans <<endl;
    return ans;
}
ll f(ll n){return ouler(n);}

int main()
{
    ll n,k;
    cin >> n >> k;
    k = (k+1)>>1;
    while(k&&n!=1) n = f(n),--k;
    cout << n%Mod <<endl;
}

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cassert>
#include <vector>
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
#define umax( x , y ) x = max( x , (y) )
#define umin( x , y ) x = min( x , (y) )
#define For( i , a ) for(int i=1;i<=a;i++)
#define ort (b+s)/2
#define y2 asrwjaelkf
#define y1 asseopirwjaelkf
#define set multiset

using namespace std;

inline int read() {
    int res = 0 ;int neg ;
    while(true){char ch = getchar();if(ch>='0' && ch<='9' || ch=='-'){if(ch=='-') neg = -1;else neg = 1 , res = ch-'0';break;} }
    while(true){char ch = getchar();if(ch>='0' && ch<='9') res*=10 , res+=ch-'0';else break;}
    return res*neg;
}

typedef long long Lint;
typedef long double db;
typedef pair<Lint,Lint> ii;
typedef pair<db,db> dd;
typedef pair<db,int> di;
typedef pair<ii,int> iii;
typedef pair<ii,ii> i4;

const int maxn = 100020;
const int maxm = 1000020;
const int MOd = 1e9 + 7;

Lint a, k;

Lint f( Lint n ) {
    Lint h = n;
    for(Lint i=2;i*i<=n;i++)
        if( n % i == 0 ) {
            h /= i;
            h *= i-1;
            while( n % i == 0 ) n /= i;
        }
    if( n > 1 ) h /= n, h *= n-1;
    return h;
}

Lint g( Lint a, Lint k ) {
    if( a == 1 ) return 1;
    //printf("%lld %lld\n",a,k);
    if( k == 1 ) return f( a );
    return g( f( a ), k-2 );
}

int main() {

    //freopen("asd.in.c","r",stdin);
    //freopen("out.txt","w",stdout);

    scanf("%lld %lld",&a,&k);
    Lint ans = a;
    if( k % 2 == 0 ) k--;
    cout << (g( a, k ) % MOd) << endl;

    return 0;
}

#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;
typedef long long LL;
map <LL,LL> ff;
LL f(LL n){
	if (n == 1LL) return 1;
	if (ff.find(n) != ff.end())
		return ff[n];
	LL s = n - 1;
    for (LL i = 2; i * i <= n; i++){
        if (n % i == 0){
        	s -= f(n / i);
        	if (i*i==n) break;
			s -= f(i);
        }
    }
    ff[n] = s;
    return s;
}
int main(){
	LL N, K;
	cin>>N>>K;
	K = (K + 1) / 2LL;
	ff.clear();
	for (LL i = 0; i < K; i++){
        N = f(N);
		if (N == 1LL) break;
	}
	cout<<N % 1000000007LL<<endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
int euler(int n){
	int ans=n-1,m=sqrt(n);
	for(int i=2;i*i<=n;i++){
		if(n%i==0){
			ans-=n/i;
			while(n%i==0)
				n/=i;
		}
	}
	return ans;
}
main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    int n,k;cin>>n>>k;
    for(int i=0;i<k&&n!=1;i+=2)
        n=euler(n);
    cout<<n%mod<<endl;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
ll qpow(ll a,ll b)
{
	ll ans=1;a%=MOD;
    for(ll i=b;i;i>>=1,a=a*a%MOD)
        if(i&1)ans=ans*a%MOD;
    return ans;
}
ll pri(ll n)
{
	ll ret=n;
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
			ret=(ret*(i-1)*qpow(i,MOD-2))%MOD;
		while(n%i==0)
			n/=i;
	}
	if(n>1)
		ret=ret*(n-1)%MOD*qpow(n,MOD-2)%MOD;
	return ret;
}
int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ll n,k,ans;
	scanf("%lld%lld",&n,&k);
	ans=n;
	for(ll i=1;i<=k;i+=2)
	{
		ans=pri(ans);
		if(ans==1)
			break;
	}
	printf("%lld\n",ans);
	return 0;
}

#include<bits/stdc++.h>
#define ll long long

ll long_mod(ll a, ll c, ll moder){
	const int orz = 1e9;
	ll b = a % orz, d = c % orz;
	a /= orz, c /= orz;
	ll ret = b * d % moder, ans = a * c % moder;
	for (int i = 0; i < 18; ++ i){
		ans = ans * 10 % moder;
	}
	ret = (ret + ans) % moder;
	ans = (a * d + b * c) % moder;
	for (int i = 0; i < 9; ++ i){
		ans = ans * 10 % moder;
	}
	return (ret + ans) % moder;
}

ll power_mod(ll a, ll index, ll moder){
	ll ans = 1;
	while (index){
		if (index & 1)
			ans = long_mod(ans, a, moder);
		a = long_mod(a, a, moder);
		index >>= 1;
	}
	return ans;
}

ll random(ll n){
	ll ret = 1ll * rand() * rand() * rand() * rand() + 1ll * rand() * rand() * rand() + 1ll * rand() * rand() + rand() + 1;
	return ret % n;
}

bool Miller_Rabin(ll n, ll t, ll u){
	ll a = random(n);
	if(!a || a == 1)
		return true;
	ll pre = power_mod(a, u, n);
	for (int i = 0; i < t; ++ i){
		ll now = long_mod(pre, pre, n);
		if (now == 1 && pre != 1 && pre != n - 1)
			return false;
		pre = now;
	}
	return pre == 1;
}

bool miller_rabin(ll n){
	if (n <= 30)
		return n == 2 || n == 3 || n == 5 || n == 7 || n == 11 || n == 13 || n == 17 || n == 19 || n == 23 || n == 29;
	if (!(n & 1))
		return false;
	const int S = 10;
	ll t = 0, x = n - 1;
	while (!(x & 1)){
		x /= 2;
		++ t;
	}
	for (int i = 0; i < S; ++ i){
		if (!Miller_Rabin(n, t, x))
			return false;
	}
	return true;
}

std::map <ll, int> fact;

ll pollard_rho(ll n){
	ll c = random(n - 1) + 1, x = random(n), y = x, i = 0, k = 1;
	while (true){
		++ i;
		x = long_mod(x, x, n);
		x = (x + c) % n;
		ll d = std::__gcd(std::abs(y - x), n);
		if (d != 1 && d != n){
			return d;
		}
		if (x == y){
			return n;
		}
		if (i == k){
			y = x;
			k <<= 1;
		}
	}
}

void get_fact(ll n){
	if (n == 1){
		return;
	}
	if (miller_rabin(n)){
		++ fact[n];
		return;
	}
	ll x = pollard_rho(n);
	get_fact(x);
	get_fact(n / x);
}

ll phi(ll n){
	ll ret = 1;
	fact.clear();
	get_fact(n);
	for (auto u = fact.begin(); u != fact.end(); ++ u){
		ret *= u -> first - 1;
		for (int i = 0; i < u -> second - 1; ++ i){
			ret *= u -> first;
		}
	}
	return ret;
}

int main(){
	srand((unsigned) time(NULL));
	ll n, k;
	scanf("%I64d%I64d", &n, &k);
	for (ll i = 0; i < k + 1 >> 1; ++ i){
		n = phi(n);
		if (n == 1){
			return printf("%I64d\n", n), 0;
		}
	}
	return printf("%I64d\n", n), 0;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define f first
#define s second

#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)

#define dbg(x) cerr << (#x) << " --> " << (x) << nl;
#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

#define _5day "grants"

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree < pair <int, int>, null_type, less < pair <int, int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 3e5 + 7, inf = 1e9 + 7, mod = 1e9 + 7;
const ll linf = (ll)1e18 + 7;
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1}, dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

  ll n, k;

  inline ll phi(ll n) {
    ll res = n;
    rep(i, 2, sqrt(n)) {
      if (n % i == 0) {
        while (n % i == 0) n /= i;
        res -= res / i;
      }
    }
    if (n > 1) res -= res / n;
    return res;
  }
  inline ll g(ll n) {
    return n;
  }
  inline ll F(ll n, ll k) {
    if (k == 1) return phi(g(n));
    if (k % 2 == 0) return g(F(n, k - 1));
    return phi(F(n, k - 1));
  }
  inline ll check(ll x) {
    if (x & (x - 1)) return 0;
    return 1;
  }
  vector <ll> good;
int main() {
  #ifdef _5
    freopen (_5day".in", "r", stdin);
    freopen (_5day".out", "w", stdout);
  #endif

  cin >> n >> k;
  rep(i, 1, k) {
    ll x = F(n, i);
    good.pb(x);
    if (check(x)) {
      good.pb(x);
      break;
    }
  }

  rep(i, 0, sz(good) - 1)
    if (i + 1 == k) cout << good[i], ioi

  ll last = good.back() / 2;
  k -= sz(good);
  while (k) {
    if (k <= 2 || last == 1) cout << last, ioi
    k -= 2;
    last /= 2;
  }
  ioi
}

#include  <bits/stdc++.h>
using namespace std;

const int M = 1000000007;

const int N = 1000005;
vector<int> p;
bool np[N];

void sieve(int n){

	for(int i = 4; i <= n; i += 2) np[i] = true;
	for(int i = 3; i*i <= n; i += 2)
		if(not np[i])
			for(int j = i*i; j <= n; j += 2*i)
				np[j] = true;

	for(int i = 2; i <= n; ++i)
		if(not np[i])
			p.push_back(i);

}

long long phi(long long n){

	long long r = n;

	for(int i = 0; 1LL*p[i]*p[i] <= n; ++i)
		if(n%p[i] == 0){
			while(n%p[i] == 0) n /= p[i];
			r -= r/p[i];
		}

	if(n > 1) r -= r/n;

	return r;
}

long long n, k;

int main(){

	sieve(1000000);
	cin >> n >> k;

	if(k != 1)
		k /= 2;

	long long r = phi(n);
	long long a;
	while(k > 1 and r != 1){
		a = phi(r);
		if(a == r) break;
		r = a;
		k--;
	}

	printf("%I64d\n", r%M);

	return 0;
}

#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

long long n, k;

long long phi(long long x) {
	long long xx = x;
	long long ans = x;
	for (int i = 2; i * i <= xx; ++i) {
		if (x % i == 0) {
			while (x % i == 0)
				x /= i;
			ans -= ans / i;
		}
	}
	if(xx > 1) ans -= ans / xx;
	return ans;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n >> k;
	for (long long i = 1; i <= k && n >= 2; ++i) {
		if(i % 2 == 1)
			n = phi(n);
	}
	cout << n % 1000000007;
	return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <cassert>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <utility>
#include <cmath>
#include <bitset>
#include <climits>
#include <iomanip>
using namespace std;

#define int long long
#define MOD 1000000007

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef double T;
typedef vector<T> VT;
typedef vector<VT> VVT;

vector<int> primes;

int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}

bool isprime(int n){
    if(n == 1)
        return false;
    else if(n <= 3)
        return true;
    else if(n % 2 == 0 || n % 3 == 0)
        return false;
    for(int i = 5; i * i <= n; i += 6){
        if(n % i == 0 || n % (i + 2) == 0)
            return false;
    }

    return true;
}

int phi(int n){
    if (n < 2)
        return 1;

    if (isprime(n))
        return n-1;

    if (n % 2 == 0) {
        int m = n >> 1;
        return !(m & 1) ? phi(m)<<1 : phi(m);
    }

    for (auto p = primes.begin(); p != primes.end() && *p <= n; p++){
        int m = *p;
        if (n % m) continue;

        int o = n/m;
        int d = gcd(m, o);
        return d==1? phi(m)*phi(o) : phi(m)*phi(o)*d/phi(d);
    }
    return -1;
}

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    vector<bool> primeis(1e6 + 2, true);
    primeis[1] = false;

    for(int i = 2; i <= 1e6 + 1; i++){
        if(primeis[i]){
            primes.push_back(i);
            for(int j = i * 2; j <= 1e6 + 1; j += i)
                primeis[j] = false;
        }
    }

    int n, k;
    cin >> n >> k;

    vector<int> ans(1e7);
    ans[1] = (phi(n) % MOD);

    for(int i = 2; i <= k; i++){
        if(i % 2 == 0)
            ans[i] = ans[i - 1];
        else
            ans[i] = (phi(ans[i - 1]) % MOD);
        if(ans[i] == 1){
            cout << 1 << endl;
            return 0;
        }
    }

    cout << ans[k] << endl;

    return 0;
}

#include <set>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <string>
#include <map>
#include <algorithm>
#include <stdlib.h>
//#include <optimization.h>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <deque>

using namespace std;

const int mod = 1e9+7;

int main(){
    //freopen("sat3.in", "r", stdin);
    //freopen("sat3.out", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0);
    long long n, k;
    cin >> n >> k;
    long long num = (k+1)/2;
    vector<long long> v;
    for (int i = 0; i < num; i++){
        v.clear();
        long long nn = n;
        for (int j = 2; j*1ll*j<=nn; j++)
            if (n%j==0){
                v.push_back(j);
                while (nn % j == 0)
                    nn /= j;
            }
        if (nn != 1)
            v.push_back(nn);
        long long ans = 0;
        for (int m = 0; m < (1ll<<v.size()); m++){
                long long p = 1;
                int sz = 0;
                for (int j = 0; j < v.size(); j++)
                    if ((m& (1 << j)) != 0){
                        p *= v[j];
                        sz++;
                    }
                if (sz % 2 == 0)
                    ans += n/p;
                else
                    ans -= n/p;
        }
        n = ans;
        if (n==1){
            cout << 1;
            return 0;
        }
    }
    cout << n%mod;
    return 0;
}

// need
#include <iostream>
#include <algorithm>

// data structure
#include <bitset>
//#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
//#include <array>
//#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <complex>
//#include <deque>
#include<valarray>

// stream
//#include <istream>
//#include <sstream>
//#include <ostream>

// etc
#include <cassert>
#include <functional>
#include <iomanip>
//#include <typeinfo>
#include <chrono>
#include <random>
#include <numeric>

#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { std::cin >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { std::cin >> first; MACRO_VAR_Scan(rest...); }
#define VEC_ROW(type, n, ...)std::vector<type> __VA_ARGS__;MACRO_VEC_ROW_Init(n, __VA_ARGS__); for(int i=0; i<n; ++i){MACRO_VEC_ROW_Scan(i, __VA_ARGS__);}
template<typename T> void MACRO_VEC_ROW_Init(int n, T& t) { t.resize(n); }
template<typename First, typename...Rest>void MACRO_VEC_ROW_Init(int n, First& first, Rest&...rest) { first.resize(n); MACRO_VEC_ROW_Init(n, rest...); }
template<typename T> void MACRO_VEC_ROW_Scan(int p, T& t) { std::cin >> t[p]; }
template<typename First, typename...Rest>void MACRO_VEC_ROW_Scan(int p, First& first, Rest&...rest) { std::cin >> first[p]; MACRO_VEC_ROW_Scan(p, rest...); }
#define OUT(d) std::cout<<d;
#define FOUT(n, d) std::cout<<std::fixed<<std::setprecision(n)<<d;
#define SOUT(n, c, d) std::cout<<std::setw(n)<<std::setfill(c)<<d;
#define SP std::cout<<" ";
#define TAB std::cout<<"\t";
#define BR std::cout<<"\n";
#define ENDL std::cout<<std::endl;
#define FLUSH std::cout<<std::flush;
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define MAT(type, c, m, n) std::vector<std::vector<type>> c(m, std::vector<type>(n));for(auto& r:c)for(auto& i:r)std::cin>>i;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)
#define FORLL(i, a, b) for(ll i=ll(a);i<ll(b);++i)
#define RFORLL(i, a, b) for(ll i=ll(b)-1;i>=ll(a);--i)
#define REPLL(i, n) for(ll i=0;i<ll(n);++i)
#define RREPLL(i, n) for(ll i=ll(n)-1;i>=0;--i)
#define PAIR std::pair<int, int>
#define PAIRLL std::pair<ll, ll>
#define IN(a, x, b) (a<=x && x<b)
#define SHOW(d) {std::cerr << #d << "\t:" << d << "\n";}
#define SHOWVECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOWVECTOR2(v) {std::cerr << #v << "\t:\n";for(const auto& xxx : v){for(const auto& yyy : xxx){std::cerr << yyy << " ";}std::cerr << "\n";}}
#define SHOWPAIR(p) {std::cerr << #p << "\t:(" << p.first << ",\t" << p.second << ")\n";}
#define SHOWPAIRVECTOR2(v) {std::cerr << #v << "\t:\n";for(const auto& xxx : v){for(const auto& yyy : xxx){std::cerr<<'('<<yyy.first<<", "<<yyy.second<<") ";}std::cerr << "\n";}}
#define SHOWPAIRVECTOR(v) {for(const auto& xxx:v){std::cerr<<'('<<xxx.first<<", "<<xxx.second<<") ";}std::cerr<<"\n";}
#define SHOWQUEUE(a) {std::queue<decltype(a.front())> tmp(a);std::cerr << #a << "\t:";for(int i=0; i<static_cast<int>(a.size()); ++i){std::cerr << tmp.front() << "\n";tmp.pop();}std::cerr << "\n";}
template<typename T> inline T CHMAX(T& a, const T b) { return a = (a < b) ? b : a; }
template<typename T> inline T CHMIN(T& a, const T b) { return a = (a > b) ? b : a; }
#define EXCEPTION(msg) throw std::string("Exception : " msg " [ in ") + __func__ + " : " + std::to_string(__LINE__) + " lines ]"
#define TRY(cond, msg) try {if (cond) EXCEPTION(msg);}catch (std::string s) {std::cerr << s << std::endl;}
void CHECKTIME(std::function<void()> f) { auto start = std::chrono::system_clock::now(); f(); auto end = std::chrono::system_clock::now(); auto res = std::chrono::duration_cast<std::chrono::nanoseconds>((end - start)).count(); std::cerr << "[Time:" << res << "ns  (" << res / (1.0e9) << "s)]\n"; }

#define int ll
using ll = long long;
using ull = unsigned long long;
constexpr int INFINT = 1 << 30;                          // 1.07x10^ 9
constexpr int INFINT_LIM = (1LL << 31) - 1;              // 2.15x10^ 9
constexpr ll INFLL = 1LL << 60;                          // 1.15x10^18
constexpr ll INFLL_LIM = (1LL << 62) - 1 + (1LL << 62);  // 9.22x10^18
constexpr double EPS = 1e-7;
constexpr int MOD = 1000000007;
constexpr double PI = 3.141592653589793238462643383279;

std::vector<ll> primeFact(ll n) {
	std::vector<ll> result;
	for (ll i = 2; i*i <= n; ++i) {
		if (n%i == 0) {
			do {
				n /= i;
			} while (n%i == 0);
			result.push_back(i);
		}
	}
	if (n != 1) {
		result.push_back(n);
	}
	return result;
}

int phi(int n) {
	int res = n;
	auto v(primeFact(n));
	for (const auto& x : v) {
		res *= (x - 1);
		res /= x;
	}
	return res;
}

ll gcd(ll a, ll b) {
	return b ? gcd(b, a%b) : a;
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

// f(n) = phi(n)
// g(n) = n

// [where k = 1           ] F_k(n) = f(g(n)) = f(n) = phi(n)
// [where k > 1 and k:even] F_k(n) = g(F_{k-1}(n)) = F_{k-1}(n)
// [where k > 1 and k: odd] F_k(n) = f(F_{k-1}(n)) = phi(F_{k-1}(n))

// therefore...
// (if k is even ... k<-(k-1))
// [where k = 1] F_k(n) = phi(n)
// [where k > 1] F_k(n) = phi(F_{k-2}(n))

signed main() {
	INIT;
	VAR(ll, n, k);
	k = (k + 1) / 2;
	REP(i, k) {
		if (n == 1) break;
		n = phi(n);
	}
	n %= 1000000007;
	OUT(n)BR;
	return 0;
}

#include <iostream>
#include <cstdio>
#include <bitset>
#include <vector>
#include <numeric>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <set>
#include <queue>
#include <stack>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cassert>

using namespace std;

#define mem(a, v) memset(a, v, sizeof (a))
#define x first
#define y second
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define mt make_tuple
#define sz(x) int((x).size())
#define rep(i, n) for (int i = 0; i < int(n); i ++)
#define repi(i, a, n) for (int i = (a); i < int(n); i ++)
#define repe(x, v) for (auto x: (v))
#define vt(x) vector < x >
#define px(x) pair < x, x >
#define pxy(x, y) pair < x, y >

typedef long long ll;

vt(int) p;

ll phi(ll x) {
  ll ret = x;
  for (int i = 0; 1ll*p[i]*p[i] <= x; i ++) {
    if (x % p[i]) {
      continue;
    }
    ret /= p[i];
    ret *= p[i]-1;
    while (x % p[i] == 0) {
      x /= p[i];
    }
  }
  if (x != 1) {
    ret /= x;
    ret *= x-1;
  }
  return ret;
}

void make(int n = 1001006) {
  vt(int) is(n);
  repi(i, 2, n) {
    if (!is[i]) {
      p.push_back(i);
      for (int j = 2*i; j < n; j += i) {
        is[j] = 1;
      }
    }
  }
}

int main () {
  std::ios_base::sync_with_stdio(false);
  make();
  ll n, k;
  cin >> n >> k;
  if (n == 1) {
    cout << 1;
    return 0;
  }
  ll ans = phi(n%2 ? n : n-1);
  for (k --; k >= 2&& ans != 1; k -= 2) {
    ans = phi(ans-1);
  }
  if (ans > 1 && k) {
    ans --;
  }
  cout << ans;
  return 0;
}

#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define ff first
#define ss second
using namespace std;
const int N=200005;
const long long M=1e9+7;
typedef long long ll;
typedef long double lb;
inline void read(int &x){x=0; char ch=getchar();while(ch<'0') ch=getchar();while(ch>='0'){x=x*10+ch-48; ch=getchar();}}
//------------------------------------------head---------------------------------------------------//
inline ll phi(ll n)
{
	if(n==1) return 1;
    ll T=n,TT=n;
    for(ll i=2;i*i<=TT;i++) if(n%i==0)
    {
        T=T/i*(i-1);
        while(n%i==0) n/=i;
    }
	if(n>1) T=T/n*(n-1);
    return T;
}
int main()
{
	ll n,k;scanf("%I64d%I64d",&n,&k); k=k/2ll;
	if(k==1) {printf("%I64d\n",phi(n)%M);return 0;}n=phi(n);
	while(1)
	{
		n=phi(n); k--; if(!k) break;
		if(n==1) break;
	}
	printf("%I64d\n",n%M);
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ull unsigned long long
#define ld long double

#define fi first
#define se second

#define pb push_back
#define mp make_pair

#define sz(a) a.size()
#define all(v) v.begin(), v.end()
#define bpc(v) __builtin_popcountll(v)

#define IOS ios_base :: sync_with_stdio(false); cin.tie(NULL);

#define sc scanf
#define pr printf

#define x Madi
#define y Turysbek
#define x1 Issyk
#define y1 KTL

const int N = 1e5 + 5;
const int Inf = 1e9 + 1;
const int Mod = 1e9 + 7;

int n, k;

int phi(int n)
{
	int res = n;
	for (int i = 2; i * i <= n; ++i)
	{
		if (n % i == 0)
		{
			while (n % i == 0)
				n /= i;
			res -= res / i;
		}
	}
	if (n > 1)
		res -= res / n;
	return res;
}

main()
{
		/*
	freopen(".in", "r", stdin);
	freopen(".out", "w", stdout);
		*/
	cin >> n >> k;
	while (k > 0)
	{
		if (n == 1)
			break;
		n = phi(n);
		k -= 2;
	}
	cout << n;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define per(i,l,r) for(int i=(r)-1;i>=(l);--i)
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl

const int N = 1e5 + 7;
const int MOD = 1e9 + 7;

ll getphi(ll x) {
    ll ret = x;
    for (ll i = 2; i * i <= x; i++) if (x % i == 0) {
        ret -= ret / i;
        while (x % i == 0) x /= i;
    }
    if (x > 1) ret -= ret / x;
    return ret;
}

ll n, k;

int main() {

    freopen("xx.in", "r", stdin);

    cin >> n >> k;
    ll ans = n;
    for (ll i = (k + 1) >> 1; i >= 1; i--) {
        ll pre = getphi(ans);
        if (ans == pre) break; else ans = pre;
    }
    cout << ans % MOD;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXS = 1000007;
const int MAXM = 10007;
const int MOD = 1e9 + 7;

LL n, k;
int kp;
bool isp[MAXS];
int prm[MAXS];

void init ();
void input ();
void work ();

LL getphi ( LL a );
bool isprm ( LL a );

int main()
{
	init();
	input();
	work();
}

void init ()
{
	// Init Everything Here

	ios::sync_with_stdio ( false );

	INIT ( isp, true );
	isp[0] = isp[1] = false;
	kp = 0;
	lp ( i, 2, MAXS )
		if ( isp[i] ){
			prm[kp++] = i;
			if ( i < MAXM ) for ( int j = i * i; j < MAXS; j += i ) isp[j] = false;
		}
}

void input ()
{
	// input method

	cin >> n >> k;
}

void work ()
{
	// main work

	for ( int i = 1; i <= k; i += 2 ){
		n = getphi ( n );
		if ( n == 1 ){
			cout << 1 << endl;
			return;
		}
	}

	cout << n % MOD << endl;
}

LL getphi ( LL a )
{
	if ( a == 1 ) return 1;
	if ( isprm ( a ) ) return a - 1;

	int v;
	LL phi = a;
	lp ( i, 0, kp ){
		v = prm[i];
		if ( a % v == 0 ){
			phi = phi / v * ( v - 1 );
			while ( ! ( a % v ) ) a /= v;
			if ( a == 1 ) return phi;
			if ( isprm ( a ) ){
				phi = phi / a * ( a - 1 );
				return phi;
			}
		}
	}

	return phi;
}

bool isprm ( LL a )
{
	if ( a < 2 ) return false;
	int lm = sqrt ( SC ( double, a ) ) + 3;
	lm = qmin ( lm, a-1 );
	lpi ( i, 1, lm )
		if ( a % i == 0 ) return false;
	return true;
}

//Aditya Agrawal
// DTU

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <utility>
#include <iterator>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <deque>
#include <bitset>

#define mod 1000000007
#define ima 1000000004
#define imi -1000000004
#define llma 1000000000000000004
#define llmi -1000000000000000004
#define lp(i,n) for(i=0;i<n;i++)
#define li(i,n) for(i=n-1;i>=0;i--)
#define readi(x) scanf("%d",&x)
#define reads(x) scanf("%s",&x)
#define readc(x) scanf("%c",&x)
#define ll long long int
#define ld long double
#define f first
#define s second
#define pa pair<ll,ll>
#define pad pair<double ,double>
#define pai pair<int,int>
#define mp make_pair
#define nn 1000005
#define pi 3.1415926535898
#define inf 1e35
#define diff 1e-7
#define md 359999
#define pb push_back
#define sync ios::sync_with_stdio(false);cout.tie(0);cin.tie(0);

using namespace std;

int s[nn+4];
ll totient[nn+4];

vector<ll > prime;

vector<ll > g[1000000];

void sieve()
{
    int i,j;
    int k=sqrt(nn);
    for(i=2;i<=nn;i++)
        totient[i]=i;
    for(i=2;i<=nn;i++)
    {
        if(s[i]!=-1)
        {
            prime.pb(i);
            for(j=1;i*j<=nn;j++)
            {
                totient[i*j]*=(i-1);
                totient[i*j]/=i;
                s[i*j]=-1;
            }
        }
       // cout<<totient[i]<<" "<<i<<endl;
    }
}

int main()
{
    sync
    ll n,k;
    sieve();
    int i;

//    ll c;
//    for(i=0;i<prime.size();i++)
//    {
//        c=prime[i];
//        while(c!=1)
//        {
//            c=totient[c];
//            g[i].pb(c);
//        }
//       // cout<<i<<" "<<g[i].size()<<endl;
//    }
    cin>>n>>k;
    ll b;
    ll l;
    ll a=n;
    ll ans=1;
    k/=2;
    while(a>1)
    {
        for(i=0;i<prime.size();i++)
        {
            l=1;
            while(a%prime[i]==0)
            {
                a/=prime[i];
                l*=prime[i];
            }

            //cout<<i<<" "<<l<<endl;
            b=0;
            while(b<k && l!=1)
            {
                b++;
                l=totient[l];
            }

            ans*=l;
            ans%=mod;
            if(a==1)
                break;
        }
        k--;
        a--;
    }

    cout<<ans;
}

//In the Name of God
//Ya Ali

#include<bits/stdc++.h>

#define int long long

#define err(A) cout<<#A<<" = "<<(A)<<endl

using namespace std;

const int M=1e9+7;
int n,k;

int f(int x)
{
  int ret=x;
  for(int i=2,X=x;i*i<=X;i++)
    if(x%i==0)
      {
	ret/=i;
	ret*=i-1;
	while(x%i==0)
	  x/=i;
      }
  if(x>1)
    return x-1;
  return ret;
}

main()
{
  ios::sync_with_stdio(0);cin.tie(0);

  cin>>n>>k;

  k=(k+1)/2;

  while(k-- and n>1)
    n=f(n);

  cout<<n%M<<endl;

  return 0;
}

#include <bits/stdc++.h>

using namespace std;

long long f(long long n) {
  if(n == 1) return 1;
  long long ret = n;
  for(long long i = 2; i * i <= n; ++i) {
    if(n % i == 0) ret = (ret / i) * (i - 1);
    while(n % i == 0) n /= i;
  }
  if(n > 1) ret = (ret / n) * (n - 1);
  return ret;
}

int main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL);

  long long n, k;
  cin >> n >> k;

  long long ans = f(n);

  for(long long i = 2; i <= k; ++i) {
    if(ans == 1) {
      break;
    }
    if(i % 2 == 1) ans = f(ans);
  }

  cout << ans << endl;
  return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
using namespace std;
typedef long long int ll;
ll phi(ll t) {
	ll k=(ll)sqrt(t)+10;
	ll ans=t;
	for(ll i=2; i<=k; i++){
		if(t%i==0){
			ans=ans/i*(i-1);
			while(t%i==0){
				t=t/i;
			}
		}
	}
	return ans;
}
int main(){
	ll i, j, k, n;
	cin>>n>>k;
	//cout<<phi(7);
	k=(k+1)/2;
	while((k--)&&n>1){
		n=phi(n);
	}
	cout<<(n%1000000007);
	return 0;
}

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <string>
#include <complex>

using namespace std;

#define mst(x,v) memset(x,v,sizeof(x))
#define rp(k,x,v) for(int k = x;k<v;++k)
#define RP(k,x,v) for(int k = x;k<=v;++k)
#define lp(k,x,v) for(int k = x;k>v;--k)
#define LP(k,x,v) for(int k = x;k>=v;--k)
#define ll long long
#define ull unsigned long long
#define fr(file) freopen(file,"r",stdin);
#define fw(file) freopen(file,"w",stdout);
#define lowbit(x) (x&-x)
#define adde(u,v) edg[++cnt]=Edge(u,v,g[u]),g[u]=cnt
#define addew(u,v,w) edg[++cnt]=Edge(u,v,g[u],w),g[u]=cnt
#define addedg(u,v,w,cap) edg[++cnt]=Edge(u,v,g[u],w,cap),g[u]=cnt,edg[++cnt]=Edge(v,u,g[v],-w,0),g[v]=cnt
#define fson Edge *e;for(int i = g[u];~i&&(e=&edg[i]);i=e->next)
#define LB lower_bound
#define UB upper_bound
#define lenr(a,b,k) UB(A,b,k)-LB(A,b,k);
#define inp(n,a) ru(n);RP(i,1,n) ru(a[i]);
#define spf(s,a,n) t[0]=0;RP(i,1,n) t[i]=t[i-1]+a[i];
#define ppf(s,a,n) t[0]=1; RP(i,1,n) t[i]=(t[i-1]*(a[i]%mod))%mod;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define piii pair<pii,int>
#define plll pair<pll,ll>
#define mpt int mid = l+r>>1;
#define ls (k<<1)
#define rs (k<<1|1)
#define INF (1<<30)
#define LINF (1LL << 62)
#define ini(n,a) RP(i,1,n) a[i]=INF;
#define inl(n,a) RP(i,1,n) a[i]=LINF;
#define dsui(n,p) RP(i,1,n) p[i]=i;
#define all(a) a.begin(),a.end()
#define inr (ql<=l && r<=qr)
#define cpx complex<double>

char READ_DATA;
int SIGNAL_INPUT;
template <typename Type>
inline char ru(Type &v)
{
	SIGNAL_INPUT = 1;
	while ((READ_DATA = getchar()) < '0' || READ_DATA > '9')
		if (READ_DATA == '-')
			SIGNAL_INPUT = -1;
		else if (READ_DATA == EOF)
			return EOF;
	v = READ_DATA - '0';
	while ((READ_DATA = getchar()) >= '0' && READ_DATA <= '9')
		v = v * 10 + READ_DATA - '0';
	v *= SIGNAL_INPUT;
	return 1;
}

template<typename A, typename B > inline char ru(A&x, B&y) { if (ru(x) == EOF) return EOF; ru(y); return 2; }
template<typename A, typename B, typename C>inline char ru(A&x, B&y, C&z) { if (ru(x) == EOF) return EOF; ru(y); ru(z); return 3; }
template<typename A, typename B, typename C, typename D>inline char ru(A&x, B&y, C&z, D&w) { if (ru(x) == EOF) return EOF; ru(y); ru(z); ru(w); return 4; }

struct Edge
{
	int  u, v, next;
	ll w, cap, flow;
	Edge(int _u = 0, int _v = 0, int nxt = -1, ll _w = 1, ll _cap = 0)
	{
		u = _u;
		v = _v;
		w = _w;
		cap = _cap;
		flow = 0;
		next = nxt;
	}
};

int mod = 1e9 + 7;
const int maxn = 1e6 + 10;
const double pi = acos(-1.0);

ll phi(ll n)
{
	ll ans = n;
	ll m = sqrt(n);
	RP(i, 2, m)
	{
		if (n%i == 0)
		{
			ans /= i;
			ans *= (i - 1);
			while (n%i == 0)
				n /= i;
		}
	}
	if (n > 1)
	{
		ans /= n;
		ans *= (n - 1);
	}

	return ans;
}

ll sum(ll k,ll n)
{
	if (k <= 1)
		return phi(n);
	else if (n <= 2)
		return 1;
	return sum(k - 1, phi(n));
}

ll n, k;

int main()
{
	ru(n, k);
	k /= 2;
	printf("%lld", sum(k, n));
}

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
using namespace std;
bool fix[1000150];
vector<int> pr;

ll phi(int n){
	ll res=n;
	for(int i=0;i<pr.size();i++){
		ll p=pr[i];
		if(p*p>n){
			break;
		}
		if(n%p==0){
			res = res/p*(p-1);
			while(n%p==0){
				n/=p;
			}
		}
	}
	if(n>1)
		res = res/n*(n-1);

	return res;
}

main(){
	for(int i=2;i<1000150;i++){
		fix[i]=1;
	}

	for(int i=2;i<1000150;i++){
		if(fix[i]){
			for(int j=2*i;j<1000150;j+=i){
				fix[j]=0;
			}
		}
	}

	for(int i=2;i<1000150;i++){
		if(fix[i])
			pr.pb(i);
	}

	ll n,k;
	cin>>n>>k;
	k=(k+1)/2;
	while(n>1&&k>0){
		n=phi(n);
		k--;
	}
	cout<<n%mod<<endl;

}

#include <cassert>
//#define NDEBUG

#include <cstdlib>
#include <cstdint>
#include <cmath>

#include <iomanip>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<ll,ll> PLL;
typedef std::pair<int,int> PII;

template<typename T>
void read_to_vector(size_t N, std::vector<T> &v) {
  for(size_t i=0; i<N; i++) {
    T tmp;
    std::cin >> tmp;
    v.push_back(tmp);
  }
}
template<typename T>
void print_vector(const std::vector<T> &v) {
  for(auto it = v.begin(); it<v.end(); it++) {
    if(it!=v.begin())
      std::cout << " ";
    std::cout << (*it);
  }
}

vector<ll> primes;

//Solution:
const ll MOD = 1000000007;

ll phi(ll x) {
  if (x == 1) { return 1; }
  ll res = 1;
  //  cout << "Phi: " << x << " " << res << endl;
  for (auto & p : primes) {
    if (x%p == 0) {
      res *= (p-1);
      x /= p;
      while (x%p == 0) {
        x/= p;
        res *= p;
      }
    }
    if (x == 1) { break; }
  }
  return res;
}

void solve() {
  ll n, k;
  cin >> n >> k;

  ll kk = (k+1)/2;

  ll val = n;
  for (ll i=0; i<kk; i++) {
    val = phi(val);
    if (val == 1) {
      break;
    }
  }

  cout << (val%MOD) << endl;
}

//This is executed before any input is read.
void pre_compute() {
  vector<bool> prime(111111, true);
  for (int i=2; i<111111; i++) {
    if (!prime[i]) continue;
    primes.push_back(i);
    for (int j=2*i; j<111111; j+=i) {
      prime[j] = false;
    }
  }
  prime[0] = false;
  prime[1] = false;

}

int main() {
  std::cout << std::setprecision(15);
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  pre_compute();

  solve();

  return 0;
}

#include<bits/stdc++.h>
using namespace std;
map<long long,long long> ff;
int mod=1e9+7;
int f(long long int x)
{
    if(x==1) return 1;
    long long int &ans=ff[x];
    if(ans) return ans; ans=x-1;
    long long l=1,r=1e6+7,mid=1;
    while(l<r){
        mid =(l+r+1)/2; if(mid*mid<=x) l=mid;
        else r=mid-1;
    }
    for(long long int i=l;i>=2;i--)
    {
        if(x%i==0) ans-=(i==x/i?f(i):f(x/i)+f(i));
    }
    return ans;
}
void ANS(long long int x)
{
    printf("%lld",x%mod); exit(0);
}
int main()
{
    long long int n,k;
    cin>>n>>k;
    k=(k+1)/2;
    for(int i=1;i<=k;i++)
    {
        if(n==1) ANS(1);
        n=f(n);
    }
    ANS(n);
}

#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<bitset>
#include<algorithm>
#include<map>
using namespace std;
const int maxn = 1234567;
int gcd(int a, int b){
	if (!b) return a;
	return gcd(b, a % b);
}
map<long long, long long> f;
long long F(long long x){
	if (f[x] != 0) return f[x];
	long long num = x;
	long long ed = (long long)sqrt(x);

	for (int i = 1; i <= ed; i ++){
		if (x % i == 0){
			num -= F(i);
			if (i * i != x && i != 1)
				num -= F(x / i);
		}
	}

	return f[x] = num;
}
long long k, n;
int main(){
	cin >>n >>k;
	k = (k - 1) / 2;
	f[1] = 1;
	long long ans = F(n);
//	cout <<ans <<endl;
	for (long long i = 1; i <= k; i ++){
		if (ans == 1) break;
		ans = F(ans);
	}
	cout <<ans <<endl;

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define st first
#define nd second
#define db(x) cerr << #x << " = " << x << endl
#define _ << ", " <<
typedef long long ll;
const ll N = 1e6 + 50;

bool sieve[N];
vector<ll> primes;

ll gcd(ll a, ll b){ return a ? gcd(b%a, a) : b; }

ll f(ll n){
  // Euler phi (totient)
  ll ind = 0, pf = primes[0], ans = n;
  while (1ll*pf*pf <= n) {
      if (n%pf==0) ans -= ans/pf;
        while (n%pf==0) n /= pf;
          pf = primes[++ind];
  }
  if (n != 1) ans -= ans/n;
  return ans;
}

int main(){
  for(ll i = 2; i < N; i++)
    if(!sieve[i]){
      primes.push_back(i);
      for(ll j = i*2; j < N; j+= i)
        sieve[i] = true;
    }

  ll n, k;
  cin >> n >> k;

  for(ll i = 1; i <= k and n != 1; i+=2){
    n = f(n);
  }
  cout << n << endl;
}

#include <bits/stdc++.h>

#define NN 1000010

#define inf 0x3f3f3f3f

#define mod 1000000007

using namespace std;

typedef long long INT;

int main(){

	INT N, K;

	cin>>N>>K;

	K=(K+1)/2;

	INT M;

	while(K--){

		M=N;

		for(int i=2; i*i<=N; i++){

			if(N%i==0){

				M=M*(i-1)/i;

				while(N%i==0) N/=i;

			}

		}

		if(N>1) N=M/N*(N-1);

		if(N<=1) break;

	}

	N%=1000000007;

	cout<<N<<endl;

}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll n,k;
ll mul(ll a,ll b,ll p)
{
    ll k = ((ld)a*(ld)b)/(ld)p;
    ll tmp = (ld)a*(ld)b-(ld)k*(ld)p;
    return tmp;
}
ll pow(ll a,ll t,ll p)
{
    if (t == 0) return 1;
    ll tmp = pow(a,t >> 1,p);
    tmp = mul(tmp,tmp,p);
    if (t&1) tmp = mul(tmp,a,p);
    return tmp;
}
int isprime(ll x)
{
    if (x == 1) return 0;
    int t = 20;
    while (t--)
    {
        ll tmp = rand()%(x-1)+1;
        ll y = pow(tmp,x-1,x);
        if (y != 1) return 0;
    }
    return 1;
}
ll f(ll x)
{
    ll tmp = x;
    for (ll i = 1;i*i <= x;i++)
    {
        if (x%i) continue;
        if (isprime(i)) tmp = (tmp/i)*(i-1);
        ll another = x/i;
        if (another != i)
            if (isprime(another))
                tmp = (tmp/another)*(another-1);
    }
    return tmp;
}
int main()
{
    cin >> n >> k;
    k = (k+1)/2;
    for (ll i = 1;i <= k;i++)
    {
        if (k-i+1 >= n) {n = 1; break;}
        n = f(n);
    }
    printf("%lld",n%1000000007);
    return 0;
}

//Aditya Agrawal
// DTU

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <utility>
#include <iterator>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <deque>
#include <bitset>

#define mod 1000000007
#define ima 1000000004
#define imi -1000000004
#define llma 1000000000000000004
#define llmi -1000000000000000004
#define lp(i,n) for(i=0;i<n;i++)
#define li(i,n) for(i=n-1;i>=0;i--)
#define readi(x) scanf("%d",&x)
#define reads(x) scanf("%s",&x)
#define readc(x) scanf("%c",&x)
#define ll long long int
#define ld long double
#define f first
#define s second
#define pa pair<ll,ll>
#define pad pair<double ,double>
#define pai pair<int,int>
#define mp make_pair
#define nn 1000005
#define pi 3.1415926535898
#define inf 1e35
#define diff 1e-7
#define md 359999
#define pb push_back
#define sync ios::sync_with_stdio(false);cout.tie(0);cin.tie(0);

using namespace std;

int s[nn+4];
ll totient[nn+4];

vector<ll > prime;

vector<ll > g[1000000];

void sieve()
{
    int i,j;
    int k=sqrt(nn);
    totient[1]=1;
    for(i=2;i<=nn;i++)
        totient[i]=i;
    for(i=2;i<=nn;i++)
    {
        if(s[i]!=-1)
        {
            prime.pb(i);
            for(j=1;i*j<=nn;j++)
            {
                totient[i*j]*=(i-1);
                totient[i*j]/=i;
                s[i*j]=-1;
            }
        }
       // cout<<totient[i]<<" "<<i<<endl;
    }
}

int main()
{
    sync
    ll n,k;
    sieve();
    int i;

//    ll c;
//    for(i=0;i<prime.size();i++)
//    {
//        c=prime[i];
//        while(c!=1)
//        {
//            c=totient[c];
//            g[i].pb(c);
//        }
//       // cout<<i<<" "<<g[i].size()<<endl;
//    }
    cin>>n>>k;
    ll b;
    ll l;
    ll a=n;
    ll ans=1;
    k=(k+1)/2;
   // cout<<totient[128];

    while(a>1 && k>0)
    {
        ans=1;
        for(i=0;i<prime.size();i++)
        {
            l=1;
            while(a%prime[i]==0)
            {
                a/=prime[i];
                l*=prime[i];
            }

            //cout<<i<<" "<<l<<endl;
            if(l!=1)
            {
                l*=(prime[i]-1);
                l/=prime[i];
            }

            ans*=l;
            //cout<<ans<<" ";
            if(a==1)
                break;
        }
        k--;
        if(a!=1)
            a--;
        a*=ans;
    }

    cout<<ans;
}

#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
const long long H = 1e9 + 7;
long long n,k;
bool snt[1000005];
vector <long long> m;
void read()
{
    scanf("%I64d%I64d",&n,&k);
    if(k > 200) k = 200;
    return;
}

void san()
{
    for (int i = 2;i <= 1000000;i++) snt[i] = true;
    snt[1] = false;
    for (int i = 1;i <= 10000;i++)
    if(snt[i])
        for (int j = i;j <= 1000000/i ;j++) snt[i * j] = false;
    for (int i = 1;i <= 1000000;i++) if(snt[i]) m.push_back(i);
    return;
}

long long ff(long long so)
{
    long long kq = so;
    for (int i = 0 ; i < m.size();i++) if(so % m[i] == 0)
        kq = kq / m[i] * (m[i] - 1);
    return kq;
}

long long tinhf(long long bac,int so)
{
    if(bac == 0) return n;
    if(so == 1) return ff(tinhf(bac - 1,1 - so)); else return tinhf(bac - 1,1 - so);
}

void solve()
{
    if(k % 2 == 0) printf("%I64d",tinhf(k,0) % H); else printf("%I64d",tinhf(k,1) % H);
    return;
}

int main()
{
    san();
    read();
    solve();
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
const int maxi=1e6+1;
long long n,k,val;
int b[maxi];
long long f[maxi];
long long totient(long long val)
{
    double ans=val;
    for (long long i=2;i<=maxi;i++)
     if (!b[i] && val%i==0)
    {
        ans*=(1-(double)1/i);
        while(val%i==0)
            val/=i;
    }
    long long res=floor(ans);
    return res;
}
int main()
{
  cin>>n>>k;

 for (int i=2;i< maxi;i++)
 if (b[i]==0)
 {
     for (int j=2*i;j<maxi;j+=i)
        b[j]=1;
 }
   val=n;
   int id=1;
   if (val==1)
   {
       f[id]=1;
   }

  while(val!=1)
  {
    val=totient(val);
    //printf("%lld\n",val);
    f[id]=val;
    id++;
  }

  k++;
  k/=2;

if (id<k) printf("1\n"); else printf("%lld\n",f[k]);
 return 0;
}
//Pamet je ogranicena...

#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fo(i,a,b) for(ll i=a;i<b;i++)
#define fo_(i,a,b) for(int i=a;i>b;i--)
#define M(a) memset(a,0,sizeof a)
#define M_(a) memset(a ,-1,sizeof a)
#define pb push_back
#define PI 3.14159265
#define nmax 50
const ll inf = std::numeric_limits<ll>::max();
const ll mod = 1e9+7;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll f(ll c){
    set<ll> s;
    fo(i,2,(ll)sqrt(c)+1){
        if(i>=c) break;
        if(c%i != 0) continue;
        s.insert(i);
        s.insert(c/i);
    }
    ll ans = c;
    for(auto i : s){
        bool ff = true;
        fo(j,2,(ld)(sqrt(i)+1.01)){
            if(j>=i) break;
            if(i%j==0) {ff = false; break;}
        }
        if(ff){
            ans *= i-1;
            ans /= i;
        }

    }
    return ans;
}

int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    ll n,k;
    cin >> n >> k;
    k = (k+1)/2;
    while(n != 1 && k > 0){
        k--;
        n = f(n);
    }
    cout << (n+mod)%mod;

    return 0;
}

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
long long A[210],al;
int main()
{
	long long n,k,i,j,x,y;
	scanf("%I64d%I64d",&n,&k);
	k=(k+1)/2;
	A[0]=n;
	while(A[al]!=1)
	{
	  x=y=A[al];
	  for(i=2;i*i<=x;i++)
		if(x%i==0)
		{
		  while(x%i==0)x/=i;
		  y=y/i*(i-1);
		}
	  if(x!=1)y=y/x*(x-1);
	  A[++al]=y;
	}
	if(k<=al)printf("%I64d\n",A[k]);
	else printf("1\n");
	return 0;
}

//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)

using namespace std;
typedef long long ll;
typedef pair<ll, ll> ii;
typedef pair<int, ii> iii;

ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}

vector<ll> factors, primes;
ll k;
int sieve[1000005];
set<ll> pppp;

ll euler_totient(ll n){
	if(pppp.find(n) != pppp.end())
		return n-1;
	ll ans = n;
	for(auto it : primes){
		if(1LL*it*it > n)	break;
		if(n % it != 0)	continue;
		while(n % it == 0)
			n /= it;
		ans /= it;
		ans *= it-1;
	}
	if(n != 1){
		ans /= n;
		ans *= n-1;
	}
	return ans;
}

ll calc(ll n){
	ll val = euler_totient(n);
	for(ll i=3;i<=k;i+=2){
		val = euler_totient(val);
		if(val == 1)	break;
	}
	return val%MOD;
}

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    for(int i=2;i<=1000*1000;i++)
    	if(!sieve[i]){
    		primes.pb(i);
    		pppp.insert(i);
    		for(int j=i;j<=1000*1000;j+=i)
    			sieve[j] = 1;
    	}

    ll n;
    cin>>n>>k;

    for(ll i=2;i*i<=n;i++)
    	if(n % i == 0){
    		ll temp = 1;
    		while(n % i == 0){
    			n /= i;
    			temp *= i;
    		}
    		factors.pb(temp);
    	}

    if(n > 1)
    	factors.pb(n);

// cout<<"factors: ";for(auto it : factors)	cout<<it<<" ";cout<<endl;

// for(int i=1;i<=10;i++)	cout<<i<<":"<<euler_totient(i)<<" ";cout<<endl;

    ll ans = 1;
    for(auto it : factors)
    	ans = (ans * calc(it)) % MOD;

    cout<<ans;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

long long phi(long long n) {
  long long ans = n;
  for (int i = 2; 1LL * i * i <= n; ++i)
    if (n % i == 0) {
      ans /= i;
      ans *= (i - 1);
      while (n % i == 0)
        n /= i;
    }
  if (n > 1) {
    ans /= n;
    ans *= (n - 1);
  }
  return ans;
}

int main() {
  //freopen("date.in", "r", stdin);
  //freopen("date.out", "w", stdout);

  long long n, k;
  scanf("%lld%lld", &n, &k);
  for (; k >= 1 && n > 1; --k)
    if (k % 2 == 1)
      n = phi(n);
  printf("%lld\n", n);

  return 0;
}

#include<iostream>
#include<vector>
using namespace std;
bool isPrime[1000005];
vector<int> primes;

void gen()
{
	for(int i=0; i<1000005; i++) isPrime[i]=1;
	for(int i=2; i<1000005; i++)
	{
		if(isPrime[i])
		{
			primes.push_back(i);
			for(int k=2; k*i<1000005; k++)
				isPrime[k*i]=0;
		}
	}
}

long long tot(long long n)
{
	long long ret=n;
	for(int i=0; i<primes.size() && primes[i]<=n; i++)
	{
		if(n%primes[i]==0)
		{
			ret-=ret/primes[i];
			while(n%primes[i]==0) n/=primes[i];
		}
	}
	if(n>1) ret-=ret/n;
	return ret;
}

int main()
{
	gen();
	long long n,k;
	cin>>n>>k;
	long long lol=(k+1)/2;
	long long ans=n;
	while(lol--)
	{
		ans=tot(ans);
		// cout<"lol"<<endl
		if(ans==1) break;
	}
	cout<<ans<<endl;
}

#include<bits/stdc++.h>
using namespace std;
long long f(long long n)
{
	if(n==1)
		return 1;
	long long x=n;
	vector<int> v;
	for(int i=2;i*1ll*i<=x;++i)
	{
		if(x%i==0)
		{
			v.push_back(i);
			while(x%i==0)
				x/=i;
		}
	}
	if(x>1)
		v.push_back(x);
	int k=v.size();
	long long ans=0;
	for(int s=(1<<k)-1;s>=0;--s)
	{
		long long tmp=n;
		for(int i=0;i<k;++i)
			if(s&(1<<i))
				tmp/=-v[i];
		ans+=(abs(tmp)-1)*(abs(tmp)/tmp);
	}
	//cout<<"n="<<n<<" ans="<<ans<<endl;
	return ans;
}
int main()
{
	long long n,k,F=0;
	cin>>n>>k;
	F=f(n);
	for(long long i=2;i<=k;++i)
	{
		if(F==1)
			break;
		if(i%2)
			F=f(F);
	}
	cout<<F<<endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define st first
#define nd second
#define db(x) cerr << #x << " = " << x << endl
#define _ << ", " <<
typedef long long ll;
const ll N = 1e6 + 50;

bool sieve[N];
vector<ll> primes;

ll gcd(ll a, ll b){ return a ? gcd(b%a, a) : b; }

ll f(ll n){
  // Euler phi (totient)
  ll ind = 0, pf = primes[0], ans = n;
  while (1ll*pf*pf <= n) {
      if (n%pf==0) ans -= ans/pf;
        while (n%pf==0) n /= pf;
          pf = primes[++ind];
  }
  if (n != 1) ans -= ans/n;
  return ans;
}

int main(){
  for(ll i = 2; i < N; i++)
    if(!sieve[i]){
      primes.push_back(i);
      for(ll j = i*2; j < N; j+= i)
        sieve[j] = true;
    }

  ll n, k;
  cin >> n >> k;

  for(ll i = 1; i <= k and n != 1; i+=2){
    n = f(n);
  }
  cout << n << endl;
}

#include <bits/stdc++.h>
#define pb push_back

using namespace std;

void debug_out() { cerr << '\n'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

typedef pair<int,int> pii;
typedef long long int ll;
typedef long double ld;

const int DMAX = 1e5+10;
const int MOD = 1e9+7;

vector <int> vec;
vector <int> arb[DMAX];

int V[DMAX];

ll n,k;

int euler(ll n);

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int t,i,j;

    cin>>n>>k;
    if(k%2 == 0)
        k--;
    while(k > 1 && n > 1){
        n=euler(n);
        k-=2;
    }
    cout<<euler(n)<<'\n';

    return 0;
}
int euler(ll n){
    ll d,nr=1;
    ll ans=1;

    while(n%2 == 0){
        n/=2;
        nr*=2;
    }
    if(nr > 1){
        nr/=2;
        ans=nr;
    }
    for(d=3;d*d <= n;d+=2){
        nr=1;
        while(n%d == 0){
            n/=d;
            nr*=d;
        }
        if(nr > 1){
            nr/=d;
            ans=ans*(d-1)%MOD;
            ans=ans*nr%MOD;
        }
    }
    if(n > 1)
        ans=ans*(n-1)%MOD;
    return ans;
}

#pragma comment(linker, ”/STACK:38777216“
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <time.h>
#include <map>
#include <set>

using namespace std;

const int N = 1000005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

long long n,k;
long long answ[N];
map <long long,long long> mp;

int gcd (int a, int b) {
	if (b == 0)
		return a;
	else
		return gcd (b, a % b);
}

long long f(long long n){
    long long answ = 0;
    for(int i=1;i<n;i++){
        if(gcd(i,n-i) == 1){
            answ++;
            answ %= mod;
        }
    }
    return answ;
}

int main(){
    cin>>n>>k;
    k = (k + 1) / 2;
    while(k--){
        n = f(n);
    }
    cout<<n<<endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll euler(ll n){
    ll res=n;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            res=res/i*(i-1);
            while(n%i==0)
                n/=i;
        }
    }
    if(n>1)
        res=res/n*(n-1);
    return res;
}
int main()
{
    ll n,k;
    scanf("%lld %lld",&n,&k);
    ll c=(k+1)/2;
    while(c--)
    {
        n=euler(n);
        if(n==1)
            break;
    }
    printf("%lld\n",n);
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vl vector<ll>

#ifndef ONLINE_JUDGE
#  define dbg(x) (cerr << #x << " = " << (x) << endl)
#else
#  define dbg(x) 0
#endif

#define MOD 1000000007

ll phi(ll n)
{
    if(n==1)return 1;
    vl v;
    ll ans=n;
    for(ll i=2; i*i<=n; i++)
    {
        if(n%i==0)
        {
            v.emplace_back(i);
            while(n%i==0)
                n=n/i;
        }
    }
    if(n>1)
        v.emplace_back(n);
    for(auto it:v)
    {
        ans=ans/(it);
    }
     for(auto it:v)
    {
        ans=(ans*((it-1)%MOD))%MOD;
    }
    return ans;
}

int main()
{
    ll n,k;cin>>n>>k;
    ll times=(k+1)/2;
    ll ans=n;
    while(times--){
        if(ans==1)
            break;
        ans=phi(ans);
    }
    cout<<ans;
}

#include<bits/stdc++.h>
using namespace std;
#define LL long long

inline LL read() {
	LL x = 0, f = 1; char a = getchar();
	while(a < '0' || a > '9') { if(a == '-') f = -1; a = getchar(); }
	while(a >= '0' && a <= '9') x = x * 10 + a - '0', a = getchar();
	return x * f;
}

map<LL, LL> F;
LL n, k;

LL f(LL x) {
	if(F[x]) return F[x];
	F[x] = x;
	LL q = sqrt(x);
	for(int i = q - 1; i > 1; i--)
	if((x % i) == 0) F[x] -= f(i) + f(x / i);
	F[x] -= q * q == x ? f(q) : 0;
	F[x]--;
	return F[x];
}

int main() {
	n = read(); k = read();
	F[1] = 1;
	for(int i = (k + 1) / 2; i && (n > 1); i--) n = f(n);
	cout << n;
	return 0;
}

//By Ralif Rakhmatullin
#include<iostream>
#include<fstream>
#include<string>
#include<cstring>
#include<math.h>
#include<cassert>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<map>
#include<ctime>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<bitset>
#include<valarray>
#include<iterator>
#include<list>
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define S second
#define ld long double
#define F first
#define y1 LOL
#define ld long double
#define pb push_back
#define len length
#define sz size
#define beg begin
const ll INF = (ll)1e18 + 123;
const int inf=(int)2e9 + 123;
const int mod=1e9+7;
using namespace std;
ll phi(ll n) {
	ll result = n;
	for (ll i=2; i*i<=n; ++i)
		if (n % i == 0ll) {
			while (n % i == 0ll)
				n /= i;
			result -= result / i;
		}
	if (n > 1ll)
		result -= result / n;
	return result;
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ll n, k;
	cin >> n >> k;
	if(k > 42){
		cout << 1;
		return 0;
	}
	ll last = n;
	for(int i = 1; i <= k; i += 2){
		ll x = phi(last);
		last = x;
	}
	cout << last % mod;
	return 0;
}

#include<bits/stdc++.h>

using namespace std;

#define ull unsigned long long
#define LL long long int
#define pii pair<int,int>
#define mp make_pair
#define pb(x) push_back(x)
#define F(i,a,n) for(int i=(a);i<(n);++i)
#define FD(i,a,n) for(int i=(a);i>=(n);--i)
#define FE(it,x) for(it=x.begin();it!=x.end();++it)
#define V(x) vector<x>
#define S(x) scanf("%d",&x)
#define Sl(x) scanf("%llu",&x)
#define M(x,i) memset(x,i,sizeof(x))
#define fr first
#define se second
#define MOD 1e9+7

long long  phi(long long n) {
    long long i,res=n;
    for(i=2;i*i<=n;i++) {
        if(n%i==0) {
        while(n%i==0)
            n/=i;
        res-=res/i;
       }
   }
    if(n>1)
        res-=res/n;
    return res;
}
int main() {
	long long n,k;
	cin >> n >> k;
	k = k+1;
	k/=2;
	long long ans = n;
	while(k--){
		ans = phi(ans);
		if(ans == 1) break;
	}
	cout << ans << endl;
}

#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<cstdio>
#include<math.h>
#include<cstdlib>
#include<map>
#include<unordered_map>
#include<utility>
#include<stack>
#include<fstream>
#include<set>
#include<queue>
#include<iomanip>

using namespace std;

#define ll long long int
#define ld long double

const ll inf = 1e+15;
const ll mod = 1e9+7;

#define cincout ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define me(a,i) memset(a,i,sizeof(a))
#define mp make_pair
#define VLL vector <ll>
#define PLL pair <ll,ll>
#define VLD vector <ld>
#define pb push_back
#define sortv(v) sort(v.begin(),v.end())
#define sortvd(v) sort(v.begin(),v.end(),greater<int>())
#define printv(n,v) for(int i=0;i<n;i++)  {cout<<v[i]<<" ";}
#define vin(v,n,a) for(int i=0;i<n;i++)	{v.pb(a);cin>>v[i];}
#define FIT(it,v) for (typeof(v.begin()) it = v.begin(); it != v.end(); it++)
#define FF(i,a,b) for (int i = (a); i < (b); i++)
#define FD(i,a,b) for (int i = (a); i >= (b); i--)

ll cnt=0,ans,tmp,n,k;
void comp(ll n){
	if(n==1 || cnt==k)
		return;
	cnt++;
	ans = tmp = n;
	for(int i=2;i*i<=tmp;i++){
		if(tmp%i==0){
			while(tmp%i==0)
				tmp/=i;
			ans -= ans/i;
		}
	}
	if(tmp!=1)
		ans -= ans/tmp;
	comp(ans);
}

int main(){
	cincout;
	cin>>n>>k;
	k = (k+1)/2;
	comp(n);
	cout<<ans<<endl;
  	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool Finish_read;
template<class T>inline void read(T &x){Finish_read=0;x=0;int f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;if(ch==EOF)return;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();x*=f;Finish_read=1;}
template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}
template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}
template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}
/*================Header Template==============*/
#define PAUSE printf("Press Enter key to continue..."); fgetc(stdin);
ll n,k;
/*==================Define Area================*/
ll Euler(ll x) {
    ll res=x;
    for(ll i=2;i*i<=x;i++) {
        if(x%i==0) {
            res=res-res/i;
            while(x%i==0) x/=i;
        }
    }
    if(x>1) res-=res/x;
    return res;
}

ll Calc() {
	ll c=(k+1)/2;
	ll res=Euler(n);
	c--;
	while(c--) {
		res=Euler(res);
		if(res==1) break;
	}
	printf("%lld\n",res);
}

int main() {
	read(n);read(k);
	Calc();
	return 0;
}

/**
▂▃▅▇█▓▒░۩۞۩ ۩۞۩░▒▓█▇▅▃▂
Make it happen now, not tomorrow.
Tomorrow is a  loser's excuse.
▂▃▅▇█▓▒░۩۞۩ ۩۞۩░▒▓█▇▅▃▂
**/
#ifndef _GLIbCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplu >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <cstring>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include<random>
#include <chrono>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplu >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <time.h>
#endif
#define __ ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
// #define INF 0x7f7f7f7f
#define ull unsigned long long int
#define pii pair<int,int>
#define ll long long int
#define ld long double
#define MSET(x,y) memset(x,y,sizeof(x))
// #define l long
#define se second
#define AlphaSize 26
#define fi first
#define NIL 0
#define UNVISITED -1
#define EXPOLORED 0
#define mk make_pair
#define pb push_back
#define sc(n) scanf("%d",&n)
#define NIL 0
#define pii pair<int,int>
#define eps 1e-8
#define all(x) x.begin(),x.end()
#define me(u,v,w) make_pair(w,make_pair(u,v))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define inrange(x,y,row,col) (x>=0 && y>=0 && x<row && y<col)
#define foreach(e, x) for(__typeof(x.begin()) e = x.begin(); e != x.end(); ++ e)
// #define add(a,b) (a + b >= MOD ? a+b-MOD:a+b)
#define hs(c1,c2) (256*min(c1,c2) + max(c1,c2))
typedef struct{ int sum,suf,pre,max;} Node;
int toint(const string &s) { stringstream ss; ss << s; int x; ss >> x; return x; }
const int MAXN = 2e5+100;
const int UP = 31;
// const ll inf = 1e18;
// const int mod = 1e9+7;
const ll highest = 1e18;
// const int inf = 1e9+10;
// const dou    ble pi = 3.141592653589793238462643383;
const double pi = acos(-1);
const double Phi =  1.618033988749894;
const int logn = 20;
const double root5 = 2.236067977;
const int inf = 1e9;
const int ini = -1e9;
/**
▂▃▅▇█▓▒░۩۞۩ ۩۞۩░▒▓█▇▅▃▂
Make it happen now, not tomorrow.
Tomorrow is a loser's excuse.
▂▃▅▇█▓▒░۩۞۩ ۩۞۩░▒▓█▇▅▃▂
**/
const int mod = 1e9+7;
ll phi(ll n){
    ll i,res = n;
    for(i=2;i*i<=n;++i){
        if(n%i==0){
            while(n%i==0)n/=i;
            res *= (i-1);
            res /= i;
        }
    }
    if(n != 1){
        res *= (n-1);
        res /= n;
    }
    return res;
}
int main(){
    ll n, k;
    cin>>n>>k;
    k = (k+1)/2;
    while(k--){
        n = phi(n);
        if(n==1)break;
    }
    cout<<n<<endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define maxn 1000000+5
#define mod 1000000007
#define ll long long
vector<ll> prime;
bool vis[maxn];
void init()
{
    for(ll i=2;i<=maxn;i++)if(!vis[i])
    {
        prime.push_back(i);
        for(ll j=i*i;j<=maxn;j+=i)vis[j]=1;
    }
}
int phi(ll n)
{
    ll ret=n;
    for(auto p : prime)
    {
        if(n%p==0)
        {
            ret=ret/p*(p-1);
            while(n%p==0)n/=p;
        }
    }
    if(n>1)return ret/n*(n-1);else return ret;
}
main()
{
    init();
    ll n,k;scanf("%I64d%I64d",&n,&k);
    int m;
    //printf("%I64d\n",phi(n));
    while(k>0)
    {
        //printf("%I64d %I64d\n",n,k);
        if(n==1)break;
        n=phi(n);k-=2;
    }
    printf("%I64d\n",n%mod);
    return 0;
}

#include<iostream>
#define ll long long
using namespace std;
ll n,k;
ll Q(ll n)
{
    ll o=n;
    for(ll i=2;i*i<=n;i++)
    if(n%i==0)
    {
        o=o/i*(i-1);
        while(n%i==0) n/=i;
    }
    if(n>1) o=o/n*(n-1);
    return o;
}
int main()
{
	cin>>n>>k;
	k=(k+1)/2;
	while(n>1&&k) k--,n=Q(n);
	cout<<n;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <climits>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cassert>
#include <cmath>
using namespace std;

#define trace(x) {cerr << #x << "=" << x <<endl;}
#define trace2(x, y) {cerr << #x << "=" << x << " " << #y << "=" << y <<endl;}
template <typename T> ostream& operator<<(ostream& os, const vector<T> &p){os << "[ "; for (T x: p) os << x << " "; os << "]" << endl; return os;}
template <typename T> ostream& operator<<(ostream& os, const set<T> &p){os << "{ "; for (T x: p) os << x << " "; os << "}" << endl; return os;}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const map<Tk, Tv> &p){os << "{ "; for (pair<Tk, Tv> x: p) os << x << " "; os << "}" << endl; return os;}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const pair<Tk, Tv> &p){os << "{" << p.first << ',' << p.second << "}";return os;}

typedef long long ll;

const int MOD = 1000000000+7;
const int INF = 1000000000;
const int MAX = 100005;

/*int f1(int n) {
    if (n == 1) return 1;
    int count = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++) {
            if (__gcd(i, j) == 1) {
                if (i + j == n) {
                    count++;
                }
            }
        }
    }
    return count;
}

ll g1(vector<int> &f, int n) {
    ll count = 0;
    for (int i = 1; i <= n; i++) {
        if (n % i == 0) {
            count += f[i];
        }
    }
    return count;
}

int main() {
    int n = 100;
    vector<int> f(n+1);
    vector<ll> g(n+1);
    for (int i = 1; i <= n; i++) {
        f[i]=f1(i);
    }
    for (int i = 1; i <= n; i++) {
        g[i]=g1(f, i);
    }
    cout << f << endl;
    cout << g << endl;
    ll F[105][105];
    for (int k = 1; k <= n; k++) {
        for (int i = 1; i <= n; i++) {
            if (k == 1) {
                F[k][i] = f[i];
            } else if (k % 2 == 0){
                F[k][i] = g[F[k-1][i]];
            } else if (k % 2 == 1) {
                F[k][i] = f[F[k-1][i]];
            }
        }
    }
    for (int i = 1; i <= 20; i++) {
        for (int j = 0; j <= 25; j++) {
            cout << F[i][j] << " ";
        }
        cout << endl;
    }
}*/

vector<bool> isprime;
vector<int> primes;
void sieve(int n) {
	isprime.resize(n + 1);
	for (int i = 0; i <= n; i++) {
		isprime[i] = true;
	}
	isprime[1] = false; isprime[2] = true;
	for (int i = 2; i <= n; i++) {
		if (isprime[i]) {
			for (int j = 2*i;  j < n; j+=i) {
					isprime[j] = false;
			}
		}
	}
	for (int i = 2; i < n; i++) {
		if (isprime[i]) {
			primes.push_back(i);
		}
	}
	return;
}

/**
 * Description: Calculates n^m (Binary exponentiation)
 * Usage: power O(lg(M))
 * Source: https://github.com/dragonslayerx
 */

#define MOD 1000000007
long long power(long long n, long long m)
{
    if (m == 0) return 1;
    long long x = power(n, m / 2);
    if (!(m & 1)) return (x * x) % MOD;
    else return (((x * x) % MOD) * n) % MOD;
}

long long euler(long long n) {
    long long Answer = n;
    for (int i = 0; i < primes.size(); i++) {
        if (n % primes[i] == 0) {
            Answer *= primes[i]-1;
            Answer /= primes[i];
        }
        while (n % primes[i] == 0) n /= primes[i];
        if (n == 1) break;
    }
    if (n == 1) {
        return Answer;
    } else {
        return n-1;
    }
}

int main() {
    sieve(1000005);
    long long n, k;
    cin >> n >> k;
    if (k >= 20) {
        cout << 1 << endl;
    } else {
        long long Answer = n;
        for (int i = 1; i <= k; i += 2) {
            Answer = euler(Answer);
        }
        cout << Answer % MOD << endl;
    }
}

#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<time.h>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<deque>
#include<vector>
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define ll long long
using namespace std;
void in(int&a);void in(ll&a);
ll n,k;
ll f(ll n){
	ll ans=1,i;
	for(i=2;i*i<=n;i++)
	if(n%i==0){
		n/=i;ans*=i-1;
		while(n%i==0)n/=i,ans*=i;
	}
	return ans*max(1,n-1);
}
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("a.in","r",stdin);
	#endif
	in(n);in(k);
	k=k>>1;
	while(n!=1&&k--)
		n=f(n);
	printf("%lld",n);
	return 0;
}
void in(ll&a){register char c;register bool y=false;c=getchar();a=0;
while(c<'0'||c>'9'){if(c=='-'){c=getchar();y=true;break;}c=getchar();}
while(c>='0'&&c<='9'){a=(a<<3)+(a<<1)+c-'0';c=0;c=getchar();}if(y)a=-a;}
void in(int&a){register char c;register bool y=false;c=getchar();a=0;
while(c<'0'||c>'9'){if(c=='-'){c=getchar();y=true;break;}c=getchar();}
while(c>='0'&&c<='9'){a=(a<<3)+(a<<1)+c-'0';c=0;c=getchar();}if(y)a=-a;}

#include <bits/stdc++.h>
#define ll __int64

using namespace std;

const int MAX = 1e6;
const ll INF = 1e12;

int a[MAX], vis[MAX];

int c;

void init(){
	memset(vis, 0, sizeof(vis));

	for (int i = 2; i<=MAX; i+=1) if (vis[i] == 0){
		for (int j = i+i; j<=MAX; j+=i){
			vis[j] = 1;
		}
	}

	c = 0;

	for (int i = 2; i<=MAX; i++)if (vis[i]==0){
		a[c++] = i;
	}

}

struct Node {
	ll x, y;
}b[MAX];

ll oula(ll x){

	int cnt = 0, i = 0;
	while (x != 1 && i < c){
		if (x % a[i] == 0){
			b[cnt].x = a[i];
			b[cnt].y = 0;
			while (x % a[i] == 0){
				x = x / a[i];
				b[cnt].y++;
			}
			cnt++;
		}
		i++;
	}

	ll ans = 1;
	for (i = 0; i<cnt; i++){
		ans = ans * (b[i].x - 1)*((ll)(pow(b[i].x, b[i].y-1)+0.000001));

	}
	return ans;
}

int main(int argc, char const *argv[])
{
	/* code */
	ll a, b;
	init();
	while (scanf("%I64d%I64d", &a, &b) != EOF){
		b = (b+1) / 2;

		ll k = 1, ans = oula(a);
		while (k < b && ans > 1){
			ans = oula(ans);
			k++;
		}

		printf("%I64d\n", ans);

	}
	return 0;
}

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define inf 1013161010
#define ninf -1013161010
#define mod 1000000007
#define ll long long
#define lf long double
#define in(x) scanf("%d",&x);
#define sz(x) ((int)x.size())
#define lld l64d
#define rep(i,n) for(i=0;i<n;i++)
#define rrep(i,n) for(i=n-1;i>=0;i--)
#define rep1(i,a,b) for(i=a;i<=b;i++)
#define rrep1(i,a,b) for(i=a;i>=b;i--)
#define stlfor(i,t) for(auto i =t.begin();i!=t.end();i++)
#define fr freopen("x.txt","r",stdin)
#define all(x) x.begin(),x.end()
#define set0(x) memset(x,0,sizeof(x))
#define dbg cout<<"yo "<<endl;

#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define umii unordered_map<int,int>
#define vi vector<int>
#define pb push_back
#define ff first
#define ss second
#define mp make_pair

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> OST;

int toint(const string &s) { stringstream ss; ss << s; int x; ss >> x; return x; }
string tostring ( int number ){  stringstream ss; ss<< number; return ss.str();}

const lf pi = 2*acos(0);
const int nn = 2123456;

ll gcd(ll a,ll b){return (b==0)? a:gcd(b,a%b); }
ll pr[nn];

void pre()
{
    ll i,j;
    for(i=2;i<=1000000;i++)
    {
        if(pr[i]==0)
        {
            for(j=2*i;j<=1000000;j+=i)
                pr[j]=1;
        }
    }

}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll i,j,n,tt,m,k,tmp;

    cin>>n>>k;
    k=(k+1)/2;
    pre();
    ll x =n ;
    if(n==1)
    {
        cout<<1;
        return 0;
    }
    while(k--)
    {
        i=2;
        tmp=x;
        ll t=x;
        while(i<=sqrt(t))
        {
            if(x%i==0&&pr[i]==0)
            {
                tmp=(tmp*(i-1))/i;
                while(x%i==0)
                    x/=i;
               // cout<<i<<endl;
            }
            i++;
        }
        if(t==x)
            tmp=t-1;
        else if(x!=1)
            tmp=(tmp*(x-1))/x;

        x=tmp;
        if(tmp==1)
            break;
        //cout<<t<<" "<<tmp<<endl;
    }

    cout<<(tmp%mod)<<endl;
    return 0;
}

//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)

using namespace std;
typedef long long ll;
typedef pair<ll, ll> ii;
typedef pair<int, ii> iii;

ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}

vector<ll> factors, primes;
ll k;
int sieve[1000005], arr[1000005];
set<ll> pppp;

ll euler_totient(ll n){
	if(n <= 1e6 && arr[n] != 0)	return arr[n];
	if(pppp.find(n) != pppp.end())
		return arr[n] = n-1;
	ll ans = n;
	for(auto it : primes){
		if(1LL*it*it > n)	break;
		if(n % it != 0)	continue;
		while(n % it == 0)
			n /= it;
		ans /= it;
		ans *= it-1;
	}
	if(n != 1){
		ans /= n;
		ans *= n-1;
	}
	return arr[n] = ans;
}

ll calc(ll n){
	ll val = euler_totient(n);
cout<<val<<endl;
	for(ll i=3;i<=k;i+=2){
		val = euler_totient(val);
		if(val == 1)	break;
	}
// cout<<"calc "<<n<<" returns "<<val<<" "<<val%MOD<<endl;
	return val%MOD;
}

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    arr[1] = 1;
    for(int i=2;i<=1000*1000;i++){
    	if(!sieve[i]){
    		primes.pb(i);
    		pppp.insert(i);
    		for(int j=i;j<=1000*1000;j+=i)
    			sieve[j] = 1;
    	}
    }

// cout<<euler_totient(10)<<endl;

    for(int i=2;i<=1000*1000;i++){
    	arr[i] = euler_totient(i);
    }

    ll n;
    cin>>n>>k;

// for(int i=1;i<=10;i++)	cout<<euler_totient(i)<<" ";cout<<endl;
// for(int i=1;i<=10;i++)	cout<<arr[i]<<" ";cout<<endl;

 // n=MOD+2;

    cout<<calc(n);

//     for(ll i=2;i*i<=n;i++)
//     	if(n % i == 0){
//     		ll temp = 1;
//     		while(n % i == 0){
//     			n /= i;
//     			temp *= i;
//     		}
//     		factors.pb(temp);
//     	}

//     if(n > 1)
//     	factors.pb(n);

// // cout<<"factors: ";for(auto it : factors)	cout<<it<<" ";cout<<endl;

// // for(int i=1;i<=10;i++)	cout<<i<<":"<<euler_totient(i)<<" ";cout<<endl;

//     ll ans = 1;
//     for(auto it : factors)
//     	ans = (ans * calc(it)) % MOD;

//     cout<<ans;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

const int MOD=1e9+7;

//const int MOD=998244353;

vector<int> getPrimes(int stop){
    int sieveStop=ceil(sqrt(stop));
    vector<int> psj;
    for(int i=2; i<=sieveStop; i++){
        bool isP=true;
        for(int j=2; j<i && isP; j++){
            isP=i%j;
        }
        if(isP) psj.push_back(i);
    }

    vector<bool> primesb(stop+1,true);
    for(int j:psj){
        for(int i=2; i*j<=stop; i++){
            primesb[i*j]=false;
        }
    }
    vector<int> ans;
    for(int i=2; i<=stop; i++){
        if(primesb[i]) ans.push_back(i);
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    auto pr=getPrimes(1000000);
    long long n,k;
    cin>>n>>k;

    vector<long long> seq(1,n);
    while(seq.back()!=1){
        long long x=seq.back(), cv=1;
        for(auto p:pr){
            if(x%p) continue;
            if(p>x) break;
            long long pm=1;
            while(!(x%p)){
                x/=p;
                pm*=p;
            }
            cv*=(pm-pm/p);
        }
        if(x>1){
            cv*=(x-1);
        }
        seq.push_back(cv);
        seq.push_back(cv);
    }
    cout<<(k<=seq.size()?seq[k]:1);

    return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long      ull;
typedef long long               ll;
typedef pair < int, int >       pii;
typedef pair < ll, ll>          pll;

#define rt          exit(0)
#define F           first
#define S           second
#define sz(s)       s.size()
#define all(s)      s.begin(), s.end()
#define rs(s)       reverse(all(s))
#define sr(s)       sort(all(s))
#define alr(a, n)   a + 1, a + n + 1
#define ar(a, n)    sort(alr(a, n))
#define ra(a, n)    reverse(alr(a, n))
#define ch          cout << "Hello\n"
#define skip        continue
#define pb          push_back
#define bye         cout << "NO", rt 0;

const int N3 = 1e3 + 15;
const int N4 = 1e4 + 15;
const int N5 = 1e5 + 15;
const int N6 = 1e6 + 15;
const int N7 = 1e7 + 15;
const int N8 = 1e8 + 15;
const int N9 = 1e9 + 15;
const ll INF = 1e18;
const int mod = 1e9 + 7;
const double pi = acos(-1.0);

#define _15_days ""

#define int ll

int n, k, res;

int phi(int x)
{
    int res = x - 1;
    for (int i = 2; i <= sqrt(x); ++i)
    {
        if (x % i == 0)
        {
            while (x % i == 0)
                x /= i;
            res -= res / i;
        }
    }
    if (n > 1)
        res -= res / n;
    return res;
}

main()
{
    cin >> n >> k;
    res = n;
    k = (++k >> 1);
    while (k --)
    {
        res = phi(res);
        if (res == 1)
            break;
    }
    cout << res % mod;
}

#include <stdio.h>
#include<math.h>
#define Mod 1000000007
long long N,K;
long long eular(long long n)            //欧拉函数
{
    long long res=1;
    for(long long i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            n/=i;
            res=(res*(i-1))%Mod;
            while(n%i==0){
                n/=i;
                res=(res*i)%Mod;
            }
        }
    }
    if(n>1){
        res=(res*(n-1))%Mod;
    }
    return res;
}
/*
long long GCD(long long x,long long y){
    if(x<y){
        long long a=x;
        x=y;
        y=a;
    }
    while(x%y!=0){
        long long a=x%y;
        x=y;
        y=a;
    }
    return y;
}

long long f(long long n){
    if(n==1){
        return 1;
    }
    long long count=0;
    for(long long i=1;i<=n/2;i++){
        if(GCD(i,n-i)==1){
            count=count+2;
        }
    }
    if(n==2){
        count--;
    }
    return count%Mod;
    return eular(n)%Mod;
}
long long g(long long n){
    long long sum=0;
    if(n<=2){
        for(long long i=1;i<=n;i++){
            sum=(f(i)+sum)%Mod;
        }
    }
    else{
        sum=(f(1)+sum)%Mod;
        sum=(f(n)+sum)%Mod;
        for(long long i=2;i<=sqrt(n);i++){
            if(n%i==0){
                sum=(f(i)+sum)%Mod;
                if(i*i!=n){
                    sum=(f(n/i)+sum)%Mod;
                }
            }
        }
    }
    return sum%Mod;

    return n;
}
long long F(long long k,long long n){
    if(k<=2){
        return f(g(n))%Mod;
    }
    else if(k%2==0){
        return f(F(k-2,n))%Mod;
    }
    else{
        return f(F(k-1,n))%Mod;
    }
}
*/
int main(int argc, const char * argv[]) {
    scanf("%lld %lld",&N,&K);
    long long ans=N;
    long long k=(1+K)/2;
    while((k--)&&ans>1){
        ans=eular(ans)%Mod;
    }
    /*
    for(N=10000000;N<=10000005;N++){
        printf("N=%lld ",N);
        for(K=1;K<=10;K++){
            printf("K=%lld %lld ",K,F(K,N));
        }
        printf("\n");
    }
     */
    printf("%lld",ans);
        return 0;
}

#include <iostream>
using LL = long long;
LL n, k;
LL phi(LL n) {
	LL res = n;
	for (LL i = 2; i * i <= n; i++) if (n % i == 0) {
		res = res / i * (i - 1);
		do n /= i; while (n % i == 0);
	}
	if (n > 1) res = res / n * (n - 1);
	return res;
}
int main() {
	std::cin >> n >> k;
	for (k = k + 1 >> 1; k && n > 1; k--) n = phi(n);
	std::cout << n << std::endl;
	return 0;
}

#include <iostream>

using namespace std;

#define long long long

const long MOD = 1e9+7;

long n, k;

long Euler(long n)
{
    long tmp = n, re = n;
    for (long i = 2; i*i <= tmp; ++i)
        if (n % i == 0)
        {
            while (n % i == 0) n /= i;
            re -= re / i;
        }
    if (n > 1) re -= re / n;
    return re;
}

void Solve()
{
    if (k & 1) ++k;
    while (k > 0 && n > 2)
    {
        n = Euler(n);
        k -= 2;
    }
    cout << n % MOD;
}

int main()
{
    cin >> n >> k;
    Solve();
    return 0;
}

#pragma comment(linker, "/stack:252457298")
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
using namespace std;

const long long Mod = 1000000007LL;

long long n, k;

long long phi(long long x) {
	long long res = 1;
	for (long long i=2; i<=sqrt(x); i++) {
		int cnt = 0;
		while (x % i == 0) {cnt++; x /= i;}
		if (cnt == 0) continue;
		for (int z=0; z<cnt-1; z++) res *= i;
		res *= (i - 1);
	}
	if (x > 1) res *= (x - 1);
	return res;
}

void Input() {
	cin >> n >> k;
}

void Solve() {
	long long i = 1;
	while (n > 1 && i <= k) {
		n = phi(n);
		i += 2;
	}
	cout << n << endl;
}

int main(int argc, char* argv[]) {
	ios_base::sync_with_stdio(0); cin.tie(NULL);
	Input(); Solve(); return 0;
}

/**********************************************\
*  Ngoc-Mai Ngo, #Team4T's Deputy Leader     *
*  #Team4T Secondary Flagship - Destruction  *
\**********************************************/

#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll getphi(ll x)//单体 Osqrtn
{
	if(x<=1)return 0;
    int res=x;
    for(int i=2;i<=x/i;i++)
    {
        if(x%i==0)
        {
            res=res/i*(i-1);
            while(x%i==0)x/=i;
        }
    }
    if(x!=1)res=res/x*(x-1);
    return res;
}
map<ll,int>mp;
ll dfs(ll x)
{
	if(mp[x])return mp[x];
	return mp[x]=getphi(x);
}

int main()
{
	ll n,k;cin>>n>>k;
	k=(k+1)/2;
	for(int i=1;i<=k;i++)
	{
		n=dfs(n);
		if(n<=1)break;
	}
	cout<<n<<endl;
}

#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

long long g = 1e7;
vector < long long > primes;
const long long MOD = 1e9 + 7;

long long phi (long long n) {
	long long result = n;
	int i = 0;
	if (n > g) {
		primes.push_back(n);
	}

	for ( ; i < primes.size(); ++i) {
		long long d = primes[i];
		if (n % d == 0) {
			while (n % d == 0)
				n /= d;
			result -= result / d;
			if (n > g) {
				primes.push_back(n);
			}
		}
	}

	if (n > 1)
		result -= result / n;
	return result;
}

int main() {
	long long n, k, ans;
	cin >> n >> k;

	vector <char> prime (g + 1, true);
	prime[0] = prime[1] = false;
	for (int i = 2; i <= g; ++i)
		if (prime[i]) {
			primes.push_back(i);
			if (i * 1ll * i <= g)
				for (int j = i*i; j <= g; j+=i)
					prime[j] = false;
		}

	ans = phi(n);
	for (int i = 1; i < k; i++) {
		ans = phi(ans);
	}

	cout << ans % MOD;

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define int long long
int n, k;
bool isprime(int x){
	if(x == 1) return false;
	for(int i = 2; i * i <= x; i++){
		if(x % i == 0) return false;
	}
	return true;
}
int pw(int x, int y){
	int res = 1;
	while(y){
		if(y & 1) res = res * x;
		x = x * x;
		y /= 2;
	}
	return res;
}
int f(int x){
	if(x == 1) return 1;
	if(isprime(x)) return x - 1;
	int cur = 2;
	int res = 1;
	while(cur * cur <= x){
		int cnt = 0;
		while(x % cur == 0){
			x /= cur;
			cnt++;
		}
		if(cnt > 0){
			res *= f(cur) * pw(cur, cnt - 1);
		}
		cur++;
	}
	if(x > 1) res = res * f(x);
	return res;
}
main(){
	// freopen("in.in","r",sstdin);
	// for(int i = 1; i <= 1000; i++) if(isprime(i)) cout << i << " " << f(i) << "\n";
	cin >> n >> k;
	for(int i = 1; i <= k; i++){
		if(i % 2 == 1){
			n = f(n);
			if(n == 1){
				cout << 1 << "\n";
				return 0;
			}
		}
	}
	cout << n << "\n";
}

#include<iostream>
#include<vector>
using namespace std;
bool isPrime[1000005];
vector<int> primes;

void gen()
{
	for(int i=0; i<1000005; i++) isPrime[i]=1;
	for(int i=2; i<1000005; i++)
	{
		if(isPrime[i])
		{
			primes.push_back(i);
			for(int k=2; k*i<1000005; k++)
				isPrime[k*i]=0;
		}
	}
}

long long tot(long long n)
{
	long long ret=n;
	for(int i=0; i<primes.size() && primes[i]<=n; i++)
	{
		if(n%primes[i]==0)
		{
			ret-=ret/primes[i];
			while(n%primes[i]==0) n/=primes[i];
		}
	}
	if(n>1) ret-=ret/n;
	return ret;
}

int main()
{
	gen();
	long long n,k;
	cin>>n>>k;
	long long lol=(k+1)/2;
	long long ans=n;
	while(lol--)
	{
		ans=tot(ans);
		// cout<"lol"<<endl
		if(ans==1) break;
	}
	cout<<ans<<endl;
}

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<set>
#include<map>
#include<vector>
using namespace std;
#define LL long long
#define FILE "dealing"
#define up(i,j,n) for(LL i=j;i<=n;i++)
LL read(){
	LL x=0,f=1,ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
	return x*f;
}
const LL maxn=1600000,inf=1000000000;
bool cmin(LL& a,LL b){return a>b?a=b,true:false;}
bool cmax(LL& a,LL b){return a<b?a=b,true:false;}
LL c[maxn],r[maxn],cnt=0;
LL mul(LL a,LL b){LL ans=1;for(;b;a*=a,b>>=1)if(b&1)ans*=a;return ans;}
LL qiuoula(LL n){
	LL m=(LL)sqrt(n*1.0+1),sum=1;
	up(i,2,m){
		if(n==1)break;
		while(n%i==0){
			n/=i;
			if(c[cnt]==i)r[cnt]++;
			else c[++cnt]=i,r[cnt]=1;
		}
		if(c[cnt]==i)
			sum*=(mul(c[cnt],r[cnt])-mul(c[cnt],r[cnt]-1));
	}
	if(n>1)sum*=(n-1);
	return sum;

}
int main(){
	//freopen(FILE".in","r",stdin);
	//freopen(FILE".out","w",stdout);
	LL n=read(),m=(read()+1)/2;
	up(i,1,m){
		n=qiuoula(n);
		if(n==1)break;
	}
	cout<<n<<endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
vector<long long> primes;
bitset<100005> pr;

void sieve() {
    pr.set();
    pr[0]=0;
    pr[1]=0;
    for (long long i=2; i<100005; i++) {
        if (pr[i]) {
            for (long long j=i*i; j<100005; j+=i) pr[j]=false;
            primes.push_back(i);
        }
    }
}

int main() {
    sieve();
    long long int n,k;
    scanf("%I64d%I64d", &n, &k);
    for (int i=0; i<(k+1)/2; i++) {
        long long tmp = n;
        for (int j=0; j<primes.size(); j++) {
            if (primes[j]>tmp) break;
            if (tmp%primes[j]==0) {
                while (tmp%primes[j]==0) {
                    tmp/=primes[j];
                }
                n /= primes[j];
                n *= (primes[j]-1);
            }
        }
        if (n==1) break;
    }
    printf("%I64d\n", n);
}

#include <bits/stdc++.h>
#define ull unsigned long long int
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define fi first
#define se second
#define mod 1000000007
#define eps 0.000000000001
#define endl "\n"
#define c(x) cout<<x<<endl;
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

ll modexp(ll x,ll n, ll res){
    ll result=res;
    while(n>0){
 		if(n%2==1) result=(result * x)%mod;
        x=(x*x)%mod;
        n=n/2;
    }
    return result;
}

ll f(ll n) {
	if(n==1 || n==2){
		return(1);
	}
	ll p=0;
	bool flag=false;
	while(n%2==0){
		flag=true;
		p++;
		n=n/2;
	}
	ll result = n;
	for(ll i=2;i*i <= n;i++){
		if(n % i == 0) {
            while(n % i == 0) n /= i;
            result -= result / i;
        }
	}
	if (n > 1) result-=result / n;
	if(flag){
		result=modexp(2, p-1, result);
	}
	return result;
}

// ll f(ll n){ //very slow
// 	if(n==1 || n==2){
// 		return(1);
// 	}
// 	ll p=0, i;
// 	for(i=1;i<=(n-1)/2;i++){
// 		if(gcd(i, n-i)==1){
// 			p++;
// 		}
// 	}
// 	p=(2*p)%mod;
// 	return(p);
// }

int main(){SPEED;
ll n, k;
cin>>n>>k;
k=(k+1)/2;
while(k--){
	n=f(n);
	if(n==1) break;
}
cout<<n<<endl;
return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define _for(i,a,b) for(int i=(a);i<(b);++i)
#define ms(a) memset(a,0,sizeof(a))
#define ms_inf(a) memset(a,0x3f,sizeof(a))
#define ms_ninf(a) memset(a,0xcf,sizeof(a))
#define pb push_back
#define mp make_pair
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define lc (o<<1)
#define rc (o<<1|1)
#define mid ((l+r)>>1)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
mt19937_64 rng((ull)new char);
const double eps = 1e-7;
const int maxn = 2e6+10;
const ll INF = 1e18;
const int mod=1e9+7;
ll euler_phi(ll n)//calculate phi(n)
{
	int m=sqrt(n+0.5);
	ll ans=n;
	for(int i=2;i<=m;++i)
	{
		if(ans%i==0)
		{
			ans=ans/i*(i-1);
			while(n%i==0)n/=i;
		}
	}
	if(n>1)ans=ans/n*(n-1);
}
ll n,k;
int main()
{
	fast;
	cin>>n>>k;
	ll times=(k+1)>>1;
	while(times--)
	{
		n=euler_phi(n);
		if(n==1)break;
	}
	cout<<n%mod;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vl vector<ll>

#ifndef ONLINE_JUDGE
#  define dbg(x) (cerr << #x << " = " << (x) << endl)
#else
#  define dbg(x) 0
#endif

#define N 100001

ll phi(ll n)
{
    if(n==1)return 1;
    vl v;
    ll ans=n;
    for(ll i=2; i*i<=n; i++)
    {
        if(n%i==0)
        {
            v.emplace_back(i);
            while(n%i==0)
                n=n/i;
        }
    }
    if(n>1)
        v.emplace_back(n);
    for(auto it:v)
    {
        ans=ans/(it);
        ans=ans*(it-1);
    }
    return ans;
}

int main()
{
    ll n,k;cin>>n>>k;
    ll times=(k+1)/2;
    ll ans=n;
    while(times--){
        if(ans==1)
            break;
        ans=phi(ans);
    }
    cout<<ans;
}

#include <bits/stdc++.h>
using namespace std;

#define endl '\n'

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(15);
}
const long long MOD = 1e9 + 7 ;
void get_factors(long long n,vector<int>& pf){
    // cout << "tat " << n << endl ;
    if(n == 1) return ;
    for(long long i = 2 ; i*i <= n ; i++){
        if(n%i == 0){
            int cnt = 0 ;
            while(n%i == 0){
                cnt++ ;
                n /= i ;
            }
            pf.push_back(i) ;
        }
    }
    // cout << "@@ " << n << endl ;
    if(n != 1)
        pf.push_back(n) ;
}
vector<int> pf ;
long long phi(long long n){
    // cout << "pat " << n << endl ;
    if(n == 1) return 1 ;
    long long ret = n ;
    pf.clear() ;
    get_factors(n,pf) ;
    for(auto it:pf){
        // cout << "## " << it.first << endl ;
        ret = ret*(it - 1) ;
        ret /= (1ll*it) ;
    }
    return (ret) ;
}
int main(int argc,char* argv[]) {
    io() ;
    #ifndef ONLINE_JUDGE
        freopen("inp.txt", "r", stdin) ;
        // freopen("out.txt", "w", stdout);
    #endif
    long long n,k ;
    cin >> n >> k ;
    long long ans = n ;
    for(long long i = k ; (ans > 1) && (i > 0) ; i--){
        if(i&1){
            ans = phi(ans) ;
        }
    }
    cout << (ans%MOD) << endl ;
    return 0 ;
}

#include<bits/stdc++.h>
#define ll long long

ll long_mod(ll a, ll c, ll moder){
	const int orz = 1e9;
	ll b = a % orz, d = c % orz;
	a /= orz, c /= orz;
	ll ret = b * d % moder, ans = a * c % moder;
	for (int i = 0; i < 18; ++ i){
		ans = ans * 10 % moder;
	}
	ret = (ret + ans) % moder;
	ans = (a * d + b * c) % moder;
	for (int i = 0; i < 9; ++ i){
		ans = ans * 10 % moder;
	}
	return (ret + ans) % moder;
}

ll power_mod(ll a, ll index, ll moder){
	ll ans = 1;
	while (index){
		if (index & 1)
			ans = long_mod(ans, a, moder);
		a = long_mod(a, a, moder);
		index >>= 1;
	}
	return ans;
}

ll random(ll n){
	ll ret = 1ll * rand() * rand() * rand() * rand() + 1ll * rand() * rand() * rand() + 1ll * rand() * rand() + rand() + 1;
	return ret % n;
}

bool Miller_Rabin(ll n, ll t, ll u){
	ll a = random(n);
	if(!a || a == 1)
		return true;
	ll pre = power_mod(a, u, n);
	for (int i = 0; i < t; ++ i){
		ll now = long_mod(pre, pre, n);
		if (now == 1 && pre != 1 && pre != n - 1)
			return false;
		pre = now;
	}
	return pre == 1;
}

bool miller_rabin(ll n){
	if (n <= 30)
		return n == 2 || n == 3 || n == 5 || n == 7 || n == 11 || n == 13 || n == 17 || n == 19 || n == 23 || n == 29;
	if (!(n & 1))
		return false;
	const int S = 10;
	ll t = 0, x = n - 1;
	while (!(x & 1)){
		x /= 2;
		++ t;
	}
	for (int i = 0; i < S; ++ i){
		if (!Miller_Rabin(n, t, x))
			return false;
	}
	return true;
}

std::map <ll, int> fact;

ll pollard_rho(ll n){
	ll c = random(n - 1) + 1, x = random(n), y = x, i = 0, k = 1;
	while (true){
		++ i;
		x = long_mod(x, x, n);
		x = (x + c) % n;
		ll d = std::__gcd(std::abs(y - x), n);
		if (d != 1 && d != n){
			return d;
		}
		if (x == y){
			return n;
		}
		if (i == k){
			y = x;
			k <<= 1;
		}
	}
}

void get_fact(ll n){
	if (n == 1){
		return;
	}
	if (miller_rabin(n)){
		++ fact[n];
		return;
	}
	ll x = pollard_rho(n);
	get_fact(x);
	get_fact(n / x);
}

ll phi(ll n){
	ll ret = 1;
	fact.clear();
	get_fact(n);
	for (auto u = fact.begin(); u != fact.end(); ++ u){
		ret *= u -> first - 1;
		for (int i = 0; i < u -> second - 1; ++ i){
			ret *= u -> first;
		}
	}
	return ret;
}

int main(){
	srand((unsigned) time(NULL));
	ll n, k;
	scanf("%I64d%I64d", &n, &k);
	/*std::cout << long_mod(n, k, 2) << std::endl;
	ll ret = (__int128) n * k % 2;
	std::cout << ret << std::endl;*/
	for (ll i = 0; i < k + 1 >> 1; ++ i){
		n = phi(n);
		if (n == 1){
			return printf("%I64d\n", n), 0;
		}
		k >>= 1;
	}
	return printf("%I64d\n", n), 0;
}

#include <bits/stdc++.h>

using namespace std;

int phi(long long n) {
  long long ans = n;
  for (int i = 2; 1LL * i * i <= n; ++i)
    if (n % i == 0) {
      ans /= i;
      ans *= (i - 1);
      while (n % i == 0)
        n /= i;
    }
  if (n > 1) {
    ans /= n;
    ans *= (n - 1);
  }
  return ans;
}

int main() {
  //freopen("date.in", "r", stdin);
  //freopen("date.out", "w", stdout);

  long long n, k;
  scanf("%lld%lld", &n, &k);
  for (; k >= 1 && n > 1; --k)
    if (k % 2 == 1)
      n = phi(n);
  printf("%d\n", n);

  return 0;
}

#include <bits/stdc++.h>
typedef long long LL;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define root 1,cnum,1
#define Pr pair<int,int>
#define Prd pair<double,double>
#define Prl pair<LL,LL>
#define fi first
#define se second
#define Abs(x) (x>0?x:x*-1)
#define lowbit(x) (x&(-x))
#define mst(a,b) memset(a,b,sizeof(a))
using namespace std;
const int INF = 0x7FFFFFFF;
const LL LINF = 0x7FFFFFFFFFFFFF;
void guan() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); }

const LL mod = 998244353;
const int maxn = 1010101;

int main() {
    guan();
    int d, h, k, p;
    LL n, m;
    while(cin >> n >> k) {
        LL ans = n;
        for(int i = 1;i <= (k+1>>1);i++) {
            LL temp = ans;
            for(LL j = 2;j*j <= temp;j++) {
                if(temp%j==0) {
                    while(temp%j==0) temp /= j;
                    ans = ans/j*(j-1);
                }
            }
            if(temp>1) ans = ans/temp*(temp-1);
            if(ans==1) break;
            //cout << ans << endl;
        }
        cout << ans << endl;
    }
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#include<vector>
#include<set>
#define il inline
#define re register
using namespace std;
typedef long long ll;
ll n,k,ans;
il int phi(ll n){
	ll ans=n;
	for(int i=2;i<=sqrt(n);i++)
		if(n%i==0){
			ans=ans/i*(i-1);
			while(n%i==0) n/=i;
		}
	if(n>1) ans=ans/n*(n-1);
	return ans;
}
int main(){
	cin>>n>>k;ans=n;
	for(int i=1;i<=k;i++){
		if(i&1) ans=phi(ans);
		if(ans==1) break;
	}
	cout<<ans;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define FORE(i, a, b) for(int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define X first
#define Y second
#define ll long long
#define mp make_pair
#define pb push_back
#define endl '\n'

const int MAXN = 1e5 * 5;
const int base = 1e9 + 7;
const int N = 5000;

ll n,k;

ll power(ll x,int y)
{
    ll a = x;
    ll res = 1;
    while(y)
    {
        if (y&1) res *= a;
        a *= a;
        y >>= 1;
    }
    return res;
}

ll calc(int a,int b)
{
    if (b == 0) return 1;
    return 1ll*(a-1)*power(a , b-1);
}

ll phi(ll x)
{
    ll res = 1;
    //if(x == 7) return res;
    for(int i = 2; 1ll*i*i <= x; ++i)
    {
        int cnt = 0;
        while(x%i == 0)
        {
            x /= i;
            ++cnt;
        }
        res *= calc(i,cnt);
        //cout<<i<<' '<<cnt<<' '<<res<<' '<<calc(<<endl;
    }
    //cout<<x<<endl;
    if(x > 1) res *= calc(x,1);
    return res;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("776e.inp", "r", stdin);
    freopen("776e.out", "w", stdout);
    #endif
    cin>>n>>k;
    //cout<< phi(n) <<endl;
    while(k > 0 && n > 1)
    {
        n = phi(n);
        k -= 2;
    }
    n %= base;
    cout<<n<<endl;
    return 0;
}

#include <cstdio>
#include <iostream>
#include <algorithm>
#define p 1000000007

using namespace std;

typedef long long ll;

ll n,k,Ans;

inline ll phi(ll x){
  ll r=x;
  for(ll i=2;i*i<=x;i++)
    if(x%i==0){
      while(x%i==0) x/=i;
      r=r-r/i;
    }
  if(x>1) r=r-r/x;
  return r;
}

int main(){
  scanf("%I64d%I64d",&n,&k);
  Ans=phi(n)%p;
  for(int i=2;i<=k;i++){
    if(i&1) Ans=phi(Ans)%p;
    if(Ans==1) break;
  }
  printf("%I64d",Ans);
  return 0;
}

#include <bits/stdc++.h>

#define forin(i, start, end) for (auto (i) = (start); (i) != (end); ++(i))
#define forup(i, end) forin((i), 0, (end))

using ll = long long;

using namespace std;

#define roo 1000000
#define ro  1000

vector<int> primes;
ll N, K;
bool comp[roo];
ll phi(ll N)
{
    ll ans = 1;
    for (int p : primes) {
        ll pow = 1;
        if (N == 1) break;
        while (N % p == 0) {
            pow *= p;
            N /= p;
        }
        ans *= pow - pow / p;
    }
    ans *= N;
    return ans;
}
int main()
{
	ios::sync_with_stdio(false);
    cin >> N >> K;
    for (ll i = 2; i < roo; ++i) {
        if (comp[i] == false) {
            primes.push_back(i);
            for (ll j = i * i; j < roo; j += i) {
                comp[j] = true;
            }
        }
    }
    while (K > 0) {
        if (K % 2 == 0) {
            K /= 2;
        } else {
            N = phi(N);
            K--;
        }
    }
    cout << N << endl;
	return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <limits.h>
#include <vector>
#include <stdlib.h>
#include <algorithm>
#include <memory.h>
#include <string.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <functional>
#include <cassert>
#include <map>
#include <set>
#include <list>

using namespace std;
typedef long long lli;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef pair<lli, int> pii;
typedef vector<pii> vpii;
typedef long double ld;

const int INF = 0x3f3f3f3f;
const lli LINF = 0x3f3f3f3f3f3f3f3f;

//#define _LOCAL_DEBUG_
#ifdef _LOCAL_DEBUG_
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
#define eprintf(...)
#endif

#pragma region Modular Arithmetic
const int MOD = int(1e9) + 7;
inline int add(const int a, const int b, const int mod = MOD) { return (a + b >= mod) ? (a + b - mod) : (a + b); }
inline int sub(const int a, const int b, const int mod = MOD) { return (a - b < 0) ? (a - b + mod) : (a - b); }
inline void inc(int &a, const int b, const int mod = MOD) { a = add(a, b, mod); }
inline int negate(const int a, const int mod = MOD) { return mod - a; }
inline int mul(const int a, const int b, const int mod = MOD) { return (a * 1ll * b) % mod; }
int binPow(int b, int p, const int mod = MOD) {
	int r = 1;
	while (p) {
		if (p & 1)
			r = mul(r, b, mod);
		b = mul(b, b, mod);
		p >>= 1;
	}
	return r;
}
int inv(const int a, const int mod = MOD) {   // assuming that MOD is prime (Fermat's little theorem)
	int res = binPow(a, mod - 2, mod);
	return res;
}
inline int dvd(const int a, const int b, const int mod = MOD) { return mul(a, inv(b, mod), mod); } // b != 0
inline int convert(int x, const int mod = MOD) {
	int tx = x % mod + mod;
	return tx > mod ? tx - mod : tx;
};
struct mNum {
	int x;
	mNum(int _x) : x(convert(_x)) {}
	mNum(lli _x) : x(convert(_x)) {}
};
mNum operator +(mNum a, mNum b) { return mNum(add(a.x, b.x)); }
mNum operator -(mNum a, mNum b) { return mNum(sub(a.x, b.x)); }
mNum operator *(mNum a, mNum b) { return mNum(mul(a.x, b.x)); }
mNum operator /(mNum a, mNum b) { return mNum(dvd(a.x, b.x)); }
mNum operator +(lli x, mNum b) { return mNum(add(convert(x), b.x)); }
mNum operator -(lli x, mNum b) { return mNum(sub(convert(x), b.x)); }
mNum operator *(lli x, mNum b) { return mNum(mul(convert(x), b.x)); }
mNum operator /(lli x, mNum b) { return mNum(dvd(convert(x), b.x)); }
mNum operator +(mNum a, lli x) { return mNum(add(a.x, convert(x))); }
mNum operator -(mNum a, lli x) { return mNum(sub(a.x, convert(x))); }
mNum operator *(mNum a, lli x) { return mNum(mul(a.x, convert(x))); }
mNum operator /(mNum a, lli x) { return mNum(dvd(a.x, convert(x))); }
#pragma endregion

#pragma region Prime Generator
const int MAX_PRIME = 1e6 + 100;
int pr[MAX_PRIME / 10] = { 0 };
int np = 0;

void generatePrimes() {
	pr[np++] = 2;
	for (int i = 3; i <= MAX_PRIME; i++) {
		bool isp = true;
		for (int j = 0; 1LL * pr[j] * pr[j] <= i; j++)
			if (i % pr[j] == 0)
				isp = false;
		if (isp)
			pr[np++] = i;
	}
}
#pragma endregion

lli n, k;

vpii factorize(lli n) {
	vpii res;
	for (int i = 0; 1ll * pr[i] * pr[i] <= n; i++) {
		if (n % pr[i] == 0) {
			int c = 0;
			while (n % pr[i] == 0) c++, n /= pr[i];
			res.push_back({ pr[i], c });
		}
	}
	if (n != 1) res.push_back({ n, 1 });
	return res;
}

lli f(lli n) {
	vpii fn = factorize(n);
	lli res = n;
	for (auto &p : fn) res -= res / p.first;
	return res;
}

lli F(lli k, lli n) {
	if (k > 50) return 1;
	if (k == 1) return f(n);
	if (k & 1) return f(F(k - 1, n));
	else return F(k - 1, n);
}

void clear() {
}

void solve() {
	lli res = F(k, n) % MOD;
	printf("%lld\n", res);
}

int main() {
	generatePrimes();
#ifdef _LOCAL_VAN
	freopen("in.txt", "r", stdin);
#endif
	while (scanf("%lld%lld", &n, &k) == 2) {
		clear();
		solve();
#ifndef _LOCAL_VAN
		return 0;
#endif
	}
	return 0;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <list>
#include <cassert>

using namespace std;

#define y1 roman_kaban
#define rank oryshych_konb
#define ull unsigned long long
const int mod = int(1e9) + 7;
//const long long infLL = 1e15;
//const int MX2 = 10100500; //  e7
const int MX = 100500; //       e5

map<long long, long long> g0;

long long f(long long n);

long long g(long long n){
    if(n == 0) return 0;
    long long &ans = g0[n];
    //cerr << n << " " << ans << endl;
    if(ans) return ans - 1;
    for(long long i = 2; i * i <= n; i++){
            if(n % i == 0){
                ans += f(n / i);
                if(i * i != n) ans += f(i);
            }
    }
    ans++;
    //cerr << n << " " << ans - 1 << endl;
    return ans - 1;
}

long long f(long long n){
    if(n == 0) return  0;
    return n - 1 - g(n);
}

int main()
{
    //cerr << g(7) << endl;
    ios_base::sync_with_stdio(false);
    long long n, k;
    cin >> n >> k;
    //n= 1e10; k = 100;
    k++;
    int step = 0;
    map<long long, int> m;
    while(k){
        //cerr << n << endl;
        step++;
        int &z = m[n];
        if(z != 0){k %= 2*(step - z);  break;}
        z = step;
            if(n)n = g(n) + f(n) + 1;
        //cerr << n << endl;
        if(k == 1) {cout << n % mod << endl; return 0;}
        n = f(n);
        k -= 2;
    }

    while(k){
        step++;
            if(n)n = g(n) + f(n) + 1;
        if(k == 1) {cout << n % mod << endl; return 0;}
        n = f(n);
        k -= 2;
    }

    cout << n % mod << endl; return 0;
    return 0;
}

#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
typedef long long ll;
const ll mod =1000000007;
long long Getphi(long long n) {
    long long phi = n;
    for (long long i = 2; i * i <= n; i ++) {
        if (n % i == 0) {
            phi /= i;
            phi *= i - 1;
            while (n % i == 0) n /= i;
        }
    }
    if (n != 1) phi /= n, phi *= n - 1;
    return phi;
}
int main()
{
	ll n,k;
	scanf("%lld%lld",&n,&k);
	if(n==1) printf("1\n");
	else
	{
		ll res = n;
		for(ll i=1;i<=k;i++){
			ll mid = res;
			if(i%2){
				res = Getphi(res)%mod;
				if(res==1) break;
			}

		}
		printf("%lld\n",res);
	}
	return 0;
}

/*
 Copyright (c) 2008 Florian Mayer

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
*/

#include <iostream>
#include <vector>
#include <string.h>

using namespace std;

vector<unsigned long> get_primes(unsigned long max){
    vector<unsigned long> primes;
    char *sieve;
    sieve = new char[max/8+1];
    // Fill sieve with 1
    memset(sieve, 0xFF, (max/8+1) * sizeof(char));
    for(unsigned long x = 2; x <= max; x++)
        if(sieve[x/8] & (0x01 << (x % 8))){
            primes.push_back(x);
            // Is prime. Mark multiplicates.
            for(unsigned long j = 2*x; j <= max; j += x)
                sieve[j/8] &= ~(0x01 << (j % 8));
        }
    delete[] sieve;
    return primes;
}

unsigned long F(unsigned long n, unsigned long k, vector<unsigned long> primes){
    if ( k > 50 || n == 1)
        return 1;

    unsigned long result = 1;

    vector<unsigned long>::iterator it;
    it = primes.begin();

     while (n>1){
        int t = *it;
        if (n % t == 0){
            result *= (t-1);
            n /= t;
            while (n % t == 0){
                n /= t;
                result *= t;
            }
        }
        it++;
     }

    if (k == 1)
        return result;
    else
        return F(result,k-1,primes);

}

int main(void){
    vector<unsigned long> primes;
    primes = get_primes(10000000);

    unsigned long n,k;
    cin >> n >> k;
    cout << F(n,(k+1)/2,primes) % 1000000007 << endl;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll>vis;
ll Mod =  1000000007;
ll ouler(ll n)
{
    if(n==0) return 0;

    ll t = (ll)sqrt(n*1.0) + 1;
    ll ans = n;
    ll tmp = n;
    if(vis[n])return vis[n];
    for(int i = 2; i < t; ++i)
    {
        if(n%i == 0)
        {
            while(n%i == 0) n/=i;
            ans = ans /n * (n-1);
        }
    }
    if(n!=1) ans = ans/n*(n-1);
    //cout <<ans <<endl;
    return vis[tmp] = ans;
}
ll f(ll n){return ouler(n);}
ll g(ll n)
{
    return n;
}

ll F(ll n,ll k)
{
    //cout << "debug1" <<endl;
    if(n == 0)return 0;
    if(k == 1) return f(g(n));
    if(k%2==0) return g(F(n,k-1));
    if(k%2)return f(F(n,k-1));
}

int main()
{
    ll n,k;
    cin >> n >> k;
    cout << F(n,k)%Mod <<endl;
}

#include<bits/stdc++.h>
using namespace std;
#define _for(i,a,b) for(int i=(a);i<(b);++i)
#define ms(a) memset(a,0,sizeof(a))
#define ms_inf(a) memset(a,0x3f,sizeof(a))
#define ms_ninf(a) memset(a,0xcf,sizeof(a))
#define pb push_back
#define mp make_pair
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define lc (o<<1)
#define rc (o<<1|1)
#define mid ((l+r)>>1)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
mt19937_64 rng((ull)new char);
const double eps = 1e-7;
const int maxn = 2e6+10;
const ll INF = 1e18;
const int mod=1e9+7;
ll euler_phi(ll n)//calculate phi(n)
{
	int m=sqrt(n+0.5);
	ll ans=n;
	for(int i=2;i<=m;++i)
	{
		if(ans%i==0)
		{
			ans=ans/i*(i-1);
			while(n%i==0)n/=i;
		}
	}
	if(n>1)ans=ans/n*(n-1);
	return ans;
}
ll n,k;
int main()
{
	fast;
	cin>>n>>k;
	ll times=(k+1)>>1;
	while(times--)
	{
		n=euler_phi(n);
		if(n==1)break;
	}
	cout<<n%mod;
}

#include"bits/stdc++.h"
using namespace std;

typedef long long LL;
LL n,k;

LL phi (LL n){
	LL res = 1;
	for (int i=2; 1ll*i*i<=n; i++){
		if (n%i==0){
			res = res * (i-1), n /= i;
			while (n % i == 0)
				res = res * i, n /= i;
		}
	}
	if (n > 1) res *= n-1;
	return res;
}
int main(){
	cin>>n>>k;
	while (k > 0 && n != 1){
		n = phi(n);
		k -= 2;
	}
	cout << n << endl;
	return 0;
}

#include <bits/stdc++.h>
#define FOR(i, n) for (int i=0; i<n; ++i)
#define RFOR(i, n) for (int i=n-1; i>=0; --i)
#define DFOR(V,B,E,A) for (int V=(A<0?B-1:B); (A>0?V<E:V>=E); V+=A)
#define OUTV(x)for(int j=0;j<x.size();++j)cout<<(j==0?"":" ")<<x[j];cout<<endl;
#define OUTM(x) for(int i=0; i<x.size(); ++i){OUTV(x[i])}
#define BLE cout<<"BLE"<<endl;
#define DEBUG(x) cerr << "DEBUG: " << #x << " = "<< x << '\n';
#define PB push_back
using namespace std;
typedef long long int LL; typedef vector<LL> VLL;
typedef vector<int> VI; typedef vector<VI> VVI;
typedef pair<int, int> PII; typedef vector<PII> VPII;
typedef vector<bool> VB; typedef vector<VB> VVB;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	LL n, k;
	cin >> n >> k;
	LL ans;
	while (k >= 1 and n > 1){
		LL p = 1;
		for (LL i = 2; i*i <= n; ++i){
			if (n%i == 0) p*=(i-1);
			while (n%i == 0) n/=i;
		}
		if (n > 1) p *= (n-1);
		k -= 2;
		n = p;
	}
	cout << n << endl;
}

#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

using namespace std;
using matrix = vector<vector<long long>>;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define all(x) (x).begin(), (x).end()
//#define int ll

ll phi(ll n) {
    ll res = n;
    for (ll i = 2; i * i <= n; ++i) {
        if (n % i == 0) {
            while (n % i == 0) {
                n /= i;
            }
            res -= res / i;
        }
    }
    if (n > 1) {
        res -= res / n;
    }
    return res;
}

signed main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.setf(ios::fixed);
    //cout.precision(20);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll n, k;
    cin >> n >> k;
    k = (k + 1) / 2;
    while (k--) {
        n = phi(n);
        if (n == 1) {
            break;
        }
    }
    cout << n;
}

#include<iostream>
#include<vector>
using namespace std;
bool isPrime[1000005];
vector<int> primes;

void gen()
{
	for(int i=0; i<1000005; i++) isPrime[i]=1;
	for(int i=2; i<1000005; i++)
	{
		if(isPrime[i])
		{
			primes.push_back(i);
			for(int k=2; k*i<1000005; k++)
				isPrime[k*i]=0;
		}
	}
}

long long tot(long long n)
{
	long long ret=n;
	for(int i=0; i<primes.size() && primes[i]<=n; i++)
	{
		if(n%primes[i]==0)
		{
			ret-=ret/primes[i];
			while(n%primes[i]==0) n/=primes[i];
		}
	}
	if(n>1) ret-=ret/n;
	return ret;
}

int main()
{
	gen();
	long long n,k;
	cin>>n>>k;
	long long lol=(k+1)/2;
	long long ans=n;
	while(lol--)
	{
		ans=tot(n);
		// cout<<"lol"<<endl
		if(ans==1) break;
	}
	cout<<ans<<endl;
}

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
ll phi(ll n){
	ll i,rea=n;
	for(i=2;i*i<=n;i++){
		if(n%i==0){
			rea-=rea/i;
			while(n%i==0)n/=i;
		}
	}
	if(n>1)rea-=rea/n;
	return rea;
}
int main()
{
	ll n,k;
	cin>>n>>k;
	k=(k+1)/2;
	while(k--){
		n=phi(n);
		if(n==1)break;
	}
	cout<<n<<endl;
	return 0;
}

#include <iostream>
using namespace std;

const int MOD=1e9+7;
bool B[10000005];
int P[10000005];
int r;

void criba()
{
 for(int i=2;i<=10000000;i++)
  if(!B[i])
  {
   P[++r]=i;
   if(1ll*i*i<=10000000ll)
    for(int j=i*i;j<=10000000;j+=i)
     B[j]=1;
  }
}

int phi(int a)
{
 int b=a;
 for(int i=1;P[i]*P[i]<=a;i++)
  if(a%P[i]==0)
  {
   b=b/P[i]*(P[i]-1);
   do
    a/=P[i];
   while(a%P[i]==0);
  }
 if(a>1)
  b=b/a*(a-1);

 return b;
}

int main()
{
 long long N,K;
 cin >> N >> K;

 criba();

 long long sol=0;
 for(long long k=1;k<=K;k++)
 {
  if(k==1)sol=phi(N);
  else
   if(k%2==1)
    sol=phi(sol);
  if(sol==1)
   break;
 }
 cout << sol % MOD << '\n';

    return 0;
}

#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define ff first
#define ss second
using namespace std;
const int N=200005;
const long long M=1e9+7;
typedef long long ll;
typedef long double lb;
inline void read(int &x){x=0; char ch=getchar();while(ch<'0') ch=getchar();while(ch>='0'){x=x*10+ch-48; ch=getchar();}}
//------------------------------------------head---------------------------------------------------//
inline ll phi(ll n)
{
	if(n==1) return 1;
    ll T=n,TT=n;
    for(ll i=2;i*i<=TT;i++) if(n%i==0)
    {
        T=T/i*(i-1);
        while(n%i==0) n/=i;
    }
	if(n>1) T=T/n*(n-1);
    return T;
}
int main()
{
	ll n,k;scanf("%I64d%I64d",&n,&k); k=k/2ll;
	if(k==1) {printf("%I64d\n",phi(n)%M);return 0;}n=phi(n);
	while(1)
	{
		n=phi(n); k--; if(!k) break;
		if(n==1) break;
	}
	printf("%I64d\n",n%M);
	return 0;
}

#include <bits/stdc++.h>
#include <stdio.h>
#include <cstdio>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>*/

#define pb push_back
#define mp make_pair
#define sz(s) ((int)(s.size()))
#define all(s) s.begin(),s.end()
#define rep(i,a,n) for(int i=a;i<=n;++i)
#define per(i,n,a) for(int i=n;i>=a;--i)
#define onlycin ios_base::sync_with_stdio(false); cin.tie(0)
using namespace std;
// using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
/*typedef tree<
pair < int, int >,
null_type,
less< pair < int, int > >,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;*/
// find_by_order() order_of_key()
const int MAXN = (int)5e5+228;
const char nxtl = '\n';
const int mod = (int)1e9+7;
const double eps = (double)1e-7;
#define int ll
template<typename T> inline bool updmin(T &a, const T &b) {return a > b ? a = b, 1 : 0;}
template<typename T> inline bool updmax(T &a, const T &b) {return a < b ? a = b, 1 : 0;}

// int f[MAXN], g[MAXN];
int f(int n) {
	if(n == 1) return 1;
	int result = n;
	for (int i=2; i*i<=n; ++i)
		if (n % i == 0) {
			while (n % i == 0)
				n /= i;
			result -= result / i;
		}
	if (n > 1)
		result -= result / n;
	return result;
}
int g(int n) {
	int result = 0;
	for(int i = 1; i*i <= n; ++i) {
		if(n % i == 0) {
			result += f(i);
			if(n/i != i) result += f(n/i);
		}
	}
	return result;
}
int rec(int i, int k, int deep = 0) {
	if(k == 1) return f(g(i));
	int x = rec(i,k-1,deep+1);
	if(x == 1) return x;
	else if(k % 2 == 0) return g(x);
	else return f(x);
}

main() {
	#ifdef accepted
		freopen(".in", "r", stdin);
		freopen(".out", "w", stdout);
	#endif
	onlycin;
	/*g[1] = 1;
	rep(i,2,55) {
		rep(j,1,i) if(i % j == 0) g[i] += f(j);
	}
	rep(i,45,55) {
		rep(k,5,10) cout << rec(i,k) << ' ';
		cout << nxtl;
	}*/
	int n, k; cin >> n >> k;
	k = min(k,1000000ll);
	cout << rec(n,k) << nxtl;
	return 0;
}

#include  <bits/stdc++.h>
using namespace std;

const int M = 1000000007;
long long phi(long long n){

	long long r = n;

	for(long long i = 2; i*i <= n; ++i)
		if(n%i == 0){
			while(n%i == 0) n /= i;
			r -= r/i;
		}

	if(n > 1) r -= r/n;

	return r;
}

long long n, k;

int main(){

	cin >> n >> k;

	k = (k+2)/2;

	long long r = phi(n);
	long long a;
	while(k > 1 and r != 1){
		a = phi(n);
		if(a == r) break;
	}

	printf("%I64d\n", r%M);

	return 0;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
const ll MD=1e9+7;

ll power(ll x,ll y,ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

ll phi(ll n)
{
    double result = n;
    for (ll p = 2; p * p <= n; ++p)
    {
        if (n % p == 0)
        {
            while (n % p == 0)
                n /= p;
            result *= (1.0 - (1.0 / (double)p));
        }
    }
    if (n>1)
        result *= (1.0 - (1.0 / (double)n));

    return ((ll)result)%MD;
}

int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m;

	// cout<<phi(12)<<endl;
	cin >> n >> k;
	x=n;
	t=k/2;
	if(k%2)
		t++;
	ll prev=-1;
	for(i=1;i<=t;i++)
	{
		y=phi(x);
		// cout<<y<<endl;
		if(x==y)
			break;
		x=y;
	}
	ll ans=1;
	// ll ans=power(2,k/2+1,MD);
	ans=(ans*x)%MD;
	cout<<x<<endl;
}

#include <algorithm>
#include <cstdio>
#include <vector>

using namespace std;

constexpr static int MOD = 1e9 + 7;
constexpr static int MAXP = 1e6 + 5;

bool composite[MAXP];
vector <int> primes;
int phi[MAXP];

vector <pair <int64_t, int64_t>> factor(int64_t n) {
    vector <pair <int64_t, int64_t>> f;
    for (int p : primes) {
        if (1LL * p * p > n)
            break;
        int e = 0;
        while (n % p == 0)
            n /= p, e++;
        if (e > 0)
            f.push_back({p, e});
    }
    if (n > 1)
        f.push_back({n, 1});
    return f;
}

int64_t calc_phi(int64_t n) {
    if (n < MAXP)
        return phi[n];
    int64_t r = 1;
    auto f = factor(n);
    for (auto pe : f) {
        r = r * (pe.first - 1) % MOD;
        for (int j = 1; j < pe.second; j++)
            r = r * pe.first % MOD;
    }
    return r;
}

int main() {
    int64_t n, k;
    scanf("%lld%lld", &n, &k);

    for (int i = 2; i < MAXP; i++) {
        if (composite[i])
            continue;
        primes.push_back(i);
        for (int j = 2 * i; j < MAXP; j += i)
            composite[j] = true;
    }
    /*
    for (int i = 0; i < 10; i++)
        printf("%d\n", primes[i]);
    */

    // f(p^e) = phi(p^e) = p^e - p^{e-1}
    // g(p^e) = sum_{i <= e} f(p^i) = p^e
    for (int i = 1; i < MAXP; i++)
        phi[i] = 1;
    for (int p : primes) {
        for (int i = p; i < MAXP; i += p)
            phi[i] *= (p - 1);
        int64_t ppow = p;
        while (ppow * p < MAXP) {
            ppow *= p;
            for (int i = ppow; i < MAXP; i += ppow)
                phi[i] *= p;
        }
    }
    /*
    for (int i = 10; i < 30; i++) {
        int sum = 0;
        for (int j = 1; j <= i; j++)
            if (i % j == 0)
                sum += phi[j];
        printf("%d %d\n", i, sum);
    }
    */
    int64_t cur = n;
    for (int64_t i = 1; i <= (k + 1) / 2; i++) {
        cur = calc_phi(cur);
        if (cur == 1)
            break;
        // printf("phi^%d: %d\n", i, cur);
    }

    printf("%lld\n", cur);
}

#include<bits/stdc++.h>

#define PB push_back
#define SZ(c) int((c).size())
#define ALL(c) (c).begin(), (c).end()
#define CONTAINS(c, x) ((c).find(x) != (c).end())
#define REP(i, n) for(int i=0; i<n; i++)
#define WAIT cout<<flush, system("PAUSE");
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MOD = 1000000007;

ll N, T;
map<ll, ll> dp;

ll f(ll x){
	if (CONTAINS(dp, x)) return dp[x];

	ll ret = 1;
	ll n = x;
	for(int d=2; d*d <= n; d++){
		ll base = 1;
		if (n%d==0){
			int c = 0;
			while(n%d==0){
				c++;
				n /= d;
				base *= d;
			}

			dp[d] = d-1;
			ret = (ret * (base/d)) % MOD;
		}
	}
	if (n > 1) dp[n] = n-1, ret = (ret*(n-1))%MOD;
	dp[x] = ret;

	return ret;
}
ll f2(ll x){
	ll ret = 0;
	for(ll I=1; I<x; I++) if (__gcd(I,x)==1) ret++;
	return ret;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	cin >> N >> T;
	while(N > 1 && T > 0){
		if (T%2==0){
			T--;
			continue;
		}
		T--;

		N = f(N);
	}
	cout << N << endl;
}

#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <set>
#include <map>
using namespace std;

#define F first
#define S second
#define P_B push_back
#define size(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define FR(i, a, b) for(int i = a; i < b; i++)
#define ROF(i, a, b) for(int i = a; i >= b; i--)
#define debug(x) cerr<< #x << ": " << x << endl;
#define fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int mod = 1000 * 1000 * 1000 + 7;
const int MAXN = 1000 * 2000 + 100;
vector <ll> prm;
bool mark[MAXN];

ll pw(ll a, ll r)
{
	if(r == 0)
		return 1;
	return ((pw((a * a), r / 2)) * ((r % 2)? a: 1)) ;
}

ll getf(ll n)
{
	if(n == 1)
		return 1;
	ll t = 1, i = 0;
	bool chck = true;
	while(n > 1 && i < size(prm))
	{
		ll s = 0;
		while(n % prm[i] == 0)
		{
			chck = false;
			n /= prm[i];
			s++;
		}

		if(s != 0)
			t = (t * ((pw(prm[i], s - 1) * (prm[i] - 1))));
		i++;
	}
	if(chck)
		return (n - 1);
	return t;
}

ll F(ll n, ll k)
{
	if(k == 1)
		return getf(n);
	ll x = F(n, k - 2);
//	cerr<< n << " " << k << " " << x << endl;
	return getf(x);
}

int main()
{
	fast;
	FR(i, 2, MAXN)
		if(!mark[i])
		{
			prm.P_B(i);
			for(int j = i + i; j < MAXN; j += i)
				mark[j] = true;
		}
	ll n, k;
	cin>> n >> k;

	if(k % 2 == 0)
		k--;
	if(k > 200)
		cout<< 1 << endl;
	else
		cout<< (F(n, k) % mod) << endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
inline long long phi(long long x)
{
	long long tmp=x,out=x;
	for(long long i=2;i*i<=x;i++)
	{
		if((tmp%i==0))
		{
			out=out/i*(i-1);
			while(tmp%i==0)tmp/=i;
		}
	}
	if(tmp!=1)out=out/tmp*(tmp-1);
	return out;
}
inline long long f(long long k,long long n)
{
	while(!(k&1))k>>=1;
	if(k==1)return phi(n);
	return phi(f(k-1,n));
}
long long n,k;
int main()
{
	scanf("%I64d%I64d",&n,&k);
	printf("%I64d\n",f(k,n)%1000000007);
	return 0;
}

#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <functional>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = (((1<<30)-1)<<1)+1;
const int nINF = 1<<31;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, int> pci;

/////////////////////////////////////////////////////////////////////
vector<ll> primes;
const ll M = 1000000007;

// Finds constants {u, v} s.t. a*u+b*v = g for g = gcd(a, b)
// Call with egcd(a, b)
pll egcd(ll a, ll b, pll x = {1, 0}, pll y = {0, 1}) {
	return (b == 0) ? x : egcd(b, a % b, y, {x.first - a/b * y.first, x.second - a/b * y.second});
}

// Finds x s.t. (a*x) % n == 1
// Assumes a is not zero divisor (i.e. gcd(a, n) == 1)
ll modInv(ll a, ll n) {
	return ((egcd(a, n).first % n) + n) % n;
}

ll phi(ll n) {
	ll tn = n;
	vector<ll> cons;
	for(ll p : primes) {
		if(p*p > tn) {
			if(tn != 1) cons.push_back(tn);
			break;
		}
		if(tn % p == 0) {
			cons.push_back(p);
			while(tn % p == 0) {
				tn /= p;
			}
		}
	}
	for(ll p : cons) {
		n = (n*(p-1)) % M;
		n = (n*modInv(p, M)) % M;
	}
	return n;
}

int main() {
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(7);
    vector<bool> p(1e6+1, 1);
    for(int i = 2; i*i <= 1e6; ++i) {
    	if(p[i]) {
    		for(int j= 2*i; j <= 1e6; j += i) {
    			p[j] = 0;
    		}
    	}
    }
    for(int i = 2; i <= 1e6; ++i) {
    	if(p[i]) primes.push_back(i);
    }
    ll n, k;
    cin >> n >> k;
    ll tk = 1;
    while(k > tk && n != 1) {
    	n = phi(n);
    	tk += 2;
    }
    cout << n << endl;

    return 0;
}

#include <bits/stdc++.h>

#define LL long long

using namespace std;

const int N=2011110;
bool pr[N];
LL n,k;

void eratos(){
    memset(pr,true,sizeof(pr));
    pr[1]=false;
    for(int i=2;i<sqrt(N);i++)
        if(pr[i])
        for(int j=i*i;j<N;j+=i)
            pr[j]=false;
}

LL f(LL n){
    LL ans=1;
    for(LL i=1;i<=sqrt(n);i++)
    if(pr[i]){
        LL cur=1,sub=0;
        while(n%i==0){
            n/=i;
            cur*=i;sub++;
        }
        ans*=(cur-sub);
    }
    if(n>1) ans*=(n-1);
    return ans;
}

LL g(LL n){
    return n;
}

int main(){
    #ifndef ONLINE_JUDGE
        freopen("776e.inp","r",stdin);
        freopen("776e.out","w",stdout);
    #endif // ONLINE_JUDGE
    eratos();
    cin>>n>>k;
    while(n>1&&k>0){
        n=f(n);
        k-=2;
    }
    cout<<n<<endl;
}