#include <bits/stdc++.h>
using namespace std;
long long a, b, c, ans;
void solve(long long s1, long long s2) {
  if (s1 == 0 || s2 == 0) {
    if (!s1 && !s2) {
      ++ans;
    }
    return;
  }
  if (long long hc = s2 % b) {
    if ((s1 - hc) % a == 0) {
      solve((s1 - hc) / a, (s2 - hc) / b);
    }
    return;
  } else {
    if (!(s1 % a)) {
      solve(s1 / a, s2 / b);
    }
    if (s1 == b && s2 == b) {
      ++ans;
    }
    return;
  }
}
signed main() {
  scanf("%lld%lld%lld", &a, &b, &c);
  if (b == 1) {
    puts(c == 1 ? (a == 1 ? "inf" : "1") : "0");
    return 0;
  }
  solve(b, c);
  printf("%lld\n", ans);
  return 0;
}
