#include <bits/stdc++.h>
inline int solve(long long a, long long fa, long long b, long long fb) {
  if (!fa || !fb || (fa - fb % b) % a) return fa && fb && (fa == fb);
  return solve(a, (fa - fb % b) / a, b, (fb - fb % b) / b) + (fa == fb);
}
int main() {
  long long a, b, c;
  std::cin >> a >> b >> c;
  if (a == 1 && b == 1 && c == 1)
    std::cout << "inf" << std::endl;
  else if (a == b && b != c)
    std::cout << "0" << std::endl;
  else
    std::cout << solve(a, b, b, c) << std::endl;
  return 0;
}
