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