#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int N = 1e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;
long long n, k;
long long phi(long long n) {
  long long ret = n;
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      ret = ret / i * (i - 1);
      while (n % i == 0) n /= i;
    }
  }
  if (n > 1) ret = ret / n * (n - 1);
  return ret;
}
long long F(long long n, long long k, long long e) {
  if (k == 1) return phi(n);
  if (e == 1) return 1;
  if (k & 1) return phi(F(n, k - 1, phi(e)));
  return F(n, k - 1, e);
}
int main() {
  ios_base::sync_with_stdio(0);
  while (cin >> n >> k) {
    cout << F(n, k, n) % MOD << endl;
  }
  return 0;
}
