#include <bits/stdc++.h>
using namespace std;
inline long long ma(long long a, long long b) { return ((a - b > 0) ? a : b); }
inline long long mi(long long a, long long b) { return ((a - b > 0) ? b : a); }
int mark[(50000 >> 5) + 1];
int P[50000], Pt = 0;
inline long long bp(long long a, long long n) {
  if (n == 0) return 1;
  if (n % 2 == 1) return a * bp(a, n - 1);
  long long x = bp(a, n / 2);
  return x * x;
}
inline void sieve() {
  register int i, j, k;
  (mark[1 >> 5] |= 1 << (1 & 31));
  int n = 46340;
  for (i = 2; i <= n; i++) {
    if (!(mark[i >> 5] >> (i & 31) & 1)) {
      for (k = n / i, j = i * k; k >= i; k--, j -= i)
        (mark[j >> 5] |= 1 << (j & 31));
      P[Pt++] = i;
    }
  }
}
inline long long mul(unsigned long long a, unsigned long long b,
                     unsigned long long mod) {
  long long ret = 0;
  for (a %= mod, b %= mod; b != 0;
       b >>= 1, a <<= 1, a = a >= mod ? a - mod : a) {
    if (b & 1) {
      ret += a;
      if (ret >= mod) ret -= mod;
    }
  }
  return ret;
}
inline void exgcd(long long x, long long y, long long &g, long long &a,
                  long long &b) {
  if (y == 0)
    g = x, a = 1, b = 0;
  else
    exgcd(y, x % y, g, b, a), b -= (x / y) * a;
}
inline long long llgcd(long long x, long long y) {
  if (x < 0) x = -x;
  if (y < 0) y = -y;
  if (!x || !y) return x + y;
  long long t;
  while (x % y) t = x, x = y, y = t % y;
  return y;
}
inline long long inverse(long long x, long long p) {
  long long g, b, r;
  exgcd(x, p, g, r, b);
  if (g < 0) r = -r;
  return (r % p + p) % p;
}
inline long long mpow(long long x, long long y, long long mod) {
  long long ret = 1;
  while (y) {
    if (y & 1) ret = (ret * x) % mod;
    y >>= 1, x = (x * x) % mod;
  }
  return ret % mod;
}
inline long long mpow2(long long x, long long y, long long mod) {
  long long ret = 1;
  while (y) {
    if (y & 1) ret = mul(ret, x, mod);
    y >>= 1, x = mul(x, x, mod);
  }
  return ret % mod;
}
inline int isPrime(long long p) {
  if (p < 2 || !(p & 1)) return 0;
  if (p == 2) return 1;
  long long q = p - 1, a, t;
  int k = 0, b = 0;
  while (!(q & 1)) q >>= 1, k++;
  for (long long(it) = (0); (it) < (2); (it)++) {
    a = rand() % (p - 4) + 2;
    t = mpow2(a, q, p);
    b = (t == 1) || (t == p - 1);
    for (int i = 1; i < k && !b; i++) {
      t = mul(t, t, p);
      if (t == p - 1) b = 1;
    }
    if (b == 0) return 0;
  }
  return 1;
}
inline long long pollard_rho(long long n, long long c) {
  long long x = 2, y = 2, i = 1, k = 2, d;
  while (true) {
    x = (mul(x, x, n) + c);
    if (x >= n) x -= n;
    d = llgcd(x - y, n);
    if (d > 1) return d;
    if (++i == k) y = x, k <<= 1;
  }
  return n;
}
inline void factorize(int n, vector<long long> &f) {
  for (int i = 0; i < Pt && P[i] * P[i] <= n; i++) {
    if (n % P[i] == 0) {
      while (n % P[i] == 0) f.push_back(P[i]), n /= P[i];
    }
  }
  if (n != 1) f.push_back(n);
}
inline void llfactorize(long long n, vector<long long> &f) {
  if (n == 1) return;
  if (n < 1e+9) {
    factorize(n, f);
    return;
  }
  if (isPrime(n)) {
    f.push_back(n);
    return;
  }
  long long d = n;
  for (int i = 2; d == n; i++) d = pollard_rho(n, i);
  llfactorize(d, f);
  llfactorize(n / d, f);
}
inline long long go(long long n) {
  if (n % 2 == 0) return n / 2;
  return n / 2 + 1;
}
inline long long make(long long n) {
  vector<long long> f;
  map<long long, int> r;
  llfactorize(n, f);
  for (auto &x : f) r[x]++;
  long long last = 1;
  for (auto it = r.begin(); it != r.end(); it++) {
    last = last * bp(it->first, it->second - 1) * (it->first - 1);
  }
  return last;
}
inline long long solve(long long n) {
  if (n == 1) return 1;
  if (n == 2) return 1;
  if (n == 3) return 2;
  return make(n);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  sieve();
  long long n, k;
  cin >> n >> k;
  long long ans = n;
  k = go(k);
  for (long long i = 0; i < k; i++) {
    ans = solve(ans);
    if (ans == 1) break;
  }
  cout << ans % 1000000007 << endl;
  return 0;
}
