#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
long long f(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)
    return result -= result / n;
  else
    return result;
}
long long F(long long n, long long k) {
  if (k == 1) return f(n);
  if (f(n) == n) return n;
  return F(f(n), k - 1);
}
int main() {
  long long n, k;
  cin >> n >> k;
  k = (k + 1) / 2;
  cout << F(n, k) % mod;
}
