#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-7;
const int N = 200010;
const int M = 200010;
const int P = 1000000007;
const int Inf = 1000000007;
const int Fni = -1000000007;
inline int qr() {
  int r = 0, f = 1;
  char c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c <= '9' && c >= '0') {
    r = (r << 1) + (r << 3) + c - '0', c = getchar();
  }
  return r * f;
}
template <typename T>
void debug(T x, char c = '\n') {
  cerr << x << c;
}
template <typename T>
void debug(T *const tp, int minn, int maxn, char v = ' ', char c = '\n') {
  for (int i = minn; i <= maxn; ++i) debug(tp[i], v);
  cerr << c;
}
template <typename T>
inline void chkmin(T &x, T y) {
  x = x > y ? y : x;
}
template <typename T>
inline void chkmax(T &x, T y) {
  x = x < y ? y : x;
}
template <typename T>
inline void add(T &x, long long y, int mod = P) {
  x += y;
  x = x >= mod ? x - mod : x;
}
template <typename T>
inline void dec(T &x, long long y, int mod = P) {
  x -= y;
  x = x < 0 ? x + mod : x;
}
template <typename T>
inline T addn(T x, long long y, int mod = P) {
  x += y;
  return (x = x > mod ? x - mod : x);
}
template <typename T>
inline T decn(T x, long long y, int mod = P) {
  x -= y;
  return (x = x < 0 ? x + mod : x);
}
long long getphi(long long x) {
  long long ret = x, sr = sqrt(x) + 1;
  for (long long i = 2; i <= sr; ++i) {
    if (x % i == 0) {
      ret = ret / i * (i - 1);
      while (x % i == 0) x /= i;
    }
  }
  debug(x);
  if (x > 1) ret = ret / x * (x - 1);
  return ret;
}
long long expow(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y & 1) res = res * x % P;
    x = x * x % P;
    y >>= 1;
  }
  return res;
}
long long n, m, k;
long long res, ans;
int main() {
  cin >> n >> k, m = n;
  while (m > 1 && ans < k) {
    ans += 2, m = getphi(m);
  }
  cout << m % P << '\n';
}
