#include <bits/stdc++.h>
using namespace std;
const int INF = (int)(1e9 + 1337);
const long long LINF = (long long)(4e18);
const double EPS = (double)(1e-11);
long long gcd(long long a, long long b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
long long f_trivia(long long n) {
  long long res = 0;
  for (int i = 1; i <= n; i++) res += (gcd(i, n - i) == 1);
  return res;
}
long long g_trivia(long long n) {
  long long res = 0;
  for (int i = 1; i <= n; i++)
    if ((n % i) == 0) res += f_trivia(n / i);
  return res;
}
long long phi(long long n) {
  long long res = n;
  for (long long i = 2; i * i <= n; i++)
    if ((n % i) == 0) {
      while ((n % i) == 0) n /= i;
      res -= res / i;
    }
  if (n > 1) res -= res / n;
  return res;
}
void solve() {
  long long n, k;
  cin >> n >> k;
  long long cur = phi(n);
  long long pos = 1;
  while (pos < k) {
    pos++;
    if (pos & 1) cur = phi(cur);
    if (cur == 1) pos = k;
  }
  cout << cur % 1000000007;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  solve();
}
