#include <bits/stdc++.h>

using namespace std;

vector<pair<long long, long long> > v[2];

int main(){
	long long t, a, b;
	cin >> t >> a >> b;
	if(t == a){
		if(a != b){
			cout << "0" << endl;
		}
		else if(t == 1){
			cout << "inf" << endl;
		}
		else{
			cout << "2" << endl;
		}
		return 0;
	}
	if(a < t){
		if(a == b){
			cout << "1" << endl;
		}
		else{
			cout << "0" << endl;
		}
		return 0;
	}
	if((a-b)%(t-a)){
		cout << "0" << endl;
		return 0;
	}
	bool read=0, write=1;
	long long tp=t, ap=a;
	v[write].push_back(make_pair(a, b));
	for(int i=32; i >= 2; --i){
		/*if(a/t < tp)
			break;
		if(b/a < ap)
			break;*/
		tp=1;
		ap=1;
		for(int j=0; j < i; ++j){
			if(a/t < tp)
				tp=a+1;
			else
				tp=tp*t;
			if(b/t < ap)
				ap=b+1;
			else
				ap=ap*a;
		}
		write^=1;
		read^=1;
		v[write].clear();
		for(int j=0; j < v[read].size(); ++j){
			long long A=v[read][j].first;
			long long B=v[read][j].second;
			for(int k=0; tp*k <= A && ap*k <= B; ++k){
				long long nA=A-tp*k;
				long long nB=B-ap*k;
				if(nA/(tp/t) < nB/(ap/a) && tp <= a && ap <= b)
					continue;
				v[write].push_back(make_pair(A-tp*k, B-ap*k));
			}
		}
	}
	long long ans=0;
	for(int i=0; i < v[write].size(); ++i){
		long long A=v[write][i].first;
		long long B=v[write][i].second;
		if((A-B)%(t-a))
			continue;
		long long c1=(A-B)/(t-a);
		long long c0=A-c1*t;
		if(c1 >= 0 && c0 >= 0)++ans;
	}
	cout << ans << endl;
}


#include <bits/stdc++.h>

using namespace std;

vector<pair<long long, long long> > v[2];

int main(){
	long long t, a, b;
	cin >> t >> a >> b;
	if(t == a){
		if(a != b){
			cout << "0" << endl;
		}
		else if(t == 1){
			cout << "inf" << endl;
		}
		else{
			cout << "2" << endl;
		}
		return 0;
	}
	if(a < t){
		if(a == b){
			cout << "1" << endl;
		}
		else{
			cout << "0" << endl;
		}
		return 0;
	}
	if((a-b)%(t-a)){
		cout << "0" << endl;
		return 0;
	}
	bool read=0, write=1;
	long long tp=t, ap=a;
	v[write].push_back(make_pair(a, b));
	for(int i=32; i >= 2; --i){
		/*if(a/t < tp)
			break;
		if(b/a < ap)
			break;*/
		tp=1;
		ap=1;
		for(int j=0; j < i; ++j){
			if(a/t < tp)
				tp=a+1;
			else
				tp=tp*t;
			if(b/t < ap)
				ap=b+1;
			else
				ap=ap*a;
		}
		write^=1;
		read^=1;
		v[write].clear();
		for(int j=0; j < v[read].size(); ++j){
			long long A=v[read][j].first;
			long long B=v[read][j].second;
			for(int k=0; tp*k <= A && ap*k <= B; ++k){
				long long nA=A-tp*k;
				long long nB=B-ap*k;
				if(nA/(tp/t) < nB/(ap/a))
					continue;
				v[write].push_back(make_pair(A-tp*k, B-ap*k));
			}
		}
	}
	long long ans=0;
	for(int i=0; i < v[write].size(); ++i){
		long long A=v[write][i].first;
		long long B=v[write][i].second;
		if((A-B)%(t-a))
			continue;
		long long c1=(A-B)/(t-a);
		long long c0=A-c1*t;
		if(c1 >= 0 && c0 >= 0)++ans;
	}
	cout << ans << endl;
}


#include <bits/stdc++.h>

using namespace std;

vector<pair<long long, long long> > v[2];

int main(){
	long long t, a, b;
	cin >> t >> a >> b;
	if(t == a){
		if(a != b){
			cout << "0" << endl;
		}
		else if(t == 1){
			cout << "inf" << endl;
		}
		else{
			cout << "2" << endl;
		}
		return 0;
	}
	bool read=0, write=1;
	long long tp=t, ap=a;
	v[write].push_back(make_pair(a, b));
	for(int i=2; i <= 32; ++i){
		if(a/t < tp)
			break;
		if(b/a < ap)
			break;
		write^=1;
		read^=1;
		v[write].clear();
		tp*=t;
		ap*=a;
		for(int j=0; j < v[read].size(); ++j){
			long long A=v[read][j].first;
			long long B=v[read][j].second;
			for(int k=0; tp*k <= A && ap*k <= B; ++k)
				v[write].push_back(make_pair(A-tp*k, B-ap*k));
		}
	}
	long long ans=0;
	for(int i=0; i < v[write].size(); ++i){
		long long A=v[write][i].first;
		long long B=v[write][i].second;
		if((A-B)%(t-a))
			continue;
		long long c1=(A-B)/(t-a);
		long long c0=A-c1*t;
		if(c1 >= 0 && c0 >= 0)++ans;
	}
	cout << ans << endl;
}


#include <bits/stdc++.h>

using namespace std;

vector<pair<long long, long long> > v[2];

int main(){
	long long t, a, b;
	cin >> t >> a >> b;
	if(t == a){
		if(a != b){
			cout << "0" << endl;
		}
		else if(t == 1){
			cout << "inf" << endl;
		}
		else{
			cout << "2" << endl;
		}
		return 0;
	}
	if(a < t){
		if(a == b){
			cout << "1" << endl;
		}
		else{
			cout << "0" << endl;
		}
		return 0;
	}
	if((a-b)%(t-a)){
		cout << "0" << endl;
		return 0;
	}
	bool read=0, write=1;
	long long tp=t, ap=a;
	v[write].push_back(make_pair(a, b));
	for(int i=32; i >= 2; --i){
		/*if(a/t < tp)
			break;
		if(b/a < ap)
			break;*/
		tp=1;
		ap=1;
		for(int j=0; j < i; ++j){
			if(a/t < tp)
				tp=a+1;
			else
				tp=tp*t;
			if(b/t < ap)
				ap=b+1;
			else
				ap=ap*a;
		}
		write^=1;
		read^=1;
		v[write].clear();
		for(int j=0; j < v[read].size(); ++j){
			long long A=v[read][j].first;
			long long B=v[read][j].second;
			for(int k=0; tp*k <= A && ap*k <= B; ++k){
				long long nA=A-tp*k;
				long long nB=B-ap*k;
				if(tp <= a && ap <= b && nA/(tp/t) < nB/(ap/a))
					continue;
				v[write].push_back(make_pair(A-tp*k, B-ap*k));
			}
		}
	}
	long long ans=0;
	for(int i=0; i < v[write].size(); ++i){
		long long A=v[write][i].first;
		long long B=v[write][i].second;
		if((A-B)%(t-a))
			continue;
		long long c1=(A-B)/(t-a);
		long long c0=A-c1*t;
		if(c1 >= 0 && c0 >= 0)++ans;
	}
	cout << ans << endl;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define x first
#define y second
#define in(n) int (n) = nxt()

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef int itn;
typedef pair<int, int> PII;

int nxt() {
    int res;
    scanf("%d", &res);
    return res;
}

ll pw[2][100];

const ll inf = 2000000000ll * 1000000000ll;

ll mul(ll a, ll b) {
    ld c = (ld) a * b;
    if (c > inf - 100) {
        return inf;
    }
    return a * b;
}

ll ans = 0;
ll t, a, b;
int curSt;
void rec(int st, ll sa = 0, ll sb = 0) {
    if (sa > a || sb > b) {
        return;
    }
    if (st < 0) {
        if (sa == a && sb == b) {
            ans++;
        }
        return;
    }
    for (ll co = (st == curSt ? 1 : 0); sa + co * pw[0][st] <= a && sb + co * pw[1][st] <= b; ++co) {
        rec(st - 1, sa + co * pw[0][st], sb + co * pw[1][st]);
    }
}

inline void solve() {

    cin >> t >> a >> b;

    if (t == a) {
        if (a == b && a == 1) {
            cout << "inf" << endl;
            return;
        }
        if (a == b) {
            cout << "2" << endl;
            return;
        }
        if (a != b) {
            cout << "0" << endl;
            return;
        }
        return;
    }

    if (t > a && a == b) {
        cout << "1" << endl;
        return;
    }

    if (t > a) {
        cout << "0" << endl;
        return;
    }

    if (t < a && a == b) {
        cout << "1" << endl;
        return;
    }

    if (t < a && a > b) {
        cout << "0" << endl;
        return;
    }

    assert(t < a && a < b);
    pw[0][0] = 1;
    pw[1][0] = 1;
    for (int i = 1; i < 100; ++i) {
        pw[0][i] = mul(pw[0][i - 1], t);
        pw[1][i] = mul(pw[1][i - 1], a);
    }
    int step = 100;
    for (int i = 0; i < 100; ++i) {
        if (pw[0][i] > a) {
            step = min(step, i - 1);
        }
        if (pw[1][i] > b) {
            step = min(step, i - 1);
        }
    }

    for (int st = step; st > 1; --st) {
        curSt = st;
        rec(st);
    }
    if (step >= 1) {
        if ((b - a) % (a - t) == 0) {
            ll a1 = (b - a) / (a - t);
            if (a1 > 0) {
                ll a0 = a - a1 * t;
                if (a0 >= 0) {
                    ++ans;
                }
            }
        }
    }
    cout << ans << endl;
}

int main()
{
#ifdef LOCAL
    ld cl0 = clock();
    freopen("input.txt", "r", stdin);
#else
    //string filename = "hard";
    //freopen((filename + ".in").c_str(), "r", stdin);
    //freopen((filename + ".out").c_str(), "w", stdout);
#endif // LOCAL

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    solve();

#ifdef LOCAL
    cerr << setprecision(10) << fixed << (clock() - cl0) / (CLOCKS_PER_SEC) << endl;
#endif
    return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define x first
#define y second
#define in(n) int (n) = nxt()

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef int itn;
typedef pair<int, int> PII;

int nxt() {
    int res;
    scanf("%d", &res);
    return res;
}

ll pw[2][100];

const ll inf = 2000000000ll * 1000000000ll;

ll mul(ll a, ll b) {
    ld c = (ld) a * b;
    if (c > inf - 100) {
        return inf;
    }
    return a * b;
}

ll ans = 0;
ll t, a, b;
int curSt;
void rec(int st, ll sa = 0, ll sb = 0) {
    if (sa > a || sb > b) {
        return;
    }
    if (st < 0) {
        if (sa == a && sb == b) {
            ans++;
        }
        return;
    }

    ll cococo = min((a - sa) / pw[0][st], (b - sb) / pw[0][st]);

    for (ll co = cococo; co >= (st == curSt ? 1 : 0) && co >= cococo - 200; --co) {
        rec(st - 1, sa + co * pw[0][st], sb + co * pw[1][st]);
    }
}

inline void solve() {

    cin >> t >> a >> b;

    if (t == a) {
        if (a != b) {
            cout << "0" << endl;
            return;
        }
        if (a == 1) {
            cout << "inf" << endl;
            return;
        }
        cout << "2" << endl;
        return;
    }

    if (t > a && a == b) {
        cout << "1" << endl;
        return;
    }

    if (t > a) {
        cout << "0" << endl;
        return;
    }

    if (t < a && a == b) {
        cout << "1" << endl;
        return;
    }

    if (t < a && a > b) {
        cout << "0" << endl;
        return;
    }

    assert(t < a && a < b);
    pw[0][0] = 1;
    pw[1][0] = 1;
    for (int i = 1; i < 100; ++i) {
        pw[0][i] = mul(pw[0][i - 1], t);
        pw[1][i] = mul(pw[1][i - 1], a);
    }
    int step = 100;
    for (int i = 0; i < 100; ++i) {
        if (pw[0][i] > a) {
            step = min(step, i - 1);
        }
        if (pw[1][i] > b) {
            step = min(step, i - 1);
        }
    }

    for (int st = step; st > 1; --st) {
        curSt = st;
        rec(st);
    }
    if (step >= 1) {
        if ((b - a) % (a - t) == 0) {
            ll a1 = (b - a) / (a - t);
            if (a1 > 0) {
                ll a0 = a - a1 * t;
                if (a0 >= 0) {
                    ++ans;
                }
            }
        }
    }
    cout << ans << endl;
}

int main()
{
#ifdef LOCAL
    ld cl0 = clock();
    freopen("input.txt", "r", stdin);
#else
    //string filename = "hard";
    //freopen((filename + ".in").c_str(), "r", stdin);
    //freopen((filename + ".out").c_str(), "w", stdout);
#endif // LOCAL

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    solve();

#ifdef LOCAL
    cerr << setprecision(10) << fixed << (clock() - cl0) / (CLOCKS_PER_SEC) << endl;
#endif
    return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define x first
#define y second
#define in(n) int (n) = nxt()

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef int itn;
typedef pair<int, int> PII;

int nxt() {
    int res;
    scanf("%d", &res);
    return res;
}

inline void solve() {
    ll t, a, b;
    cin >> t >> a >> b;
    if (t == a && a == b && a == 1) {
        cout << "inf" << endl;
        return;
    }

    if (t == a && a == b) {
        cout << "2" << endl;
        return;
    }

    if (t > a && a == b) {
        cout << "1" << endl;
        return;
    }

    if (t > a) {
        cout << "0" << endl;
        return;
    }

    if (t < a && a == b) {
        cout << "1" << endl;
        return;
    }

    if (t < a && a > b) {
        cout << "0" << endl;
        return;
    }

    assert(t < a && a < b);
    cout << "1" << endl;
}

int main()
{
#ifdef LOCAL
    ld cl0 = clock();
    freopen("input.txt", "r", stdin);
#else
    //string filename = "hard";
    //freopen((filename + ".in").c_str(), "r", stdin);
    //freopen((filename + ".out").c_str(), "w", stdout);
#endif // LOCAL

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    solve();

#ifdef LOCAL
    cerr << setprecision(10) << fixed << (clock() - cl0) / (CLOCKS_PER_SEC) << endl;
#endif
    return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define x first
#define y second
#define in(n) int (n) = nxt()

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef int itn;
typedef pair<int, int> PII;

int nxt() {
    int res;
    scanf("%d", &res);
    return res;
}

ll pw[2][100];

const ll inf = 2000000000ll * 1000000000ll;

ll mul(ll a, ll b) {
    ld c = (ld) a * b;
    if (c > inf - 100) {
        return inf;
    }
    return a * b;
}

ll ans = 0;
ll t, a, b;
int curSt;
void rec(int st, ll sa = 0, ll sb = 0) {
    if (sa > a || sb > b) {
        return;
    }
    if (st < 0) {
        if (sa == a && sb == b) {
            ans++;
        }
        return;
    }
    for (ll co = (st == curSt ? 1 : 0); sa + co * pw[0][st] <= a && sb + co * pw[1][st] <= b; ++co) {
        rec(st - 1, sa + co * pw[0][st], sb + co * pw[1][st]);
    }
}

inline void solve() {

    cin >> t >> a >> b;
    if (t == a && a == b && a == 1) {
        cout << "inf" << endl;
        return;
    }

    if (t == a && a == b) {
        cout << "2" << endl;
        return;
    }

    if (t > a && a == b) {
        cout << "1" << endl;
        return;
    }

    if (t > a) {
        cout << "0" << endl;
        return;
    }

    if (t < a && a == b) {
        cout << "1" << endl;
        return;
    }

    if (t < a && a > b) {
        cout << "0" << endl;
        return;
    }

    assert(t < a && a < b);
    pw[0][0] = 1;
    pw[1][0] = 1;
    for (int i = 1; i < 100; ++i) {
        pw[0][i] = mul(pw[0][i - 1], t);
        pw[1][i] = mul(pw[1][i - 1], a);
    }
    int step = 100;
    for (int i = 0; i < 100; ++i) {
        if (pw[0][i] > a) {
            step = min(step, i - 1);
        }
        if (pw[1][i] > b) {
            step = min(step, i - 1);
        }
    }

    for (int st = step; st > 1; --st) {
        curSt = st;
        rec(st);
    }
    if (step >= 1) {
        if ((b - a) % (a - t) == 0) {
            ll a1 = (b - a) / (a - t);
            if (a1 > 0) {
                ll a0 = a - a1 * t;
                if (a0 >= 0) {
                    ++ans;
                }
            }
        }
    }
    cout << ans << endl;
}

int main()
{
#ifdef LOCAL
    ld cl0 = clock();
    freopen("input.txt", "r", stdin);
#else
    //string filename = "hard";
    //freopen((filename + ".in").c_str(), "r", stdin);
    //freopen((filename + ".out").c_str(), "w", stdout);
#endif // LOCAL

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    solve();

#ifdef LOCAL
    cerr << setprecision(10) << fixed << (clock() - cl0) / (CLOCKS_PER_SEC) << endl;
#endif
    return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define x first
#define y second
#define in(n) int (n) = nxt()

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef int itn;
typedef pair<int, int> PII;

int nxt() {
    int res;
    scanf("%d", &res);
    return res;
}

inline void solve() {
    ll t, a, b;
    cin >> t >> a >> b;
    if (t == a && a == b && a == 1) {
        cout << "inf" << endl;
        return;
    }

    if (t == a && a == b) {
        cout << "2" << endl;
        return;
    }

    if (t > a && a == b) {
        cout << "1" << endl;
        return;
    }

    if (t > a) {
        cout << "0" << endl;
        return;
    }

    if (t < a && a == b) {
        cout << "1" << endl;
        return;
    }

    if (t < a && a > b) {
        cout << "0" << endl;
        return;
    }

    assert(t < a && a < b);
    assert(false);
    cout << "sadasdas" << endl;
}

int main()
{
#ifdef LOCAL
    ld cl0 = clock();
    freopen("input.txt", "r", stdin);
#else
    //string filename = "hard";
    //freopen((filename + ".in").c_str(), "r", stdin);
    //freopen((filename + ".out").c_str(), "w", stdout);
#endif // LOCAL

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    solve();

#ifdef LOCAL
    cerr << setprecision(10) << fixed << (clock() - cl0) / (CLOCKS_PER_SEC) << endl;
#endif
    return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define x first
#define y second
#define in(n) int (n) = nxt()

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef int itn;
typedef pair<int, int> PII;

int nxt() {
    int res;
    scanf("%d", &res);
    return res;
}

inline void solve() {
    ll t, a, b;
    cin >> t >> a >> b;
    if (t == a && a == b && a == 1) {
        cout << "inf" << endl;
        return;
    }

    if (t == a && a == b) {
        cout << "2" << endl;
        return;
    }

    if (t > a && a == b) {
        cout << "1" << endl;
        return;
    }

    if (t > a) {
        cout << "0" << endl;
        return;
    }

    if (t < a && a == b) {
        cout << "1" << endl;
        return;
    }

    if (t < a && a > b) {
        cout << "0" << endl;
        return;
    }

    assert(t < a && a < b);
    cout << "sadasdas" << endl;
}

int main()
{
#ifdef LOCAL
    ld cl0 = clock();
    freopen("input.txt", "r", stdin);
#else
    //string filename = "hard";
    //freopen((filename + ".in").c_str(), "r", stdin);
    //freopen((filename + ".out").c_str(), "w", stdout);
#endif // LOCAL

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    solve();

#ifdef LOCAL
    cerr << setprecision(10) << fixed << (clock() - cl0) / (CLOCKS_PER_SEC) << endl;
#endif
    return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define x first
#define y second
#define in(n) int (n) = nxt()

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef int itn;
typedef pair<int, int> PII;

int nxt() {
    int res;
    scanf("%d", &res);
    return res;
}

ll pw[2][100];

const ll inf = 2000000000ll * 1000000000ll;

ll mul(ll a, ll b) {
    ld c = (ld) a * b;
    if (c > inf - 100) {
        return inf;
    }
    return a * b;
}

ll ans = 0;
ll t, a, b;
int curSt;
void rec(int st, ll sa = 0, ll sb = 0) {
    if (sa > a || sb > b) {
        return;
    }
    if (st < 0) {
        if (sa == a && sb == b) {
            ans++;
        }
        return;
    }
    for (ll co = (st == curSt ? 1 : 0); sa + co * pw[0][st] <= a && sb + co * pw[1][st] <= b; ++co) {
        rec(st - 1, sa + co * pw[0][st], sb + co * pw[1][st]);
    }
}

inline void solve() {

    cin >> t >> a >> b;
    if (t == a && a == b && a == 1) {
        cout << "inf" << endl;
        return;
    }

    if (t == a && a == b) {
        cout << "2" << endl;
        return;
    }

    if (t > a && a == b) {
        cout << "1" << endl;
        return;
    }

    if (t > a) {
        cout << "0" << endl;
        return;
    }

    if (t < a && a == b) {
        cout << "1" << endl;
        return;
    }

    if (t < a && a > b) {
        cout << "0" << endl;
        return;
    }

    //assert(t < a && a < b);
    pw[0][0] = 1;
    pw[1][0] = 1;
    for (int i = 1; i < 100; ++i) {
        pw[0][i] = mul(pw[0][i - 1], t);
        pw[1][i] = mul(pw[1][i - 1], a);
    }
    int step = 100;
    for (int i = 0; i < 100; ++i) {
        if (pw[0][i] > a) {
            step = min(step, i - 1);
        }
        if (pw[1][i] > b) {
            step = min(step, i - 1);
        }
    }

    for (int st = step; st > 1; --st) {
        curSt = st;
        rec(st);
    }
    if (step >= 1) {
        if ((b - a) % (a - t) == 0) {
            ll a1 = (b - a) / (a - t);
            if (a1 > 0) {
                ll a0 = a - a1 * t;
                if (a0 >= 0) {
                    ++ans;
                }
            }
        }
    }
    cout << ans << endl;
}

int main()
{
#ifdef LOCAL
    ld cl0 = clock();
    freopen("input.txt", "r", stdin);
#else
    //string filename = "hard";
    //freopen((filename + ".in").c_str(), "r", stdin);
    //freopen((filename + ".out").c_str(), "w", stdout);
#endif // LOCAL

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    solve();

#ifdef LOCAL
    cerr << setprecision(10) << fixed << (clock() - cl0) / (CLOCKS_PER_SEC) << endl;
#endif
    return 0;
}


#include <stdio.h>
#include <math.h>
#include <string.h>
#include <memory.h>
#include <stdlib.h>
#include <ctype.h>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(b)-1;i>=a;i--)
#define ALL(v) v.begin(),v.end()
const int INF = 0x7FFFFFFF;

LL ti[8];
LL zi[8];

LL solve(int k, LL x, LL y) {
  if (k-- == 0) return (x == 0);
  LL answer = 0;
  while (x >= 0 && y >= 0) {
    answer += solve(k, x, y);
    x -= zi[k];
    y -= ti[k];
  }
  return answer;
}

int main() {
  LL t, a, b;
  cin >> t >> a >> b;
  if (t == 1 && a == 1) {
    if (b == 1) cout << "inf";
    else cout << 0;
    return 0;
  }
  if (a < t) {
    if (a == b) cout << 1;
    else cout << 0;
    return 0;
  }
  if (a == t) {
    if (a == b) cout << 2;
    else cout << 0;
    return 0;
  }
  if (b <= a) {
    if (a == b) cout << 1;
    else cout << 0;
    return 0;
  }
  int k = 0;
  LL tk = 1, ak = 1;
  while (true) {
    if (tk > a / t) break;
    if (ak > b / a) break;
    tk *= t;
    ak *= a;
    ti[k] = tk;
    zi[k] = ak - tk;
    k++;
  }
  cout << (solve(k, b - a, a) % 1000000007);
  return 0;
}


#include <stdio.h>
#include <math.h>
#include <string.h>
#include <memory.h>
#include <stdlib.h>
#include <ctype.h>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(b)-1;i>=a;i--)
#define ALL(v) v.begin(),v.end()
const int INF = 0x7FFFFFFF;

LL ti[8];
LL zi[8];

LL solve(int k, LL x, LL y) {
  if (k-- == 0) return (x == 0);
  LL answer = 0;
  while (x >= 0 && y >= 0) {
    answer += solve(k, x, y);
    x -= zi[k];
    y -= ti[k];
  }
  return answer;
}

int main() {
  LL t, a, b;
  cin >> t >> a >> b;
  if (t == 1 && a == 1) {
    if (b == 1) cout << "inf";
    else cout << 0;
    return 0;
  }
  if (a < t) {
    if (a == b) cout << 1;
    else cout << 0;
    return 0;
  }
  if (a == t) {
    if (a == b) cout << 2;
    else cout << 0;
    return 0;
  }
  if (b <= a) {
    if (a == b) cout << 1;
    else cout << 0;
    return 0;
  }
  if (t == 1) {
    int k = 0;
    LL ak = 1;
    while (ak <= b / a) {
      ak *= a;
      k++;
    }
    if (b == ak) {
      cout << 1;
      return 0;
    }
    LL sum = 0;
    while (ak) {
      sum += b / ak;
      b %= ak;
      ak /= a;
    }
    cout << (sum == a);
    return 0;
  }
  int k = 0;
  LL tk = 1, ak = 1;
  while (true) {
    if (tk > a / t) break;
    if (ak > b / a) break;
    tk *= t;
    ak *= a;
    ti[k] = tk;
    zi[k] = ak - tk;
    k++;
  }
  cout << (solve(k, b - a, a) % 1000000007);
  return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:1000000000")
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <complex>
#include <cassert>
#include <string>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef complex < double > cd;

const bool db = false;

#define mp make_pair
#define pb push_back
#define ppb pop_back
#define sd second
#define fs first

#define inf 1000000007
#define nmax 1000010
#define mmax 100010
#define eps 1e-9

ll t, a, b;

vector < ll > f(ll n, ll d) {
	vector < ll > res;
	while(n > 0) {
		res.pb(n % d);
		n /= d;
	}
	return res;
}

int main() {
	//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	//freopen("distance.in", "r", stdin); freopen("distance.out", "w", stdout);
	cin >> t >> a >> b;
	if(t == 1 && a == 1 && b == 1) {
		cout << "inf\n";
		exit(0);
	}
	if(t == a && a == b) {
		cout << "2\n";
		exit(0);
	}
	if(a == b) {
		cout << "1\n";
		exit(0);
	}
	if(t > a || a > b) {
		cout << "0\n";
		exit(0);
	}
	if(t == 1) {
		cout << "0\n";
		exit(0);
	}
	vector < ll > fa = f(a, t), fb = f(b, a);
	printf("%d\n", fa != fb);
	getchar(); getchar();
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:1000000000")
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <complex>
#include <cassert>
#include <string>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef complex < double > cd;

const bool db = false;

#define mp make_pair
#define pb push_back
#define ppb pop_back
#define sd second
#define fs first

#define inf 1000000007
#define nmax 1000010
#define mmax 100010
#define eps 1e-9

ll t, a, b;

vector < ll > f(ll n, ll d) {
	vector < ll > res;
	while(n > 0) {
		res.pb(n % d);
		n /= d;
	}
	//reverse(res.begin(), res.end());
	return res;
}

bool calc(vector < ll > f, ll x, ll need) {
	ll res = f[0];
	for(int i = 1; i < f.size() && res <= need; ++i) {
		res = res + x * f[i];
	}
	//cout << res << " " << need << endl;
	return res == need;
}

int main() {
	//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	//freopen("distance.in", "r", stdin); freopen("distance.out", "w", stdout);
	cin >> t >> a >> b;
	if(t == 1 && a == 1 && b == 1) {
		cout << "inf\n";
		exit(0);
	}
	if(t == a && a == b) {
		cout << "2\n";
		exit(0);
	}
	if(a == b) {
		cout << "1\n";
		exit(0);
	}
	if(t > a || a > b) {
		cout << "0\n";
		exit(0);
	}
	if(t == a) {
		cout << "0\n";
		exit(0);
	}
	//f(1)=a0+a1+...+an=a
	//f(a)=a0+a1*a+a2*a^2+...+an*a^(n-1)=b
	if(t != 1) {
		vector < ll > fa = f(a, t), fb = f(b, a);
		printf("%d\n", fa == fb);
	} else if(t == 1) {
		printf("%d\n", (b - a) % (a - t) == 0);
	}
	getchar(); getchar();
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:1000000000")
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <complex>
#include <cassert>
#include <string>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef complex < double > cd;

const bool db = false;

#define mp make_pair
#define pb push_back
#define ppb pop_back
#define sd second
#define fs first

#define inf 1000000007
#define nmax 1000010
#define mmax 100010
#define eps 1e-9

ll t, a, b;

vector < ll > f(ll n, ll d) {
	vector < ll > res;
	while(n > 0) {
		res.pb(n % d);
		n /= d;
	}
	reverse(res.begin(), res.end());
	return res;
}

bool calc(vector < ll > f, ll x, ll need) {
	ll res = 0;
	for(int i = 0; i < f.size() && res <= need; ++i) {
		res = res + x * f[i];
	}
	return res == need;
}

int main() {
	//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	//freopen("distance.in", "r", stdin); freopen("distance.out", "w", stdout);
	cin >> t >> a >> b;
	if(t == 1 && a == 1 && b == 1) {
		cout << "inf\n";
		exit(0);
	}
	if(t == a && a == b) {
		cout << "2\n";
		exit(0);
	}
	if(a == b) {
		cout << "1\n";
		exit(0);
	}
	if(t > a || a > b) {
		cout << "0\n";
		exit(0);
	}
	if(t == a) {
		cout << "0\n";
		exit(0);
	}
	if(a != 1 && t != 1) {
		vector < ll > fa = f(a, t), fb = f(b, a);
		printf("%d\n", fa == fb);
	} else if(a == 1) {
		vector < ll > fa = f(a, t);
		printf("%d\n", calc(fa, a, b));
	} else {
		vector < ll > fb = f(b, a);
		printf("%d\n", calc(fb, t, a));
	}
	getchar(); getchar();
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:1000000000")
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <complex>
#include <cassert>
#include <string>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef complex < double > cd;

const bool db = false;

#define mp make_pair
#define pb push_back
#define ppb pop_back
#define sd second
#define fs first

#define inf 1000000007
#define nmax 1000010
#define mmax 100010
#define eps 1e-9

ll t, a, b;

int main() {
	//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	//freopen("distance.in", "r", stdin); freopen("distance.out", "w", stdout);
	cin >> t >> a >> b;
	if(t == a && a == b) {
		cout << 2 << endl;
	} else if(a == b) {
		cout << 1 << endl;
	} else if(t == a) {
		cout << 0 << endl;
	} else if(t == b) {
		cout << 1 << endl;
	} else {
		cout << "inf" << endl;
	}
	getchar(); getchar();
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:1000000000")
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <complex>
#include <cassert>
#include <string>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef complex < double > cd;

const bool db = false;

#define mp make_pair
#define pb push_back
#define ppb pop_back
#define sd second
#define fs first

#define inf 1000000007
#define nmax 1000010
#define mmax 100010
#define eps 1e-9

ll t, a, b;

vector < ll > f(ll n, ll d) {
	vector < ll > res;
	while(n > 0) {
		res.pb(n % d);
		n /= d;
	}
	//reverse(res.begin(), res.end());
	return res;
}

bool calc(vector < ll > f, ll x, ll need) {
	ll res = f[0];
	for(int i = 1; i < f.size(); ++i) {
		res = res + x * f[i];
	}
	cout << res << " " << need << endl;
	return res == need;
}

int main() {
	//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	//freopen("distance.in", "r", stdin); freopen("distance.out", "w", stdout);
	cin >> t >> a >> b;
	if(t == 1 && a == 1 && b == 1) {
		cout << "inf\n";
		exit(0);
	}
	if(t == a && a == b) {
		cout << "2\n";
		exit(0);
	}
	if(a == b) {
		cout << "1\n";
		exit(0);
	}
	if(t > a || a > b) {
		cout << "0\n";
		exit(0);
	}
	if(t == a) {
		cout << "0\n";
		exit(0);
	}
	//f(1)=a0+a1+...+an=a
	//f(a)=a0+a1*a+a2*a^2+...+an*a^(n-1)=b
	if(t != 1) {
		vector < ll > fa = f(a, t), fb = f(b, a);
		printf("%d\n", fa == fb);
	} else if(t == 1) {
		printf("%d\n", (b - a) % (a - t) == 0);
	}
	getchar(); getchar();
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:1000000000")
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <complex>
#include <cassert>
#include <string>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef complex < double > cd;

const bool db = false;

#define mp make_pair
#define pb push_back
#define ppb pop_back
#define sd second
#define fs first

#define inf 1000000007
#define nmax 1000010
#define mmax 100010
#define eps 1e-9

ll t, a, b;

vector < ll > f(ll n, ll d) {
	vector < ll > res;
	while(n > 0) {
		res.pb(n % d);
		n /= d;
	}
	return res;
}

int main() {
	//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	//freopen("distance.in", "r", stdin); freopen("distance.out", "w", stdout);
	cin >> t >> a >> b;
	if(t == 1 && a == 1 && b == 1) {
		cout << "inf\n";
		exit(0);
	}
	if(t == a && a == b) {
		cout << "2\n";
		exit(0);
	}
	if(a == b) {
		cout << "1\n";
		exit(0);
	}
	if(t > a || a > b) {
		cout << "0\n";
		exit(0);
	}
	if(t == 1) {
		cout << "0\n";
		exit(0);
	}
	vector < ll > fa = f(a, t), fb = f(b, a);
	printf("%d\n", fa == fb);
	getchar(); getchar();
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:1000000000")
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <complex>
#include <cassert>
#include <string>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef complex < double > cd;

const bool db = false;

#define mp make_pair
#define pb push_back
#define ppb pop_back
#define sd second
#define fs first

#define inf 1000000007
#define nmax 1000010
#define mmax 100010
#define eps 1e-9

ll t, a, b;

vector < ll > f(ll n, ll d) {
	vector < ll > res;
	while(n > 0) {
		res.pb(n % d);
		n /= d;
	}
	return res;
}

int main() {
	//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	//freopen("distance.in", "r", stdin); freopen("distance.out", "w", stdout);
	cin >> t >> a >> b;
	if(t == 1 && a == 1 && b == 1) {
		cout << "inf\n";
		exit(0);
	}
	if(t == a && a == b) {
		cout << "2\n";
		exit(0);
	}
	if(a == b) {
		cout << "1\n";
		exit(0);
	}
	if(t > a || b < a) {
		cout << "0\n";
		exit(0);
	}
	if(t == 1 && a == t) {
		cout << "0\n";
		exit(0);
	}
	vector < ll > fa = f(a, t), fb = f(b, a);
	printf("%d\n", fa == fb);
	getchar(); getchar();
	return 0;
}


/****************************************/
/*****          Desgard_Duan        *****/
/****************************************/
//#pragma comment(linker, "/STACK:102400000,102400000")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <vector>
#include <set>
#include <functional>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;

void data() {
    freopen("data.in", "r", stdin);
    freopen("data.out", "w", stdout);
}

long long gcd(long long a, long long b) {
    return b ? gcd(b, a % b) : a;
}

inline void get_val(long long &a) {
    long long value = 0, s = 1;
    char c;
    while ((c = getchar()) == ' ' || c == '\n');
    if (c == '-') s = -s;
    else value = c - 48;
    while ((c = getchar()) >= '0' && c <= '9')
        value = value * 10 + c - 48;
    a = s * value;
}

inline void get_val (long long &a, long long &b, long long &c) {
    get_val (a);
    get_val (b);
    get_val (c);
}

long long gao (long long a, long long b, long long c, long long d) {
    if (b == 0 && d == 0) {
        return 1;
    }
    if (b == 0 || d == 0) {
        return 0;
    }
    long long ans = 0;
    for (long long i = 0; i <= 1; ++ i) {
        long long a0 = i * c + d % c;
        if (a0 > b || a0 > d) break;
        if ((b - a0) % a == 0) {
            ans += gao (a, (b - a0) / a, c, (d - a0) / c);
        }
    }
    return ans;
}

int main () {
    long long t, a, b;
    get_val (t, a, b);
    if (t == 1 && a == 1) {
        if (b == 1) {
            puts ("inf");
        } else {
            puts ("0");
        }
    } else {
        printf ("%I64d\n", gao (t, a, a, b));
    }
    return 0;
}


/****************************************/
/*****          Desgard_Duan        *****/
/****************************************/
//#pragma comment(linker, "/STACK:102400000,102400000")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <vector>
#include <set>
#include <functional>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;

void data() {
    freopen("data.in", "r", stdin);
    freopen("data.out", "w", stdout);
}

long long gcd(long long a, long long b) {
    return b ? gcd(b, a % b) : a;
}

inline void get_val(long long &a) {
    long long value = 0, s = 1;
    char c;
    while ((c = getchar()) == ' ' || c == '\n');
    if (c == '-') s = -s;
    else value = c - 48;
    while ((c = getchar()) >= '0' && c <= '9')
        value = value * 10 + c - 48;
    a = s * value;
}

inline void get_val (long long &a, long long &b, long long &c) {
    get_val (a);
    get_val (b);
    get_val (c);
}

long long gao (long long a, long long b, long long c, long long d) {
    if (b == 0 && d == 0) {
        return 1;
    }
    if (b == 0 || d == 0) {
        return 0;
    }
    long long ans = 0;
    for (long long i = 0; i <= 1; ++ i) {
        long long a0 = i * c + d % c;
        if (a0 > b || a0 > d) break;
        if ((b - a0) % a == 0) {
            ans += gao (a, (b - a0) / a, c, (d - a0) / c);
        }
    }
    return ans;
}

int main () {
    long long t, a, b;
    get_val (t, a, b);
    if (t == 1 && a == 1) {
        if (b == 1) {
            puts ("inf");
        } else {
            puts ("0");
        }
    } else {
        printf ("%I64\n", gao (t, a, a, b));
    }
    return 0;
}


#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

typedef long long  LL;
LL a,b,t,c,n,sum,l[1010],ans;

void work()
{
    scanf("%I64d %I64d %I64d",&t,&a,&b);
    if (a==1)
        if (b==1)  if (t==1)  printf("inf");  else  printf("1");  else  printf("0");
    else
        {
            c=b;
            while (c)
                sum+=l[++n]=c%a,c/=a;
            if ((t==1)&&(b>=a)&&(sum==1))  ans++;
            if ((t>1)&&(b==a))  ans++;
            sum=0,c=1;
            for (int i=1; i<=n; i++)
                sum+=l[i]*c,c*=t;
            if (sum==a)  ans++;
            printf("%I64d",ans);
        }
}

int main()
{
    work();
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cmath>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <set>
#include <map>
#include <sstream>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
#define x first
#define y second
#define mp make_pair
#define pb push_back
ll G(ll a,ll b){if(b==0)return a;return G(b,a%b);}
ll co[1000];
int main(){
	ios_base::sync_with_stdio(false);
	ll t,a,b;
	cin>>t>>a>>b;
	ll cur=0,res=0;
	if(t!=1){
		if(a!=1){
			ll bb=b;
			while(bb){
				co[cur++]=bb%a;
				bb/=a;
			}
			ll tmp=0,powT=1;
			for(int i=0;i<cur;i++){
				tmp+=co[i]*powT;
				powT*=t;
			}
			if(tmp==a)res++;
		}
		if(a==b)res++;
		cout<<res;
		return 0;
	}
	if(a==1 && b==1){
		cout<<"inf";
		return 0;
	}
	if(a==1){
		cout<<0;
		return 0;
	}
	ll bb=b;
	if(bb==1)res--;
	while(bb%a==0)bb/=a;
	if(bb==1)res++;
	while(b){
		co[cur++]=b%a;
		b/=a;
	}
	ll tmp=0,powT=1;
	for(int i=0;i<cur;i++){
		tmp+=co[i]*powT;
		powT*=t;
	}
	if(tmp==a)res++;
	cout<<res;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cmath>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <set>
#include <map>
#include <sstream>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
#define x first
#define y second
#define mp make_pair
#define pb push_back
ll G(ll a,ll b){if(b==0)return a;return G(b,a%b);}
ll co[1000];
int main(){
	ios_base::sync_with_stdio(false);
	ll t,a,b;
	cin>>t>>a>>b;
	ll cur=0,res=0;
	if(t!=1){
		ll bb=b;
		while(bb){
			co[cur++]=bb%a;
			bb/=a;
		}
		ll tmp=0,powT=1;
		for(int i=0;i<cur;i++){
			tmp+=co[i]*powT;
			powT*=t;
		}
		if(tmp==a)res++;
		if(a==b)res++;
		cout<<res;
		return 0;
	}
	if(a==1 && b==1){
		cout<<"inf";
		return 0;
	}
	if(a==1){
		cout<<0;
		return 0;
	}
	ll bb=b;
	while(bb%a==0)bb/=a;
	if(bb==1)res++;
	while(b){
		co[cur++]=b%a;
		b/=a;
	}
	ll tmp=0,powT=1;
	for(int i=0;i<cur;i++){
		tmp+=co[i]*powT;
		powT*=t;
	}
	if(tmp==a)res++;
	cout<<res;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cmath>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <set>
#include <map>
#include <sstream>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
#define x first
#define y second
#define mp make_pair
#define pb push_back
ll G(ll a,ll b){if(b==0)return a;return G(b,a%b);}
ll co[1000];
int main(){
	ios_base::sync_with_stdio(false);
	ll t,a,b;
	cin>>t>>a>>b;
	ll cur=0,res=0;
	if(t!=1){
		if(a!=1){
			ll bb=b;
			while(bb){
				co[cur++]=bb%a;
				bb/=a;
			}
			ll tmp=0,powT=1;
			for(int i=0;i<cur;i++){
				tmp+=co[i]*powT;
				powT*=t;
			}
			if(tmp==a)res++;
		}
		if(a==b)res++;
		cout<<res;
		return 0;
	}
	if(a==1 && b==1){
		cout<<"inf";
		return 0;
	}
	if(a==1){
		cout<<0;
		return 0;
	}
	ll bb=b;
	while(bb%a==0)bb/=a;
	if(bb==1)res++;
	while(b){
		co[cur++]=b%a;
		b/=a;
	}
	ll tmp=0,powT=1;
	for(int i=0;i<cur;i++){
		tmp+=co[i]*powT;
		powT*=t;
	}
	if(tmp==a)res++;
	cout<<res;
}


#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

#define dbg(x) (cout<<#x<<" = "<<(x)<<'\n')
#ifdef HOME
const string inputFile = "input.txt";
const string outputFile = "output.txt";
#else
const string problemName = "";
const string inputFile = problemName + ".in";
const string outputFile = problemName + ".out";
#endif

typedef long long int lld;
typedef pair<int, int> PII;
typedef pair<int, lld> PIL;
typedef pair<lld, int> PLI;
typedef pair<lld, lld> PLL;

const int INF = (1LL << 31) - 1;
const lld LINF = (1LL << 62) - 1;
const int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};
const int MOD = (int)(1e9) + 7;

const int NMAX = 100000 + 5;
const int MMAX = 100000 + 5;
const int KMAX = 100000 + 5;
const int PMAX = 100000 + 5;
const int LMAX = 100000 + 5;
const int VMAX = 100000 + 5;

lld t, a, b, n, i, tt, q, sol = 0;
lld A[NMAX];

int putere(lld b, lld a) {
    while(b != 1 && b % a == 0)
        b /= a;
    return b == 1;
}

int main() {

#ifndef ONLINE_JUDGE
    freopen(inputFile.c_str(), "r", stdin);
    freopen(outputFile.c_str(), "w", stdout);
#endif

    scanf("%lld%lld%lld", &t, &a, &b);

    if(t != 1) {
        if(a == b)
            sol++;

        for(n = 0; b; n++) {
            A[n] = b % a;
            b /= a;
        }

        for(i = q = 0, tt = 1; i < n; i++) {
            q += A[i] * tt;
            tt *= t;
            if(q < 0 || q > a)
                break;
        }

        if(q == a)
            sol++;

        printf("%lld", sol);
    } else {
        if(a == 1 && b == 1)
            printf("inf");
        else if(putere(b, a))
            printf("1");
        else if(a <= b)
            printf("1");
        else
            printf("0");
    }

    return 0;
}


#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

#define dbg(x) (cout<<#x<<" = "<<(x)<<'\n')
#ifdef HOME
const string inputFile = "input.txt";
const string outputFile = "output.txt";
#else
const string problemName = "";
const string inputFile = problemName + ".in";
const string outputFile = problemName + ".out";
#endif

typedef long long int lld;
typedef pair<int, int> PII;
typedef pair<int, lld> PIL;
typedef pair<lld, int> PLI;
typedef pair<lld, lld> PLL;

const int INF = (1LL << 31) - 1;
const lld LINF = (1LL << 62) - 1;
const int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};
const int MOD = (int)(1e9) + 7;

const int NMAX = 100000 + 5;
const int MMAX = 100000 + 5;
const int KMAX = 100000 + 5;
const int PMAX = 100000 + 5;
const int LMAX = 100000 + 5;
const int VMAX = 100000 + 5;

lld t, a, b, n, i, tt, q, sol = 0;
lld A[NMAX];

int putere(lld b, lld a) {
    while(b != 1 && b % a == 0)
        b /= a;
    return b == 1;
}

int main() {

#ifndef ONLINE_JUDGE
    freopen(inputFile.c_str(), "r", stdin);
    freopen(outputFile.c_str(), "w", stdout);
#endif

    scanf("%lld%lld%lld", &t, &a, &b);

    if(t != 1 || (t == 1 && a != 1)) {
        if(a == b)
            sol++;

        for(n = 0; b; n++) {
            A[n] = b % a;
            b /= a;
        }

        for(i = q = 0, tt = 1; i < n; i++) {
            q += A[i] * tt;
            tt *= t;
            if(q < 0 || q > a)
                break;
        }

        if(q == a)
            sol++;

        printf("%lld", sol);
    } else {
        if(a == 1 && b == 1)
            printf("inf");
        else
            printf("0");
    }

    return 0;
}


#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

#define dbg(x) (cout<<#x<<" = "<<(x)<<'\n')
#ifdef HOME
const string inputFile = "input.txt";
const string outputFile = "output.txt";
#else
const string problemName = "";
const string inputFile = problemName + ".in";
const string outputFile = problemName + ".out";
#endif

typedef long long int lld;
typedef pair<int, int> PII;
typedef pair<int, lld> PIL;
typedef pair<lld, int> PLI;
typedef pair<lld, lld> PLL;

const int INF = (1LL << 31) - 1;
const lld LINF = (1LL << 62) - 1;
const int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};
const int MOD = (int)(1e9) + 7;

const int NMAX = 100000 + 5;
const int MMAX = 100000 + 5;
const int KMAX = 100000 + 5;
const int PMAX = 100000 + 5;
const int LMAX = 100000 + 5;
const int VMAX = 100000 + 5;

lld t, a, b, n, i, tt, q, sol = 0;
lld A[NMAX];

int putere(lld b, lld a) {
    while(b != 1 && b % a == 0)
        b /= a;
    return b == 1;
}

int main() {

#ifndef ONLINE_JUDGE
    freopen(inputFile.c_str(), "r", stdin);
    freopen(outputFile.c_str(), "w", stdout);
#endif

    scanf("%lld%lld%lld", &t, &a, &b);

    if(t != 1) {
        if(a == b)
            sol++;

        for(n = 0; b; n++) {
            A[n] = b % a;
            b /= a;
        }

        for(i = q = 0, tt = 1; i < n; i++) {
            q += A[i] * tt;
            tt *= t;
            if(q < 0 || q > a)
                break;
        }

        if(q == a)
            sol++;

        printf("%lld", sol);
    } else {
        if(a == 1 && b == 1)
            printf("inf");
        else if(putere(b, a))
            printf("1");
        else
            printf("0");
    }

    return 0;
}


#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

#define dbg(x) (cout<<#x<<" = "<<(x)<<'\n')
#ifdef HOME
const string inputFile = "input.txt";
const string outputFile = "output.txt";
#else
const string problemName = "";
const string inputFile = problemName + ".in";
const string outputFile = problemName + ".out";
#endif

typedef long long int lld;
typedef pair<int, int> PII;
typedef pair<int, lld> PIL;
typedef pair<lld, int> PLI;
typedef pair<lld, lld> PLL;

const int INF = (1LL << 31) - 1;
const lld LINF = (1LL << 62) - 1;
const int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};
const int MOD = (int)(1e9) + 7;

const int NMAX = 100000 + 5;
const int MMAX = 100000 + 5;
const int KMAX = 100000 + 5;
const int PMAX = 100000 + 5;
const int LMAX = 100000 + 5;
const int VMAX = 100000 + 5;

lld t, a, b, n, i, tt, q, sol = 0;
lld A[NMAX];

int putere(lld b, lld a) {
    if(a == 1 && b != 1)
        return 0;
    while(b != 1 && b % a == 0)
        b /= a;
    return b == 1;
}

int main() {

#ifndef ONLINE_JUDGE
    freopen(inputFile.c_str(), "r", stdin);
    freopen(outputFile.c_str(), "w", stdout);
#endif

    scanf("%lld%lld%lld", &t, &a, &b);

    if(t != 1 || (t == 1 && !putere(b, a))) {
        if(a == b)
            sol++;

        for(n = 0; b && a > 1; n++) {
            A[n] = b % a;
            b /= a;
        }

        for(i = q = 0, tt = 1; i < n; i++) {
            q += A[i] * tt;
            tt *= t;
            if(q < 0 || q > a)
                break;
        }

        if(q == a)
            sol++;

        printf("%lld", sol);
    } else {
        if(a == 1 && b == 1)
            printf("inf");
        else
            printf("%d", putere(b, a));
    }

    return 0;
}


#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

#define dbg(x) (cout<<#x<<" = "<<(x)<<'\n')
#ifdef HOME
const string inputFile = "input.txt";
const string outputFile = "output.txt";
#else
const string problemName = "";
const string inputFile = problemName + ".in";
const string outputFile = problemName + ".out";
#endif

typedef long long int lld;
typedef pair<int, int> PII;
typedef pair<int, lld> PIL;
typedef pair<lld, int> PLI;
typedef pair<lld, lld> PLL;

const int INF = (1LL << 31) - 1;
const lld LINF = (1LL << 62) - 1;
const int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};
const int MOD = (int)(1e9) + 7;

const int NMAX = 100000 + 5;
const int MMAX = 100000 + 5;
const int KMAX = 100000 + 5;
const int PMAX = 100000 + 5;
const int LMAX = 100000 + 5;
const int VMAX = 100000 + 5;

lld t, a, b, n, i, tt, q, sol = 0;
lld A[NMAX];

int putere(lld b, lld a) {
    while(b != 1 && b % a == 0)
        b /= a;
    return b == 1;
}

int main() {

#ifndef ONLINE_JUDGE
    freopen(inputFile.c_str(), "r", stdin);
    freopen(outputFile.c_str(), "w", stdout);
#endif

    scanf("%lld%lld%lld", &t, &a, &b);

    if(t != 1 || (t == 1 && !putere(b, a))) {
        if(a == b)
            sol++;

        for(n = 0; b && a > 1; n++) {
            A[n] = b % a;
            b /= a;
        }

        for(i = q = 0, tt = 1; i < n; i++) {
            q += A[i] * tt;
            tt *= t;
            if(q < 0 || q > a)
                break;
        }

        if(q == a)
            sol++;

        printf("%lld", sol);
    } else {
        if(a == 1 && b == 1)
            printf("inf");
        else
            printf("%d", putere(b, a));
    }

    return 0;
}


#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

#define dbg(x) (cout<<#x<<" = "<<(x)<<'\n')
#ifdef HOME
const string inputFile = "input.txt";
const string outputFile = "output.txt";
#else
const string problemName = "";
const string inputFile = problemName + ".in";
const string outputFile = problemName + ".out";
#endif

typedef long long int lld;
typedef pair<int, int> PII;
typedef pair<int, lld> PIL;
typedef pair<lld, int> PLI;
typedef pair<lld, lld> PLL;

const int INF = (1LL << 31) - 1;
const lld LINF = (1LL << 62) - 1;
const int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};
const int MOD = (int)(1e9) + 7;

const int NMAX = 100000 + 5;
const int MMAX = 100000 + 5;
const int KMAX = 100000 + 5;
const int PMAX = 100000 + 5;
const int LMAX = 100000 + 5;
const int VMAX = 100000 + 5;

lld t, a, b, n, i, tt, q, sol = 0;
lld A[NMAX];

int putere(lld b, lld a) {
    while(b != 1 && b % a == 0)
        b /= a;
    return b == 1;
}

int main() {

#ifndef ONLINE_JUDGE
    freopen(inputFile.c_str(), "r", stdin);
    freopen(outputFile.c_str(), "w", stdout);
#endif

    scanf("%lld%lld%lld", &t, &a, &b);

    if(t != 1 || (t == 1 && !putere(b, a))) {
        if(a == b)
            sol++;

        for(n = 0; b; n++) {
            A[n] = b % a;
            b /= a;
        }

        for(i = q = 0, tt = 1; i < n; i++) {
            q += A[i] * tt;
            tt *= t;
            if(q < 0 || q > a)
                break;
        }

        if(q == a)
            sol++;

        printf("%lld", sol);
    } else {
        if(a == 1 && b == 1)
            printf("inf");
        else
            printf("%d", putere(b, a));
    }

    return 0;
}


#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

#define dbg(x) (cout<<#x<<" = "<<(x)<<'\n')
#ifdef HOME
const string inputFile = "input.txt";
const string outputFile = "output.txt";
#else
const string problemName = "";
const string inputFile = problemName + ".in";
const string outputFile = problemName + ".out";
#endif

typedef long long int lld;
typedef pair<int, int> PII;
typedef pair<int, lld> PIL;
typedef pair<lld, int> PLI;
typedef pair<lld, lld> PLL;

const int INF = (1LL << 31) - 1;
const lld LINF = (1LL << 62) - 1;
const int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};
const int MOD = (int)(1e9) + 7;

const int NMAX = 100000 + 5;
const int MMAX = 100000 + 5;
const int KMAX = 100000 + 5;
const int PMAX = 100000 + 5;
const int LMAX = 100000 + 5;
const int VMAX = 100000 + 5;

lld t, a, b, n, i, tt, q, sol = 0;
lld A[NMAX];

int putere(lld b, lld a) {
    if(a == 1 && b != 1)
        return 0;
    if(a != 1 && b == 1)
        return 0;
    while(b != 1 && b % a == 0)
        b /= a;
    return b == 1;
}

int main() {

#ifndef ONLINE_JUDGE
    freopen(inputFile.c_str(), "r", stdin);
    freopen(outputFile.c_str(), "w", stdout);
#endif

    scanf("%lld%lld%lld", &t, &a, &b);

    if(t != 1 || (t == 1 && !putere(b, a))) {
        if(a == b)
            sol++;

        for(n = 0; b && a > 1; n++) {
            A[n] = b % a;
            b /= a;
        }

        for(i = q = 0, tt = 1; i < n; i++) {
            q += A[i] * tt;
            tt *= t;
            if(q < 0 || q > a)
                break;
        }

        if(q == a)
            sol++;

        printf("%lld", sol);
    } else {
        if(a == 1 && b == 1)
            printf("inf");
        else
            printf("%d", putere(b, a));
    }

    return 0;
}


#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(ll i=0;i<(ll)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;

ll t, a, b;
long double x[2][60];
ll dfs(int co, ll re1, ll re2){
	if(co == 1){
		if(t == a || (re1-re2) % (t-a)) return 0;
		ll i = (re1 - re2) / (t-a);
		return !(re1 - i*t < 0 || re2 - i*a < 0 || i < 0);
	}
	ll ans = 0;-- co;
	while(re1 >= 0 && re2 >= 0){
		ans += dfs(co, re1, re2);
		re1 -= x[0][co]; re2 -= x[1][co];
	}
	return ans;
}

main(){
	cin >> t >> a >> b;
	if(t == 1 && a == 1 && b == 1){
		puts("inf");
		return 0;
	}
	if(t == a && a == b){
		puts("2");
		return 0;
	}
	if(t == a){
		puts("0");
		return 0;
	}
	REP(i, 60){
		x[0][i] = powl(t, i);
		x[1][i] = powl(a, i);
	}
	cout << dfs(59, a, b) << endl;
	return 0;
}


#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(ll i=0;i<(ll)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;

ll t, a, b;
long double x[2][60];
ll dfs(int co, ll re1, ll re2){
	if(co == 1){
		if(t == a || (re1-re2) % (t-a)) return 0;
		ll i = (re1 - re2) / (t-a);
		return !(re1 - i*t < 0 || re2 - i*a < 0 || i < 0);
	}
	ll ans = 0;
	while(re1 >= 0 && re2 >= 0){
		if(dfs(co-1, re1, re2)) return 1;
		re1 -= x[0][co]; re2 -= x[1][co];
	}
	return 0;
}

main(){
	cin >> t >> a >> b;
	if(t == 1 && a == 1 && b == 1){
		puts("inf");
		return 0;
	}
	if(t == a && a == b){
		puts("2");
		return 0;
	}
	if(t == a){
		puts("0");
		return 0;
	}
	REP(i, 60){
		x[0][i] = powl(t, i);
		x[1][i] = powl(a, i);
	}
	cout << dfs(59, a, b) << endl;
	return 0;
}


#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(ll i=0;i<(ll)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;

ll t, a, b;

ll dfs(int co, ll re1, ll re2){
	if(co == 0) return re1 == re2;
	if(co == 1){
		if(t == a || (re1-re2) % (t-a)) return 0;
		ll i = (re1 - re2) / (t-a);
		if(re1 - i*t < 0 || re2 - i*a < 0 || i < 0) return 0;
		return 1;
	}
	ll ans = 0;
	REP(i, 1ll<<60){
		if(i*powl(t, co) > re1 || i*powl(a, co) > re2) break;
		ans += dfs(co - 1, re1 - i*powl(t, co), re2 - i*powl(a, co));
	}
	return ans;
}

main(){
	cin >> t >> a >> b;
	if(t == 1 && a == 1 && b == 1){
		puts("inf");
		return 0;
	}
	if(t == a && a == b){
		puts("2");
		return 0;
	}
	if(t == a){
		puts("0");
		return 0;
	}
	cout << dfs(59, a, b) << endl;
	return 0;
}


#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(ll i=0;i<(ll)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;

ll t, a, b;
long double x[2][60];
ll dfs(int co, ll re1, ll re2){
	if(co == 1){
		if(t == a || (re1-re2) % (t-a)) return 0;
		ll i = (re1 - re2) / (t-a);
		return !(re1 - i*t < 0 || re2 - i*a < 0 || i < 0);
	}
	ll ans = 0;
	while(re1 >= 0 && re2 >= 0){
		ans += dfs(co-1, re1, re2);
		re1 -= x[0][co]; re2 -= x[1][co];
	}
	return ans;
}

main(){
	cin >> t >> a >> b;
	if(t == 1 && a == 1 && b == 1){
		puts("inf");
		return 0;
	}
	if(t == a && a == b){
		puts("2");
		return 0;
	}
	if(t == a){
		puts("0");
		return 0;
	}
	REP(i, 60){
		x[0][i] = powl(t, i);
		x[1][i] = powl(a, i);
	}
	cout << dfs(59, a, b) << endl;
	return 0;
}


#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(ll i=0;i<(ll)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;

ll t, a, b;
long double x[2][60];
ll dfs(int co, ll re1, ll re2){
	if(co == 1){
		if(t == a || (re1-re2) % (t-a)) return 0;
		ll i = (re1 - re2) / (t-a);
		return !(re1 - i*t < 0 || re2 - i*a < 0 || i < 0);
	}
	ll ans = 0;
	REP(i, 1ll<<60){
		if(i*x[0][co] > re1 || i*x[1][co] > re2) break;
		ans += dfs(co - 1, re1 - i*powl(t, co), re2 - i*powl(a, co));
	}
	return ans;
}

main(){
	cin >> t >> a >> b;
	if(t == 1 && a == 1 && b == 1){
		puts("inf");
		return 0;
	}
	if(t == a && a == b){
		puts("2");
		return 0;
	}
	if(t == a){
		puts("0");
		return 0;
	}
	REP(i, 60){
		x[0][i] = powl(t, i);
		x[1][i] = powl(a, i);
	}
	cout << dfs(59, a, b) << endl;
	return 0;
}


#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(ll i=0;i<(ll)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;

ll t, a, b;

ll dfs(int co, ll re1, ll re2){
	if(co == 0) return re1 == re2;
	ll ans = 0;
	REP(i, 1ll<<60){
		if(i*powl(t, co) > re1 || i*powl(a, co) > re2) break;
		ans += dfs(co - 1, re1 - i*powl(t, co), re2 - i*powl(a, co));
	}
	return ans;
}

main(){
	cin >> t >> a >> b;
	if(t == 1 && a == 1 && b == 1){
		puts("inf");
		return 0;
	}
	cout << dfs(7, a, b) << endl;
	return 0;
}


/**
 * Copyright (c) 2015 Authors. All rights reserved.
 *
 * FileName: E.cpp
 * Author: Beiyu Li <sysulby@gmail.com>
 * Date: 2015-02-01
 */
#include <bits/stdc++.h>

using namespace std;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define For(i,s,t) for (int i = (s); i <= (t); ++i)
#define foreach(i,c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); ++i)

typedef long long LL;
typedef pair<int, int> Pii;

const int inf = 0x3f3f3f3f;
const LL infLL = 0x3f3f3f3f3f3f3f3fLL;

LL t, a, b;

bool is_pow(LL b, LL a) { while (b % a == 0) b /= a; return b == 1; }

void solve()
{
        if (a < t) {
                cout << (b == a) << endl;
        } else if (a == t) {
                if (b != a) cout << 0 << endl;
                else cout << (b == 1? "inf": "2") << endl;
        } else if (b <= a) {
                cout << (b == a) << endl;
        } else if (t == 1 && is_pow(b, a)) {
                cout << 1 << endl;
        } else {
                LL v = a;
                while (b) {
                        if (v < b % a) {
                                cout << 0 << endl;
                                return;
                        }
                        v -= b % a; b -= b % a;
                        if (!b) break;
                        while (b % a == 0) {
                                if (v % t != 0) {
                                        cout << 0 << endl;
                                        return;
                                }
                                v /= t; b /= a;
                        }
                }
                cout << (v? 0: 1) << endl;
        }
}

int main()
{
        cin >> t >> a >> b;
        solve();

        return 0;
}


/**
 * Copyright (c) 2015 Authors. All rights reserved.
 *
 * FileName: E.cpp
 * Author: Beiyu Li <sysulby@gmail.com>
 * Date: 2015-02-01
 */
#include <bits/stdc++.h>

using namespace std;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define For(i,s,t) for (int i = (s); i <= (t); ++i)
#define foreach(i,c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); ++i)

typedef long long LL;
typedef pair<int, int> Pii;

const int inf = 0x3f3f3f3f;
const LL infLL = 0x3f3f3f3f3f3f3f3fLL;

LL t, a, b;

bool is_pow(LL b, LL a) { while (b % a == 0) b /= a; return b == 1; }

void solve()
{
        if (a < t) {
                cout << (b == a) << endl;
        } else if (a == t) {
                if (b != a) cout << 0 << endl;
                else cout << (b == 1? "inf": "2") << endl;
        } else if (b <= a) {
                cout << (b == a) << endl;
        } else {
                LL v = a;
                while (b) {
                        if (v < b % a) {
                                cout << 0 << endl;
                                return;
                        }
                        v -= b % a; b -= b % a;
                        if (!b) break;
                        while (b % a == 0) {
                                if (v % t != 0) {
                                        cout << 0 << endl;
                                        return;
                                }
                                v /= t; b /= a;
                        }
                }
                cout << (v? 0: 1) << endl;
        }
}

int main()
{
        cin >> t >> a >> b;
        solve();

        return 0;
}


#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <algorithm>
#include <locale>
#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <climits>
#include <iomanip>
#include <bitset>
#include <list>
#include <deque>

using namespace std;

#define all(a)              (a).begin(), (a).end()
#define ms(a,b)             memset(a, b, sizeof(a))
#define mp                  make_pair
#define pb                  push_back
#define fore(it,a)          for (auto it = (a).begin(), it##_ = (a).end(); it != it##_; it++)
#define f0r(i, a)           for (int i = 0, end = (a); i < end; i++)
#define debug(args...)      do {cerr << #args << ": "; dbg,args; cerr << endl;} while(0)
#define read(type, args...) type args; rdr,args;
#define fi                  first
#define se                  second
#define bit_no              __builtin_popcount
#define left(a)             (2*(a))
#define right(a)            (2*(a)+1)
#define mid(left, right)    (((left)+(right))/2+1)

typedef long long           ll;
typedef long double         ld;
typedef unsigned long long  ull;
typedef vector<int>         vi;
typedef vector<vi>          vvi;
typedef pair<int, int>      ii;
typedef vector<ii>          vii;

const int inf = 2e8+5;
const ll l_inf = 9e18+5;

template<typename T>
inline T mod(T a, T b)
{
    return (a % b + b) % b;
}

template<typename T,typename T2>
ostream& operator<< (ostream &s, const pair<T,T2> &p) {return s << p.fi << ' ' << p.se << ' ';}

template<typename T,typename T2>
istream& operator>> (istream &s, pair<T,T2> &p) {return s >> p.fi >> p.se;}

template<typename T>
ostream& operator<< (ostream &s, const vector<T> &v)  {for (auto it: v) s << it << ' '; return s;}

template<typename T>
istream& operator>> (istream &s, vector<T> &v) {fore (it, v) s >> *it; return s;}

template<typename T>
void read_range(T beg, T end)
{
    while (beg != end)
        cin >> *beg++;
}

template<typename T>
void print_range(T beg, T end)
{
    while (beg != end)
        cout << *beg++ << ' ';
}

struct reader
{
    template<typename T>
    reader& operator, (T &v)
    {
        cin >> v;
        return *this;
    }
} rdr;

struct debugger
{
    template<typename T>
    debugger& operator, (const T &v)
    {
        cerr << v << ", ";
        return *this;
    }
} dbg;

int main()
{
    ios_base::sync_with_stdio(false);

    read(ll, t, n, m);

    if (t == 1 and n == 1 and m == 1)
        cout << "inf";
    else if (t == 1 and n == 1)
        cout << 0;
    else if (t == 1 and floor(log(m)/log(n)) == log(m)/log(n) and log(m) != 0)
        cout << 1;
    else {
        int cnt = (n == m);
        ll sum = 0;
        ll p = 1;
        while (m) {
            sum += p * (m % n);
            m /= n;
            p *= t;
        }
        cnt += (sum == n);
        cout << cnt;
    }

    return 0;
}


#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <algorithm>
#include <locale>
#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <climits>
#include <iomanip>
#include <bitset>
#include <list>
#include <deque>

using namespace std;

#define all(a)              (a).begin(), (a).end()
#define ms(a,b)             memset(a, b, sizeof(a))
#define mp                  make_pair
#define pb                  push_back
#define fore(it,a)          for (auto it = (a).begin(), it##_ = (a).end(); it != it##_; it++)
#define f0r(i, a)           for (int i = 0, end = (a); i < end; i++)
#define debug(args...)      do {cerr << #args << ": "; dbg,args; cerr << endl;} while(0)
#define read(type, args...) type args; rdr,args;
#define fi                  first
#define se                  second
#define bit_no              __builtin_popcount
#define left(a)             (2*(a))
#define right(a)            (2*(a)+1)
#define mid(left, right)    (((left)+(right))/2+1)

typedef long long           ll;
typedef long double         ld;
typedef unsigned long long  ull;
typedef vector<int>         vi;
typedef vector<vi>          vvi;
typedef pair<int, int>      ii;
typedef vector<ii>          vii;

const int inf = 2e8+5;
const ll l_inf = 9e18+5;

template<typename T>
inline T mod(T a, T b)
{
    return (a % b + b) % b;
}

template<typename T,typename T2>
ostream& operator<< (ostream &s, const pair<T,T2> &p) {return s << p.fi << ' ' << p.se << ' ';}

template<typename T,typename T2>
istream& operator>> (istream &s, pair<T,T2> &p) {return s >> p.fi >> p.se;}

template<typename T>
ostream& operator<< (ostream &s, const vector<T> &v)  {for (auto it: v) s << it << ' '; return s;}

template<typename T>
istream& operator>> (istream &s, vector<T> &v) {fore (it, v) s >> *it; return s;}

template<typename T>
void read_range(T beg, T end)
{
    while (beg != end)
        cin >> *beg++;
}

template<typename T>
void print_range(T beg, T end)
{
    while (beg != end)
        cout << *beg++ << ' ';
}

struct reader
{
    template<typename T>
    reader& operator, (T &v)
    {
        cin >> v;
        return *this;
    }
} rdr;

struct debugger
{
    template<typename T>
    debugger& operator, (const T &v)
    {
        cerr << v << ", ";
        return *this;
    }
} dbg;

int main()
{
    ios_base::sync_with_stdio(false);

    read(ll, t, n, m);

    if (t == 1 and n == 1 and m == 1)
        cout << "inf";
    else if (t == 1 and n == 1)
        cout << 0;
    else if (t == 1 and abs(trunc(log(m)/log(n))-log(m)/log(n)) < 0.000000000001 and m != 0)
        cout << 1;
    else {
        int cnt = (n == m);
        ll sum = 0;
        ll p = 1;
        if (n >= t) {
            while (m) {
                sum += p * (m % n);
                m /= n;
                p *= t;
            }
            cnt += (sum == n);
        }
        cout << cnt;
    }

    return 0;
}


#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <algorithm>
#include <locale>
#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <climits>
#include <iomanip>
#include <bitset>
#include <list>
#include <deque>

using namespace std;

#define all(a)              (a).begin(), (a).end()
#define ms(a,b)             memset(a, b, sizeof(a))
#define mp                  make_pair
#define pb                  push_back
#define fore(it,a)          for (auto it = (a).begin(), it##_ = (a).end(); it != it##_; it++)
#define f0r(i, a)           for (int i = 0, end = (a); i < end; i++)
#define debug(args...)      do {cerr << #args << ": "; dbg,args; cerr << endl;} while(0)
#define read(type, args...) type args; rdr,args;
#define fi                  first
#define se                  second
#define bit_no              __builtin_popcount
#define left(a)             (2*(a))
#define right(a)            (2*(a)+1)
#define mid(left, right)    (((left)+(right))/2+1)

typedef long long           ll;
typedef long double         ld;
typedef unsigned long long  ull;
typedef vector<int>         vi;
typedef vector<vi>          vvi;
typedef pair<int, int>      ii;
typedef vector<ii>          vii;

const int inf = 2e8+5;
const ll l_inf = 9e18+5;

template<typename T>
inline T mod(T a, T b)
{
    return (a % b + b) % b;
}

template<typename T,typename T2>
ostream& operator<< (ostream &s, const pair<T,T2> &p) {return s << p.fi << ' ' << p.se << ' ';}

template<typename T,typename T2>
istream& operator>> (istream &s, pair<T,T2> &p) {return s >> p.fi >> p.se;}

template<typename T>
ostream& operator<< (ostream &s, const vector<T> &v)  {for (auto it: v) s << it << ' '; return s;}

template<typename T>
istream& operator>> (istream &s, vector<T> &v) {fore (it, v) s >> *it; return s;}

template<typename T>
void read_range(T beg, T end)
{
    while (beg != end)
        cin >> *beg++;
}

template<typename T>
void print_range(T beg, T end)
{
    while (beg != end)
        cout << *beg++ << ' ';
}

struct reader
{
    template<typename T>
    reader& operator, (T &v)
    {
        cin >> v;
        return *this;
    }
} rdr;

struct debugger
{
    template<typename T>
    debugger& operator, (const T &v)
    {
        cerr << v << ", ";
        return *this;
    }
} dbg;

int main()
{
    ios_base::sync_with_stdio(false);

    read(ll, t, n, m);

    bool power = true;
    ll temp = m;
    while (temp)
        if (temp % n) {
            power = false;
            break;
        }
        else if (temp == n)
            break;
        else
            temp /= n;

    if (t == 1 and n == 1 and m == 1)
        cout << "inf";
    else if (t == 1 and n == 1)
        cout << 0;
    else if (t == 1 and power and m != 1)
        cout << 1;
    else {
        int cnt = (n == m);
        ll sum = 0;
        ll p = 1;
        if (n >= t) {
            while (m) {
                sum += p * (m % n);
                m /= n;
                p *= t;
            }
            cnt += (sum == n);
        }
        cout << cnt;
    }

    return 0;
}


#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <algorithm>
#include <locale>
#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <climits>
#include <iomanip>
#include <bitset>
#include <list>
#include <deque>

using namespace std;

#define all(a)              (a).begin(), (a).end()
#define ms(a,b)             memset(a, b, sizeof(a))
#define mp                  make_pair
#define pb                  push_back
#define fore(it,a)          for (auto it = (a).begin(), it##_ = (a).end(); it != it##_; it++)
#define f0r(i, a)           for (int i = 0, end = (a); i < end; i++)
#define debug(args...)      do {cerr << #args << ": "; dbg,args; cerr << endl;} while(0)
#define read(type, args...) type args; rdr,args;
#define fi                  first
#define se                  second
#define bit_no              __builtin_popcount
#define left(a)             (2*(a))
#define right(a)            (2*(a)+1)
#define mid(left, right)    (((left)+(right))/2+1)

typedef long long           ll;
typedef long double         ld;
typedef unsigned long long  ull;
typedef vector<int>         vi;
typedef vector<vi>          vvi;
typedef pair<int, int>      ii;
typedef vector<ii>          vii;

const int inf = 2e8+5;
const ll l_inf = 9e18+5;

template<typename T>
inline T mod(T a, T b)
{
    return (a % b + b) % b;
}

template<typename T,typename T2>
ostream& operator<< (ostream &s, const pair<T,T2> &p) {return s << p.fi << ' ' << p.se << ' ';}

template<typename T,typename T2>
istream& operator>> (istream &s, pair<T,T2> &p) {return s >> p.fi >> p.se;}

template<typename T>
ostream& operator<< (ostream &s, const vector<T> &v)  {for (auto it: v) s << it << ' '; return s;}

template<typename T>
istream& operator>> (istream &s, vector<T> &v) {fore (it, v) s >> *it; return s;}

template<typename T>
void read_range(T beg, T end)
{
    while (beg != end)
        cin >> *beg++;
}

template<typename T>
void print_range(T beg, T end)
{
    while (beg != end)
        cout << *beg++ << ' ';
}

struct reader
{
    template<typename T>
    reader& operator, (T &v)
    {
        cin >> v;
        return *this;
    }
} rdr;

struct debugger
{
    template<typename T>
    debugger& operator, (const T &v)
    {
        cerr << v << ", ";
        return *this;
    }
} dbg;

int main()
{
    ios_base::sync_with_stdio(false);

    read(ll, t, n, m);

    if (t == 1 and n == 1 and m == 1)
        cout << "inf";
    else if (t == 1 and n == 1)
        cout << 0;
    else if (t == 1 and abs(floor(log(m)/log(n)) - log(m)/log(n)) < 1 and m != 0)
        cout << 1;
    else {
        int cnt = (n == m);
        ll sum = 0;
        ll p = 1;
        while (m) {
            sum += p * (m % n);
            m /= n;
            p *= t;
        }
        cnt += (sum == n);
        cout << cnt;
    }

    return 0;
}


#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <algorithm>
#include <locale>
#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <climits>
#include <iomanip>
#include <bitset>
#include <list>
#include <deque>

using namespace std;

#define all(a)              (a).begin(), (a).end()
#define ms(a,b)             memset(a, b, sizeof(a))
#define mp                  make_pair
#define pb                  push_back
#define fore(it,a)          for (auto it = (a).begin(), it##_ = (a).end(); it != it##_; it++)
#define f0r(i, a)           for (int i = 0, end = (a); i < end; i++)
#define debug(args...)      do {cerr << #args << ": "; dbg,args; cerr << endl;} while(0)
#define read(type, args...) type args; rdr,args;
#define fi                  first
#define se                  second
#define bit_no              __builtin_popcount
#define left(a)             (2*(a))
#define right(a)            (2*(a)+1)
#define mid(left, right)    (((left)+(right))/2+1)

typedef long long           ll;
typedef long double         ld;
typedef unsigned long long  ull;
typedef vector<int>         vi;
typedef vector<vi>          vvi;
typedef pair<int, int>      ii;
typedef vector<ii>          vii;

const int inf = 2e8+5;
const ll l_inf = 9e18+5;

template<typename T>
inline T mod(T a, T b)
{
    return (a % b + b) % b;
}

template<typename T,typename T2>
ostream& operator<< (ostream &s, const pair<T,T2> &p) {return s << p.fi << ' ' << p.se << ' ';}

template<typename T,typename T2>
istream& operator>> (istream &s, pair<T,T2> &p) {return s >> p.fi >> p.se;}

template<typename T>
ostream& operator<< (ostream &s, const vector<T> &v)  {for (auto it: v) s << it << ' '; return s;}

template<typename T>
istream& operator>> (istream &s, vector<T> &v) {fore (it, v) s >> *it; return s;}

template<typename T>
void read_range(T beg, T end)
{
    while (beg != end)
        cin >> *beg++;
}

template<typename T>
void print_range(T beg, T end)
{
    while (beg != end)
        cout << *beg++ << ' ';
}

struct reader
{
    template<typename T>
    reader& operator, (T &v)
    {
        cin >> v;
        return *this;
    }
} rdr;

struct debugger
{
    template<typename T>
    debugger& operator, (const T &v)
    {
        cerr << v << ", ";
        return *this;
    }
} dbg;

int main()
{
    ios_base::sync_with_stdio(false);

    read(ll, t, n, m);

    if (t == 1 and n == 1 and m == 1)
        cout << "inf";
    else if (t == 1 and n == 1)
        cout << 0;
    else if (t == 1 and abs(round(log(m)/log(n))-log(m)/log(n)) < 0.000000000001 and m != 1)
        cout << 1;
    else {
        int cnt = (n == m);
        ll sum = 0;
        ll p = 1;
        if (n >= t) {
            while (m) {
                sum += p * (m % n);
                m /= n;
                p *= t;
            }
            cnt += (sum == n);
        }
        cout << cnt;
    }

    return 0;
}


#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <algorithm>
#include <locale>
#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <climits>
#include <iomanip>
#include <bitset>
#include <list>
#include <deque>

using namespace std;

#define all(a)              (a).begin(), (a).end()
#define ms(a,b)             memset(a, b, sizeof(a))
#define mp                  make_pair
#define pb                  push_back
#define fore(it,a)          for (auto it = (a).begin(), it##_ = (a).end(); it != it##_; it++)
#define f0r(i, a)           for (int i = 0, end = (a); i < end; i++)
#define debug(args...)      do {cerr << #args << ": "; dbg,args; cerr << endl;} while(0)
#define read(type, args...) type args; rdr,args;
#define fi                  first
#define se                  second
#define bit_no              __builtin_popcount
#define left(a)             (2*(a))
#define right(a)            (2*(a)+1)
#define mid(left, right)    (((left)+(right))/2+1)

typedef long long           ll;
typedef long double         ld;
typedef unsigned long long  ull;
typedef vector<int>         vi;
typedef vector<vi>          vvi;
typedef pair<int, int>      ii;
typedef vector<ii>          vii;

const int inf = 2e8+5;
const ll l_inf = 9e18+5;

template<typename T>
inline T mod(T a, T b)
{
    return (a % b + b) % b;
}

template<typename T,typename T2>
ostream& operator<< (ostream &s, const pair<T,T2> &p) {return s << p.fi << ' ' << p.se << ' ';}

template<typename T,typename T2>
istream& operator>> (istream &s, pair<T,T2> &p) {return s >> p.fi >> p.se;}

template<typename T>
ostream& operator<< (ostream &s, const vector<T> &v)  {for (auto it: v) s << it << ' '; return s;}

template<typename T>
istream& operator>> (istream &s, vector<T> &v) {fore (it, v) s >> *it; return s;}

template<typename T>
void read_range(T beg, T end)
{
    while (beg != end)
        cin >> *beg++;
}

template<typename T>
void print_range(T beg, T end)
{
    while (beg != end)
        cout << *beg++ << ' ';
}

struct reader
{
    template<typename T>
    reader& operator, (T &v)
    {
        cin >> v;
        return *this;
    }
} rdr;

struct debugger
{
    template<typename T>
    debugger& operator, (const T &v)
    {
        cerr << v << ", ";
        return *this;
    }
} dbg;

int main()
{
    ios_base::sync_with_stdio(false);

    read(ll, t, n, m);

    if (t == 1 and n == 1 and m == 1)
        cout << "inf";
    else if (t == 1 and n == 1)
        cout << 0;
    else if (t == 1 and abs(trunc(log(m)/log(n))-log(m)/log(n)) < 0.000000000001 and m != 0)
        cout << 1;
    else {
        int cnt = (n == m);
        ll sum = 0;
        ll p = 1;
        while (m) {
            sum += p * (m % n);
            m /= n;
            p *= t;
        }
        cnt += (sum == n);
        cout << cnt;
    }

    return 0;
}


#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <algorithm>
#include <locale>
#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <climits>
#include <iomanip>
#include <bitset>
#include <list>
#include <deque>

using namespace std;

#define all(a)              (a).begin(), (a).end()
#define ms(a,b)             memset(a, b, sizeof(a))
#define mp                  make_pair
#define pb                  push_back
#define fore(it,a)          for (auto it = (a).begin(), it##_ = (a).end(); it != it##_; it++)
#define f0r(i, a)           for (int i = 0, end = (a); i < end; i++)
#define debug(args...)      do {cerr << #args << ": "; dbg,args; cerr << endl;} while(0)
#define read(type, args...) type args; rdr,args;
#define fi                  first
#define se                  second
#define bit_no              __builtin_popcount
#define left(a)             (2*(a))
#define right(a)            (2*(a)+1)
#define mid(left, right)    (((left)+(right))/2+1)

typedef long long           ll;
typedef long double         ld;
typedef unsigned long long  ull;
typedef vector<int>         vi;
typedef vector<vi>          vvi;
typedef pair<int, int>      ii;
typedef vector<ii>          vii;

const int inf = 2e8+5;
const ll l_inf = 9e18+5;

template<typename T>
inline T mod(T a, T b)
{
    return (a % b + b) % b;
}

template<typename T,typename T2>
ostream& operator<< (ostream &s, const pair<T,T2> &p) {return s << p.fi << ' ' << p.se << ' ';}

template<typename T,typename T2>
istream& operator>> (istream &s, pair<T,T2> &p) {return s >> p.fi >> p.se;}

template<typename T>
ostream& operator<< (ostream &s, const vector<T> &v)  {for (auto it: v) s << it << ' '; return s;}

template<typename T>
istream& operator>> (istream &s, vector<T> &v) {fore (it, v) s >> *it; return s;}

template<typename T>
void read_range(T beg, T end)
{
    while (beg != end)
        cin >> *beg++;
}

template<typename T>
void print_range(T beg, T end)
{
    while (beg != end)
        cout << *beg++ << ' ';
}

struct reader
{
    template<typename T>
    reader& operator, (T &v)
    {
        cin >> v;
        return *this;
    }
} rdr;

struct debugger
{
    template<typename T>
    debugger& operator, (const T &v)
    {
        cerr << v << ", ";
        return *this;
    }
} dbg;

int main()
{
    ios_base::sync_with_stdio(false);

    read(ll, t, n, m);

    if (t == 1 and n == 1 and m == 1)
        cout << "inf";
    else if (t == 1 and n == 1)
        cout << 0;
    else if (t == 1 and abs(trunc(log(m)/log(n))-log(m)/log(n)) < 0.000000000001 and m != 1)
        cout << 1;
    else {
        int cnt = (n == m);
        ll sum = 0;
        ll p = 1;
        if (n >= t) {
            while (m) {
                sum += p * (m % n);
                m /= n;
                p *= t;
            }
            cnt += (sum == n);
        }
        cout << cnt;
    }

    return 0;
}


#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <algorithm>
#include <locale>
#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <climits>
#include <iomanip>
#include <bitset>
#include <list>
#include <deque>

using namespace std;

#define all(a)              (a).begin(), (a).end()
#define ms(a,b)             memset(a, b, sizeof(a))
#define mp                  make_pair
#define pb                  push_back
#define fore(it,a)          for (auto it = (a).begin(), it##_ = (a).end(); it != it##_; it++)
#define f0r(i, a)           for (int i = 0, end = (a); i < end; i++)
#define debug(args...)      do {cerr << #args << ": "; dbg,args; cerr << endl;} while(0)
#define read(type, args...) type args; rdr,args;
#define fi                  first
#define se                  second
#define bit_no              __builtin_popcount
#define left(a)             (2*(a))
#define right(a)            (2*(a)+1)
#define mid(left, right)    (((left)+(right))/2+1)

typedef long long           ll;
typedef long double         ld;
typedef unsigned long long  ull;
typedef vector<int>         vi;
typedef vector<vi>          vvi;
typedef pair<int, int>      ii;
typedef vector<ii>          vii;

const int inf = 2e8+5;
const ll l_inf = 9e18+5;

template<typename T>
inline T mod(T a, T b)
{
    return (a % b + b) % b;
}

template<typename T,typename T2>
ostream& operator<< (ostream &s, const pair<T,T2> &p) {return s << p.fi << ' ' << p.se << ' ';}

template<typename T,typename T2>
istream& operator>> (istream &s, pair<T,T2> &p) {return s >> p.fi >> p.se;}

template<typename T>
ostream& operator<< (ostream &s, const vector<T> &v)  {for (auto it: v) s << it << ' '; return s;}

template<typename T>
istream& operator>> (istream &s, vector<T> &v) {fore (it, v) s >> *it; return s;}

template<typename T>
void read_range(T beg, T end)
{
    while (beg != end)
        cin >> *beg++;
}

template<typename T>
void print_range(T beg, T end)
{
    while (beg != end)
        cout << *beg++ << ' ';
}

struct reader
{
    template<typename T>
    reader& operator, (T &v)
    {
        cin >> v;
        return *this;
    }
} rdr;

struct debugger
{
    template<typename T>
    debugger& operator, (const T &v)
    {
        cerr << v << ", ";
        return *this;
    }
} dbg;

int main()
{
    ios_base::sync_with_stdio(false);

    read(ll, t, n, m);

    bool power = (n != 1);

    ll temp = m;
    while (temp)
        if (temp % n) {
            power = false;
            break;
        }
        else if (temp == n)
            break;
        else if (n == 1)
            break;
        else
            temp /= n;

    if (t == 1 and n == 1 and m == 1)
        cout << "inf";
    else if (t == 1 and n == 1)
        cout << 0;
    else if (t == 1 and power and m != 1)
        cout << 1;
    else {
        int cnt = (n == m);
        ll sum = 0;
        ll p = 1;
        if (n >= t) {
            while (m) {
                sum += p * (m % n);
                m /= n;
                p *= t;
            }
            cnt += (sum == n);
        }
        cout << cnt;
    }

    return 0;
}