#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const unsigned gen_seed =
    std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937_64 gen(gen_seed);
const int LIMIT = 1000000;
std::vector<int> mindiv(LIMIT + 1, 0);
std::vector<long long> p;
std::vector<std::pair<long long, long long> > factor(long long n) {
  std::vector<std::pair<long long, long long> > d;
  if (n <= LIMIT) {
    while (n > 1) {
      long long pr = mindiv[n];
      n /= pr;
      d.push_back(make_pair(pr, 1ll));
      while (n % pr == 0) {
        d.back().second++;
        n /= pr;
      }
    }
    return d;
  }
  for (auto pr : p) {
    if (n % pr == 0) {
      n /= pr;
      d.push_back(make_pair(pr, 1ll));
      while (n % pr == 0) {
        d.back().second++;
        n /= pr;
      }
    }
  }
  if (n > 1) d.push_back(make_pair(n, 1));
  return d;
}
int main() {
  std::vector<bool> isp(LIMIT + 1, true);
  for (int i = 0; i < LIMIT + 1; i++) mindiv[i] = i;
  int upbound = (int)sqrt((double)LIMIT);
  for (int m = 2; m <= upbound; m++) {
    if (isp[m]) {
      p.push_back(m);
      for (int k = m * m; k <= LIMIT; k += m) {
        isp[k] = false;
        mindiv[k] = min(mindiv[k], m);
      }
    }
  }
  for (int m = upbound + 1; m <= LIMIT; m++) {
    if (isp[m]) {
      p.push_back(m);
    }
  }
  long long n, k;
  cin >> n >> k;
  k = (k + 1) / 2;
  std::vector<std::pair<long long, long long> > d = factor(n);
  while (k > 0) {
    std::vector<std::pair<long long, long long> > nd;
    for (auto x : d) {
      if (x.second > 1) {
        nd.push_back(make_pair(x.first, x.second - 1));
      }
      for (auto y : factor(x.first - 1)) nd.push_back(y);
      n /= x.first;
      n *= (x.first - 1);
    }
    sort((nd).begin(), (nd).end());
    d.clear();
    for (int i = 0; i < nd.size(); i++) {
      if (i == 0 || nd[i].first != nd[i - 1].first)
        d.push_back(nd[i]);
      else
        d.back().second += nd[i].second;
    }
    k--;
    if (n == 1) break;
  }
  cout << n % mod;
}
