#include <bits/stdc++.h>
using namespace std;
long long prime[1000009], T;
bool isp[1000009];
void precalc() {
  long long i, j;
  T = 0;
  for (i = 2; i <= 1000000; i++) {
    if (isp[i] == false) {
      for (j = i * i; j <= 1000000; j += i) {
        isp[j] = true;
      }
      prime[T] = i;
      T++;
    }
  }
}
long long GET(long long n) {
  long long i, j, ans, curr = n;
  if (curr == 1) return 1;
  ans = 1;
  for (i = 0; i < T && prime[i] * prime[i] <= curr; i++) {
    j = 1;
    while (curr % prime[i] == 0) {
      j *= prime[i];
      curr /= prime[i];
    }
    if (j > 1) {
      ans *= (j - j / prime[i]);
    }
  }
  if (curr > 1) ans *= (curr - 1);
  return ans;
}
int main() {
  long long i, j, k, l, n, m, curr, ans;
  precalc();
  cin >> n >> m;
  curr = n;
  for (i = m; i >= 1 && curr > 1; i--) {
    if (i % 2) {
      curr = GET(curr);
    }
  }
  cout << curr % 1000000007 << endl;
}
