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