#include <bits/stdc++.h>
using namespace std;
long long fn(long long n) {
  long long ret = n;
  bool fg = 0;
  while (n % 2 == 0) n /= 2, fg = 1;
  if (fg == 1) ret /= 2;
  for (long long i = 3; i * i <= n; i += 2) {
    fg = 0;
    while (n % i == 0) n /= i, fg = 1;
    if (fg == 1) ret /= i, ret *= i - 1;
  }
  if (n > 2) ret /= n, ret *= n - 1;
  return ret;
}
int main() {
  long long n, k;
  scanf("%lld", &n), scanf("%lld", &k);
  k = (k + 1) / 2;
  long long ans = n;
  while (k--) {
    ans = fn(ans);
    if (ans == 1) break;
  }
  printf("%lld\n", ans % 1000000007);
  return 0;
}
