#include <bits/stdc++.h>
using namespace std;
long long int vis[1000001] = {0};
vector<long long int> prim;
void shieve() {
  for (int i = 2; i <= 1000000; ++i) {
    if (!vis[i]) {
      for (int j = i; j <= 1000000; j += i) {
        vis[j] = 1;
      }
      prim.push_back(i);
    }
  }
  return;
}
long long int phi(long long int n) {
  long long int j = 0;
  long long int x = n;
  while (prim[j] <= sqrt(n) and j < prim.size()) {
    if (n % prim[j] == 0) {
      while (n % prim[j] == 0) {
        n = n / prim[j];
      }
      x = (x / prim[j]) * (prim[j] - 1);
    }
    j++;
  }
  if (n != 1) {
    x = (x / n) * (n - 1);
  }
  return x;
}
int main() {
  shieve();
  cin.tie(0), cerr.tie(0), ios_base::sync_with_stdio(0);
  ;
  long long int n;
  long long int k;
  cin >> n >> k;
  long long int y = (k - 1) / 2;
  y++;
  long long int ans = n;
  long long int count = 0;
  while (y--) {
    ans = phi(ans);
    if (ans == 1) {
      break;
    }
  }
  ans = ans % 1000000007;
  cout << ans << endl;
  return 0;
}
