#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0;
  char c = getchar();
  bool f = 0;
  for (; c > '9' || c < '0'; f = c == '-', c = getchar())
    ;
  for (; c >= '0' && c <= '9'; x = (x << 1) + (x << 3) + c - '0', c = getchar())
    ;
  return f ? -x : x;
}
inline void write(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) write(x / 10);
  putchar(x % 10 + 48);
}
long long x, y, z;
int ans;
void dfs(long long fx, long long fy) {
  if (fx > fy) return;
  if (!fx && !fy) {
    ans++;
    return;
  }
  for (long long i = fy % y; i <= fy && i <= fx; i += y)
    if ((fx - i) % x == 0) dfs((fx - i) / x, (fy - i) / y);
}
int main() {
  x = read(), y = read(), z = read();
  if (x == 1 && y == 1) return puts(z == 1 ? "inf" : "0"), 0;
  if (x > y)
    swap(x, y), dfs(z, x);
  else
    dfs(y, z);
  printf("%d\n", ans);
}
