#include <bits/stdc++.h>
long long rd() {
  long long k = 0, f = 1;
  char c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') k = k * 10 + c - 48, c = getchar();
  return f ? k : -k;
}
long long a, b, c, ans, w[110], tot;
bool calc(long long s1, long long s2) {
  if (s1 == 0 || s2 == 0) {
    if (s1 == 0 && s2 == 0) {
      ++ans;
      return 1;
    }
    return 0;
  }
  if (long long now = s2 % b) {
    if ((s1 - now) % a == 0) {
      w[++tot] = now;
      return calc((s1 - now) / a, (s2 - now) / b);
    }
    return 0;
  } else {
    bool flag = 0;
    long long k = ++tot;
    if (s1 % a == 0) w[k] = 0, flag = calc(s1 / a, s2 / b);
    if (s1 == b && s2 == b) {
      ++ans;
      if (!flag) w[k] = b, tot = k;
      return 1;
    }
    return flag;
  }
}
signed main() {
  scanf("%lld%lld%lld", &a, &b, &c);
  tot = -1, ans = 0;
  if (b == 1) {
    puts(c == 1 ? (a == 1 ? "inf" : "1") : "0");
    return 0;
  }
  calc(b, c), printf("%lld\n", ans);
  if (ans && tot == -1) tot = 0, w[tot] = b;
  return 0;
}
