#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long int LINF = 0x3f3f3f3f3f3f3f3fll;
const long double pi = acos(-1);
const int MOD = 1e9 + 7;
long long int phi(long long int n) {
  long long int ret = 1;
  long long int cont = n;
  for (long long int i = 2; i * i <= cont; i++) {
    long long int 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 int n, k;
  cin >> n >> k;
  long long int resp = n;
  for (long long int i = 1; i <= (k + 1) / 2; i++) {
    resp = phi(resp);
    if (resp == 1) break;
  }
  cout << resp % MOD << endl;
  return 0;
}
