#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
using namespace std;
long long n, k;
long long pr[1000005];
vector<long long> p;
long long power(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y % 2) res = (res * x) % 1000000007;
    x = (x * x) % 1000000007;
    y = y >> 1;
  }
  return res % 1000000007;
}
void prime() {
  long long i, j;
  for (i = 2; i < 1000005; i++)
    if (!pr[i]) {
      p.push_back(i);
      for (j = i * 2; j < 1000005; j += i) pr[j] = 1;
    }
}
long long solve(long long val) {
  if (val == 1) {
    return 1;
  }
  long long i, res = val;
  for (i = 0; i < p.size() && p[i] * p[i] <= val; i++) {
    if (val % p[i] == 0) {
      res -= (res / p[i]);
      while (val % p[i] == 0) val = val / p[i];
    }
  }
  if (val > 1) {
    res -= (res / val);
  }
  return res;
}
int main() {
  prime();
  cin >> n >> k;
  long long x = (k / 2) + (k % 2);
  long long ans = n;
  while (x--) {
    ans = solve(ans);
    if (ans == 1) break;
  }
  cout << ans % 1000000007;
  return 0;
}
