#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long mul_mod(long long a, long long b, long long p) {
  long long ret = 0;
  for (; b; a = a * 2 % p, b >>= 1)
    if (b & 1) ret = (ret + a) % p;
  return ret;
}
long long pow_mod(long long a, long long b, long long p) {
  long long ret = 1;
  for (; b; a = mul_mod(a, a, p), b >>= 1)
    if (b & 1) ret = mul_mod(ret, a, p);
  return ret;
}
int test(long long n, long long a, long long p) {
  if (n == 2 || n == a) return 1;
  if (n % 2 == 0) return 0;
  while (p % 2 == 0) p >>= 1;
  long long t = pow_mod(a, p, n);
  while (p != n - 1 && t != 1 && t != n - 1) t = mul_mod(t, t, n), p <<= 1;
  return t == n - 1 || p % 2 == 1;
}
int miller_rabin(long long n) {
  if (n < 1) return 0;
  long long a[] = {2, 3, 61};
  for (int i = 0; i <= 2; ++i)
    if (!test(n, a[i], n - 1)) return 0;
  return 1;
}
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }
long long pollard_rho(long long n, long long c) {
  long long x, y, i, k, g;
  x = y = rand() % (n - 1) + 1;
  for (i = k = 2;; ++i) {
    x = (mul_mod(x, x, n) + c) % n;
    if ((g = gcd(y - x + n, n)) != 1) return g;
    if (x == y) return n;
    if (i == k) k <<= 1, y = x;
  }
}
long long n, k, sz, v[1010];
void fact(long long n, long long c) {
  if (n == 1) return;
  if (miller_rabin(n)) {
    v[++sz] = n;
    return;
  }
  long long p = n;
  while (p >= n) p = pollard_rho(p, c--);
  fact(p, c);
  fact(n / p, c);
}
int main() {
  cin >> n >> k;
  for (long long i = (k + 1) / 2; i >= 1 && n != 1; --i) {
    sz = 0;
    fact(n, 200);
    sort(v + 1, v + sz + 1);
    sz = unique(v + 1, v + sz + 1) - v - 1;
    long long phi = n;
    for (int i = 1; i <= sz; ++i) phi = phi / v[i] * (v[i] - 1);
    n = phi;
  }
  cout << n % mod;
}
