#include <bits/stdc++.h>
using namespace std;
int sgn(double a) { return a < -(1e-6) ? -1 : a < (1e-6) ? 0 : 1; }
const long long mod = 1000000007;
const int maxn = 100010;
long long euler(long long n) {
  long long res = n, a = n;
  for (long long i = 2; i * i <= a; i++) {
    if (a % i == 0) {
      res = res / i * (i - 1);
      while (a % i == 0) a /= i;
    }
  }
  if (a > 1) res = res / a * (a - 1);
  return res;
}
void solve() {
  long long n, k;
  scanf("%lld%lld", &n, &k);
  if (k & 1) k++;
  long long t = k >> 1;
  long long i = n;
  for (long long c = t; i > 1 && c > 0; i = euler(i), c--)
    ;
  printf("%lld\n", i % mod);
}
int main() {
  solve();
  return 0;
}
