#include <bits/stdc++.h>
using namespace std;
inline long long rd() {
  long long x = 0;
  int ch = getchar(), f = 1;
  while (!isdigit(ch) && (ch != '-') && (ch != EOF)) ch = getchar();
  if (ch == '-') {
    f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline void rt(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10)
    rt(x / 10), putchar(x % 10 + '0');
  else
    putchar(x + '0');
}
const int p = 1000000007;
long long n, k;
long long phi(long long n) {
  long long ret = n;
  for (long long i = 2; i * i <= n; i++)
    if (n % i == 0) {
      ret = ret / i * (i - 1);
      while (n % i == 0) n /= i;
    }
  if (n != 1) ret = ret / n * (n - 1);
  return ret;
}
int main() {
  n = rd(), k = (rd() + 1) / 2;
  while (n != 1 && k) n = phi(n), k--;
  rt(n % p), putchar('\n');
}
