#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
const long long mod = 1000000007;
bool chk[N];
vector<int> primes;
void pre() {
  memset(chk, false, sizeof(chk));
  for (int i = 2; i < N; i++) {
    if (!chk[i]) {
      primes.push_back(i);
      for (int j = 2 * i; j < N; j += i) {
        chk[j] = true;
      }
    }
  }
}
inline long long totient(long long n) {
  long long ret = 1;
  for (auto x : primes) {
    if (x * x > n) break;
    if (n % x) continue;
    while (n % x == 0) {
      ret *= x;
      n /= x;
    }
    ret /= x;
    ret *= (x - 1);
  }
  if (n > 1) ret *= (n - 1);
  return ret;
}
long long compute(long long n, long long k) {
  if (k == 1) return totient(n);
  if (n == 1) return 1;
  if (k % 2 == 0) return compute(n, k - 1);
  return compute(totient(n), k - 2);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << setprecision(32);
  pre();
  long long n, k;
  cin >> n >> k;
  cout << compute(n, k) % mod << endl;
  return 0;
}
