#include <bits/stdc++.h>
using namespace std;
const int P = 1000000007;
int ch;
long long n, m;
void R(long long &x) {
  x = 0;
  ch = getchar();
  while (ch < '0' || '9' < ch) ch = getchar();
  while ('0' <= ch && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
}
void W(long long x) {
  if (x >= 10) W(x / 10);
  putchar(x % 10 + '0');
}
long long phi(long long n) {
  long long i, ans = 1;
  for (i = 2; i * i <= n; i++)
    if (n % i == 0) {
      n /= i;
      ans *= i - 1;
      while (n % i == 0) n /= i, ans *= i;
    }
  if (n > 1) ans *= n - 1;
  return ans;
}
int main() {
  R(n);
  R(m);
  m = (m + 1) / 2;
  while (m--) {
    n = phi(n);
    if (n == 1) break;
  }
  W(n % P);
  puts("");
}
