#include <bits/stdc++.h>
using namespace std;
const long long N = 100005;
long long T, ans, res;
long long Ans[N], p[N], a, b, c;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline void solve(long long dep, long long a, long long x, long long b,
                  long long y) {
  if (x == 0 || y == 0) return;
  if (x == y) {
    p[dep] = x, ans = dep;
    for (long long i = 0; i <= dep; i++) Ans[i] = p[i];
    res++;
  }
  long long c = y % b;
  p[dep] = c;
  if (c % a != x % a) return;
  solve(dep + 1, a, (x - c) / a, b, (y - c) / b);
}
signed main() {
  a = read(), b = read(), c = read();
  if (a == 1 && b == 1 && c == 1) {
    printf("inf\n");
    return 0;
  }
  if (a == b && b != c) {
    printf("0\n");
    return 0;
  }
  res = 0;
  solve(0, a, b, b, c);
  printf("%d\n", res);
  return 0;
}
