#include <bits/stdc++.h>
using namespace std;
long long cphi(long long x) {
  long long ans = x;
  long long k = 2;
  while (k * k <= x) {
    if (x % k == 0) {
      while (x % k == 0) {
        x /= k;
      }
      ans = ans / k * (k - 1);
    }
    k++;
  }
  if (x != 1) {
    ans = ans / x * (x - 1);
  }
  return ans;
}
int main() {
  long long n, k;
  cin >> n >> k;
  k = (k + 1) / 2;
  while (n != 1 && k) {
    n = cphi(n);
    k--;
  }
  printf("%I64d\n", (n % 1000000007ll));
}
