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