#include <bits/stdc++.h>
const int maxn = 2000 * 100 + 10;
const long long mod = (1e9 + 7);
using namespace std;
int main() {
  long long t, a, b;
  scanf("%lld%lld%lld", &t, &a, &b);
  if ((t == a) && (a != b))
    printf("0");
  else if (t > 1) {
    if ((t == a) && (t == b))
      printf("2");
    else {
      if (a == 1) {
        printf("%d", a == b);
        return 0;
      }
      long long na = a, nb = b;
      vector<int> at, ba;
      while (na > 0) {
        at.push_back(na % t);
        na /= t;
      }
      while (nb > 0) {
        ba.push_back(nb % a);
        nb /= a;
      }
      if (a == b)
        printf("%d", 1 + (at == ba));
      else
        printf("%d", (at == ba));
    }
  } else {
    if (a > 1) {
      long long s = 0, nb = b;
      while (nb > 0) {
        s += nb % a;
        nb /= a;
      }
      if (s == a) {
        printf("1");
      } else {
        if (a > b) {
          printf("0");
          return 0;
        }
        while (b % a == 0) {
          b /= a;
          if (b == 1LL) break;
        }
        if (b == 1)
          printf("1");
        else
          printf("0");
      }
    } else {
      printf("inf");
    }
  }
}
