#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long s = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = 0;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    s = (s << 1) + (s << 3) + (c ^ 48), c = getchar();
  return f ? s : -s;
}
const long long N = 2e4 + 10;
long long tot, ans[N], now[N], Max;
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;
    now[k] = fa;
    if (k < Max) return;
    if (k == Max) {
      long long flag = 0;
      for (register long long i = k; ~i; --i) {
        if (now[i] < ans[k]) {
          flag = 1;
          break;
        }
        if (now[i] != ans[k]) break;
      }
      if (flag)
        for (register long long i = 0; i <= k; ++i) ans[i] = now[i];
    }
    Max = k;
  }
  if ((fa - fb % b) % a) return;
  if (k > 60) {
    tot = 0;
    return;
  }
  now[k] = fb % b;
  solve(k + 1, a, (fa - fb % b) / a, b, (fb - fb % b) / b);
}
signed main() {
  long long a = read(), b = read(), c = read();
  if (b == c) {
    if (a == b && a == 1)
      puts("inf");
    else {
      if (a == b)
        puts("2");
      else
        puts("1");
    }
  } else {
    memset(ans, 0, sizeof ans);
    memset(now, 0, sizeof now);
    Max = -1;
    tot = 0;
    solve(0, a, b, b, c);
    if (!tot)
      puts("0");
    else {
      printf("%lld\n", tot);
    }
  }
  return 0;
}
