#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    x = (x << 3) + (x << 1) + (c ^ '0'), c = getchar();
  return x * f;
}
const int N = 11005;
long long d[N], ans[N], tot, mx;
inline void solve(long long k, long long a, long long fa, long long b,
                  long long fb) {
  if (!fa || !fb) return;
  if (fa == fb) {
    tot++;
    d[k] = fa;
    if (k < mx) return;
    int flag = k > mx;
    mx = k;
    if (!flag) {
      for (int i = k; i >= 0; i--) {
        if (d[i] < ans[k]) {
          flag = 1;
          break;
        }
        if (d[i] != ans[k]) break;
      }
    }
    if (flag)
      for (int i = 0; i <= k; i++) ans[i] = d[i];
  }
  if ((fa - fb % b) % a) return;
  if (k > 80) {
    tot = 0;
    return;
  }
  d[k] = fb % b;
  solve(k + 1, a, (fa - fb % b) / a, b, (fb - fb % b) / b);
}
int main() {
  long long a = read(), b = read(), c = read();
  if (b == c) {
    if (a == b && a == 1) {
      puts("inf");
      return 0;
    }
    if (a == b)
      puts("2");
    else
      puts("1");
    return 0;
  }
  memset(ans, 0, sizeof(ans));
  memset(d, 0, sizeof(d));
  mx = -1;
  tot = 0;
  solve(0, a, b, b, c);
  printf("%lld\n", tot);
  return 0;
}
