#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
namespace {};
vector<int> primes;
const int N = 1e6 + 1;
bool isnpr[N];
void sieve() {
  primes.reserve(78500);
  for (int i = 2; i < N; i++) {
    if (!isnpr[i]) {
      primes.push_back(i);
      for (int j = 2 * i; j < N; j += i) isnpr[j] = true;
    }
  }
}
long long fg(long long n, int isf) {
  if (!isf) return n;
  if (n == 1) return 1;
  long long ret = 1;
  for (int p : primes) {
    if (n == 1) break;
    if (n % p != 0) continue;
    n /= p;
    long long mul = 1;
    while (n % p == 0) {
      n /= p;
      mul *= p;
    }
    if (!isf)
      ret *= (mul * p) - 1;
    else
      ret *= mul * (p - 1);
  }
  if (n > 1) ret *= (n - 1);
  if (!isf) ret++;
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  sieve();
  long long n, k;
  cin >> n >> k;
  for (long long i = 0; i < k + 1; i++) {
    if (n == 1) break;
    n = fg(n, i & 1);
  }
  n %= MOD;
  cout << n << '\n';
  return 0;
}
