#include <bits/stdc++.h>
using namespace std;
long long phi(long long n) {
  long long ret = 1;
  long long cont = n;
  for (long long i = 2; i * i <= cont; i++) {
    long long mul = 1;
    while (n % i == 0) {
      mul *= i;
      n /= i;
    }
    ret *= (mul - mul / i);
  }
  if (n > 1) ret *= (n - 1);
  return ret;
}
int main() {
  long long n, k;
  cin >> n >> k;
  long long ans = 0;
  for (int i = 1; i <= k && ans != 1; i++) {
    if (i == 1)
      ans = phi(n);
    else if (i & 1)
      ans = phi(ans);
    else
      continue;
  }
  cout << ans % 1000000007 << endl;
}
