#include <bits/stdc++.h>

#define REP(i, a) for(int i = 0; i < a; i++)
#define RFOR(i,x,y) for(int i = x; i>= y; i--)
#define FOR(i,x,y) for (int i = x; i < y; i++)
#define ITFOR(it,A) for(typeof A.begin() it = A.begin(); it!=A.end(); it++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define VE vector <int>
#define mset(A,x) memset(A, x, sizeof A)
#define PB push_back
#define ones(x) __builtin_popcount(x)
#define cua(x) (x)*(x)
#define debug(x) cout <<#x << " = " << x << endl
#define adebug(x,n) cout <<#x<<endl; REP(i,n)cout<<x[i]<<char(i+1==n?10:32)
#define mdebug(x,m,n) cout <<#x<<endl; REP(i,m)REP(j,n)cout<<x[i][j]<<char(j+1==n?10:32)
#define LSOne(S) (S&(-S))

using namespace std;

#define ll long long
#define lli long long int
#define PI acos(-1.0)
#define ii pair<int,int>
#define inf_ll (((1LL<<62)-1)<<1)+1
#define inf_i (1<<30)-1

int main(){
	set<lli> arr;
	lli b,q,l,m,num,cnt=0; scanf("%lld %lld %lld %lld",&b,&q,&l,&m);
	REP(i,m){
		scanf("%lld",&num);
		arr.insert(num);
	}
	if(arr.count(b)!=0) printf("0\n");
	else if(abs(q)==1||b==0) printf("inf\n");
	else if(q==0){
		if(arr.count(0)!=0) printf("1\n");
		else printf("0\n");
	}
	else {
		while(abs(b)<=l){
			if(arr.count(b)==0) cnt++;
			b*=q;
		}
		printf("%lld\n",cnt);
	}
  return 0;
}

/*
   freopen("input.txt", "r", stdin);
   freopen("out.txt", "w", stdout);
*/

/*
    fclose(stdin);
    fclose(stdout);
*/


#include <bits/stdc++.h>

#define REP(i, a) for(int i = 0; i < a; i++)
#define RFOR(i,x,y) for(int i = x; i>= y; i--)
#define FOR(i,x,y) for (int i = x; i < y; i++)
#define ITFOR(it,A) for(typeof A.begin() it = A.begin(); it!=A.end(); it++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define VE vector <int>
#define mset(A,x) memset(A, x, sizeof A)
#define PB push_back
#define ones(x) __builtin_popcount(x)
#define cua(x) (x)*(x)
#define debug(x) cout <<#x << " = " << x << endl
#define adebug(x,n) cout <<#x<<endl; REP(i,n)cout<<x[i]<<char(i+1==n?10:32)
#define mdebug(x,m,n) cout <<#x<<endl; REP(i,m)REP(j,n)cout<<x[i][j]<<char(j+1==n?10:32)
#define LSOne(S) (S&(-S))

using namespace std;

#define ll long long
#define lli long long int
#define PI acos(-1.0)
#define ii pair<int,int>
#define inf_ll (((1LL<<62)-1)<<1)+1
#define inf_i (1<<30)-1

int main(){
	set<lli> arr;
	lli b,q,l,m,num,cnt=0; scanf("%lld %lld %lld %lld",&b,&q,&l,&m);
	REP(i,m){
		scanf("%lld",&num);
		arr.insert(num);
	}
	if(abs(q)==1&&arr.count(b)!=0||b>l) printf("0\n");
	else if(abs(q)==1||b==0) printf("inf\n");
	else if(q==0){
		if(arr.count(0)!=0){
			if(arr.count(b)!=0) printf("0\n");
			else printf("1\n");
		}
		else printf("inf\n");
	}
	else {
		while(abs(b)<=l){
			if(arr.count(b)==0) cnt++;
			b*=q;
		}
		printf("%lld\n",cnt);
	}
  return 0;
}

/*
   freopen("input.txt", "r", stdin);
   freopen("out.txt", "w", stdout);
*/

/*
    fclose(stdin);
    fclose(stdout);
*/


#include <bits/stdc++.h>

#define REP(i, a) for(int i = 0; i < a; i++)
#define RFOR(i,x,y) for(int i = x; i>= y; i--)
#define FOR(i,x,y) for (int i = x; i < y; i++)
#define ITFOR(it,A) for(typeof A.begin() it = A.begin(); it!=A.end(); it++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define VE vector <int>
#define mset(A,x) memset(A, x, sizeof A)
#define PB push_back
#define ones(x) __builtin_popcount(x)
#define cua(x) (x)*(x)
#define debug(x) cout <<#x << " = " << x << endl
#define adebug(x,n) cout <<#x<<endl; REP(i,n)cout<<x[i]<<char(i+1==n?10:32)
#define mdebug(x,m,n) cout <<#x<<endl; REP(i,m)REP(j,n)cout<<x[i][j]<<char(j+1==n?10:32)
#define LSOne(S) (S&(-S))

using namespace std;

#define ll long long
#define lli long long int
#define PI acos(-1.0)
#define ii pair<int,int>
#define inf_ll (((1LL<<62)-1)<<1)+1
#define inf_i (1<<30)-1

int main(){
	set<lli> arr;
	lli b,q,l,m,num,cnt=0; scanf("%lld %lld %lld %lld",&b,&q,&l,&m);
	REP(i,m){
		scanf("%lld",&num);
		arr.insert(num);
	}
	if(abs(b)>l) printf("0\n");
	else if(b==0){
		if(arr.count(b)!=0) printf("0\n");
		else printf("inf\n");
	}
	else if(q==0){
		if(arr.count(0)!=0){
			if(arr.count(b)!=0) printf("0\n");
			else printf("1\n");
		}
		else printf("inf\n");
	}
	else if(abs(q)==1){
		if(q==1){
			if(arr.count(b)!=0) printf("0\n");
			else printf("inf\n");
		}
		if(q==-1){
			if(arr.count(-b)!=0&&arr.count(b)!=0) printf("0\n");
			else printf("inf\n");
		}
	}
	else{
		while(abs(b)<=l){
			if(arr.count(b)==0) cnt++;
			b*=q;
		}
		printf("%lld\n",cnt);
	}
  return 0;
}

/*
   freopen("input.txt", "r", stdin);
   freopen("out.txt", "w", stdout);
*/

/*
    fclose(stdin);
    fclose(stdout);
*/


#include <bits/stdc++.h>

#define REP(i, a) for(int i = 0; i < a; i++)
#define RFOR(i,x,y) for(int i = x; i>= y; i--)
#define FOR(i,x,y) for (int i = x; i < y; i++)
#define ITFOR(it,A) for(typeof A.begin() it = A.begin(); it!=A.end(); it++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define VE vector <int>
#define mset(A,x) memset(A, x, sizeof A)
#define PB push_back
#define ones(x) __builtin_popcount(x)
#define cua(x) (x)*(x)
#define debug(x) cout <<#x << " = " << x << endl
#define adebug(x,n) cout <<#x<<endl; REP(i,n)cout<<x[i]<<char(i+1==n?10:32)
#define mdebug(x,m,n) cout <<#x<<endl; REP(i,m)REP(j,n)cout<<x[i][j]<<char(j+1==n?10:32)
#define LSOne(S) (S&(-S))

using namespace std;

#define ll long long
#define lli long long int
#define PI acos(-1.0)
#define ii pair<int,int>
#define inf_ll (((1LL<<62)-1)<<1)+1
#define inf_i (1<<30)-1

int main(){
	set<lli> arr;
	lli c,b,q,l,m,num,cnt=0; scanf("%lld %lld %lld %lld",&b,&q,&l,&m);
	REP(i,m){
		scanf("%lld",&num);
		arr.insert(num);
	}
	if(abs(b)>l) printf("0\n");
	else if(abs(q)==1){
		c=0;
		while(abs(b)<=l){
			if(c==5) break;
			if(b==b*q) c++;
			b*=q;
		}
		(c==5)? printf("inf\n"): printf("0\n");
	}
	else if(q==0){
		if(arr.count(0)!=0){
			if(arr.count(b)!=0) printf("0\n");
			else printf("1\n");
		}
		else printf("inf\n");
	}
	else if(b==0){
		if(arr.count(b)!=0) printf("0\n");
		else printf("inf\n");
	}
	else {
		c=0;
		while(abs(b)<=l){
			if(c==5) break;
			if(arr.count(b)==0) cnt++;
			if(b==b*q) c++;
			b*=q;
		}
		(c==5)? printf("inf\n"): printf("%lld\n",cnt);
	}
  return 0;
}

/*
   freopen("input.txt", "r", stdin);
   freopen("out.txt", "w", stdout);
*/

/*
    fclose(stdin);
    fclose(stdout);
*/


#include <bits/stdc++.h>

#define REP(i, a) for(int i = 0; i < a; i++)
#define RFOR(i,x,y) for(int i = x; i>= y; i--)
#define FOR(i,x,y) for (int i = x; i < y; i++)
#define ITFOR(it,A) for(typeof A.begin() it = A.begin(); it!=A.end(); it++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define VE vector <int>
#define mset(A,x) memset(A, x, sizeof A)
#define PB push_back
#define ones(x) __builtin_popcount(x)
#define cua(x) (x)*(x)
#define debug(x) cout <<#x << " = " << x << endl
#define adebug(x,n) cout <<#x<<endl; REP(i,n)cout<<x[i]<<char(i+1==n?10:32)
#define mdebug(x,m,n) cout <<#x<<endl; REP(i,m)REP(j,n)cout<<x[i][j]<<char(j+1==n?10:32)
#define LSOne(S) (S&(-S))

using namespace std;

#define ll long long
#define lli long long int
#define PI acos(-1.0)
#define ii pair<int,int>
#define inf_ll (((1LL<<62)-1)<<1)+1
#define inf_i (1<<30)-1

int main(){
	set<lli> arr;
	lli b,q,l,m,num,cnt=0; scanf("%lld %lld %lld %lld",&b,&q,&l,&m);
	REP(i,m){
		scanf("%lld",&num);
		arr.insert(num);
	}
	if(arr.count(b)!=0||b>l) printf("0\n");
	else if(abs(q)==1||b==0) printf("inf\n");
	else if(q==0){
		if(arr.count(0)!=0) printf("1\n");
		else printf("inf\n");
	}
	else {
		while(abs(b)<=l){
			if(arr.count(b)==0) cnt++;
			b*=q;
		}
		printf("%lld\n",cnt);
	}
  return 0;
}

/*
   freopen("input.txt", "r", stdin);
   freopen("out.txt", "w", stdout);
*/

/*
    fclose(stdin);
    fclose(stdout);
*/


#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;

int abs(int a){
	return a > 0 ? a : -a;
}

int find(int* array, int n, int a){
	int step = n / 2;
	int i;
	for (i = n / 2; step > 0; step /= 2)
		if (array[i] < a)
			i += step;
		else if (array[i] > a)
			i -= step;
		else
			return i;
	return i;
}

int main(){
	int b, q, l, m, a[100000];
	cin >> b >> q >> l >> m;
	bool haveNull = false, haveOne = false, havemOne = false, haveB = false, havemB = false;
	for (int i = 0; i < m; i++){
		cin >> a[i];
		if (a[i] == 1) haveOne = true;
		if (a[i] == 0) haveNull = true;
		if (a[i] == -1) havemOne = true;
		if (a[i] == b) haveB = true;
		if (a[i] == -b) havemB = true;
	}
	sort(a, a + m);

	if (b > l){
		cout << 0 << endl;
	}else if (b == 0){
		cout << (haveNull ? "0" : "inf") << endl;
	}else if (q == 0){
		if (haveB)
			cout << (haveNull ? "0" : "inf") << endl;
		else
			cout << (haveNull ? "1" : "inf") << endl;
	}else if (q == 1){
		cout << (haveB ? "0" : "inf") << endl;
	}else if (q == -1){
		cout << ((haveB && havemB) ? "0" : "inf") << endl;
	}else if (-1 < q && q < 1){
		cout << "inf" << endl;
	}else if (q > 0 && b > 0){
		int k = 0;
		long long number = b;
		int count = 0;
		while (number <= l){
			if (a[k] == number){
				number *= q;
				k++;
			}else if (a[k] < number){
				k++;
			}else{
				count++;
				number *= q;
			}
			if (k >= m)
				while(number <= l){
					count++;
					number *= q;
				}
		}
		cout << count << endl;
	}else{
		int k = find(a, m, 0);
		int pl = 0, mn = 0;
		if (m > 10){
			pl = -6;
			mn = 6;
		}else{
			pl -= m / 2;
			mn += m / 2;
		}
		long long number = b;
		int count = 0;
		while (abs(number) <= l){
			if (a[k + pl] == number && k + pl < m){
				number *= q;
				pl++;
			}else if (a[k - mn] == number && k - mn > 0){
				number *= q;
				mn--;
			}else if (abs(a[k + pl]) < abs(number) && k + pl < m){
				pl++;
			}else if (abs(a[k - mn]) < abs(number) && k - mn > 0){
				mn--;
			}else{
				count++;
				number *= q;
			}
			if (k + pl >= m && k - mn < 0)
				while(abs(number) <= l){
					count++;
					number *= q;
				}
		}
		cout << count << endl;
	}

	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

bool compare(int a, int b){
	return abs(a) < abs(b);
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
	const int N = 1e5;
	int b, q, l, m;
	cin >> b >> q >> l >> m;
	int a[N], s;
	bool h0 = false, h1 = false, hm1 = false, hb = false, hmb = false;
	for (int i = 0; i < m;){
		cin >> s;
		if (s == 0) h0 = true;
		else if (s == 1) h1 = true;
		else if (s == -1) hm1 = true;
		else if (s == b) hb = true;
		else if (s == -b) hmb = true;
		if (abs(s) <= l)
			a[i++] = s;
		else{
			m--;
		}
	}
	if (q == 0 && h0) cout << (hb || abs(b) > l ? "0" : "1") << endl;
	else if (q == 0) cout << "inf" << endl;
	else if (q == 1) cout << (hb || abs(b) > l ? "0" : "inf") << endl;
	else if (q == -1) cout << (hb && hmb || abs(b) > l ? "0" : "inf") << endl;
	else{
		sort(a, a + m, compare);

		long long number = b;
		int count = 0, i = 0;
		while(abs(number) <= l){
			if (i == m){
				while(number <= l){
					number *= q;
					count++;
				}
				break;
			}
			if (abs(number) > abs(a[i])) i++;
			else if (abs(number) == abs(a[i])){
				if (number == a[i]){
					number *= q;
					i++;
				}else
					i++;
			}else{
				count++;
				number *= q;
			}
		}
		cout << count << endl;
	}

	return 0;
}


#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;

int abs(int& a){
	return a > 0 ? a : -a;
}

int find(int* array, int n, int a){
	int step = n / 2;
	int i;
	for (i = n / 2; step > 0; step /= 2)
		if (array[i] < a)
			i += step;
		else if (array[i] > a)
			i -= step;
		else
			return i;
	return i;
}

int main(){
	int b, q, l, m, a[100000];
	cin >> b >> q >> l >> m;
	bool haveNull = false, haveOne = false, havemOne = false, haveB = false, havemB = false;
	for (int i = 0; i < m; i++){
		cin >> a[i];
		if (a[i] == 1) haveOne = true;
		if (a[i] == 0) haveNull = true;
		if (a[i] == -1) havemOne = true;
		if (a[i] == b) haveB = true;
		if (a[i] == -b) havemB = true;
	}
	sort(a, a + m);

	if (b > l){
		cout << 0 << endl;
	}else if (b == 0){
		cout << (haveNull ? "0" : "inf") << endl;
	}else if (q == 0){
		if (haveB)
			cout << (haveNull ? "0" : "inf") << endl;
		else
			cout << (haveNull ? "1" : "inf") << endl;
	}else if (q == 1){
		cout << (haveB ? "0" : "inf") << endl;
	}else if (q == -1){
		cout << ((haveB && havemB) ? "0" : "inf") << endl;
	}else if (-1 < q && q < 1){
		cout << "inf" << endl;
	}else if (q > 0 && b > 0){
		int k = 0;
		long long number = b;
		int count = 0;
		while (number <= l){
			if (a[k] == number){
				number *= q;
				k++;
			}else if (a[k] < number){
				k++;
			}else{
				count++;
				number *= q;
			}
			if (k >= m)
				while(number <= l){
					count++;
					number *= q;
				}
		}
		cout << count << endl;
	}else{
		int k = find(a, m, 0);
		if (b < 0 && a[k] > 0 && k > 0)
			k--;
		else if (b > 0 && a[k] < 0 && k < m)
			k++;
		int pl = 0, mn = 0;
		long long number = b;
		int count = 0;
		while (abs(number) <= l){
			if (a[k + pl] == number && k + pl < m){
				number *= q;
				pl++;
			}else if (a[k - mn] == number && k - mn > 0){
				number *= q;
				mn--;
			}else if (a[k + pl] < number && k + pl < m){
				pl++;
			}else if (a[k - mn] > number && k - mn > 0){
				mn--;
			}else{
				count++;
				number *= q;
			}
			if (k + pl >= m && k - mn < 0)
				while(abs(number) <= l){
					count++;
					number *= q;
				}
		}
		cout << count << endl;
	}

	return 0;
}


#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;

int abs(int& a){
	return a > 0 ? a : -a;
}

int find(int* array, int n, int a){
	int step = n / 2;
	int i;
	for (i = n / 2; step > 0; step /= 2)
		if (array[i] < a)
			i += step;
		else if (array[i] > a)
			i -= step;
		else
			return i;
	return i;
}

int main(){
	int b, q, l, m, a[100000];
	cin >> b >> q >> l >> m;
	bool haveNull = false, haveOne = false, havemOne = false, haveB = false, havemB = false;
	for (int i = 0; i < m; i++){
		cin >> a[i];
		if (a[i] == 1) haveOne = true;
		if (a[i] == 0) haveNull = true;
		if (a[i] == -1) havemOne = true;
		if (a[i] == b) haveB = true;
		if (a[i] == -b) havemB = true;
	}
	sort(a, a + m);

	if (b > l){
		cout << 0 << endl;
	}else if (b == 0){
		cout << (haveNull ? "0" : "inf") << endl;
	}else if (q == 0){
		if (haveB)
			cout << (haveNull ? "0" : "inf") << endl;
		else
			cout << (haveNull ? "1" : "inf") << endl;
	}else if (q == 1){
		cout << (haveB ? "0" : "inf") << endl;
	}else if (q == -1){
		cout << ((haveB && havemB) ? "0" : "inf") << endl;
	}else if (-1 < q && q < 1){
		cout << "inf" << endl;
	}else if (q > 0 && b > 0){
		int k = 0;
		long long number = b;
		int count = 0;
		while (number <= l){
			if (a[k] == number){
				number *= q;
				k++;
			}else if (a[k] < number){
				k++;
			}else{
				count++;
				number *= q;
			}
			if (k >= m)
				while(number <= l){
					count++;
					number *= q;
				}
		}
		cout << count << endl;
	}else{
		int k = find(a, m, 0);
		int pl = 0, mn = 0;
		if (m > 10){
			pl = -6;
			mn = 6;
		}else{
			pl -= m / 2;
			mn += m / 2;
		}
		long long number = b;
		int count = 0;
		while (abs(number) <= l){
			if (a[k + pl] == number && k + pl < m){
				number *= q;
				pl++;
			}else if (a[k - mn] == number && k - mn > 0){
				number *= q;
				mn--;
			}else if (abs(a[k + pl]) < abs(number) && k + pl < m){
				pl++;
			}else if (abs(a[k - mn]) < abs(number) && k - mn > 0){
				mn--;
			}else{
				count++;
				number *= q;
			}
			if (k + pl >= m && k - mn < 0)
				while(abs(number) <= l){
					count++;
					number *= q;
				}
		}
		cout << count << endl;
	}

	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

bool compare(int a, int b){
	return abs(a) < abs(b);
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
	const int N = 1e5;
	int b, q, l, m;
	cin >> b >> q >> l >> m;
	int a[N], s;
	bool h0 = false, h1 = false, hm1 = false, hb = false, hmb = false;
	for (int i = 0; i < m;){
		cin >> s;
		if (s == 0) h0 = true;
		else if (s == 1) h1 = true;
		else if (s == -1) hm1 = true;
		else if (s == b) hb = true;
		else if (s == -b) hmb = true;
		if (abs(s) <= l)
			a[i++] = s;
		else{
			m--;
		}
	}
	if (abs(b) > l) cout << 0 << endl;
	else if (b == 0) cout << (h0 ? "0" : "inf") << endl;
	else if (q == 0 && h0) cout << (hb ? "0" : "1") << endl;
	else if (q == 0) cout << "inf" << endl;
	else if (q == 1) cout << (hb ? "0" : "inf") << endl;
	else if (q == -1) cout << (hb && hmb ? "0" : "inf") << endl;
	else{
		sort(a, a + m, compare);

		long long number = b;
		int count = 0, i = 0;
		while(abs(number) <= l){
			if (i == m){
				while(abs(number) <= l){
					number *= q;
					count++;
				}
				break;
			}
			if (abs(number) > abs(a[i])) i++;
			else if (abs(number) == abs(a[i])){
				if (number == a[i]){
					number *= q;
					i++;
				}else
					i++;
			}else{
				count++;
				number *= q;
			}
		}
		cout << count << endl;
	}

	return 0;
}


#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;

int abs(int& a){
	return a > 0 ? a : -a;
}

int find(int* array, int n, int a){
	int step = n / 2;
	int i;
	for (i = n / 2; step > 0; step /= 2)
		if (array[i] < a)
			i += step;
		else if (array[i] > a)
			i -= step;
		else
			return i;
	return i;
}

int main(){
	int b, q, l, m, a[100000];
	cin >> b >> q >> l >> m;
	bool haveNull = false, haveOne = false, havemOne = false, haveB = false, havemB = false;
	for (int i = 0; i < m; i++){
		cin >> a[i];
		if (a[i] == 1) haveOne = true;
		if (a[i] == 0) haveNull = true;
		if (a[i] == -1) havemOne = true;
		if (a[i] == b) haveB = true;
		if (a[i] == -b) havemB = true;
	}
	sort(a, a + m);

	if (b > l){
		cout << 0 << endl;
	}else if (b == 0){
		cout << (haveNull ? "0" : "inf") << endl;
	}else if (q == 0){
		if (haveB)
			cout << (haveNull ? "0" : "inf") << endl;
		else
			cout << (haveNull ? "1" : "inf") << endl;
	}else if (q == 1){
		cout << (haveB ? "0" : "inf") << endl;
	}else if (q == -1){
		cout << ((haveB && havemB) ? "0" : "inf") << endl;
	}else if (-1 < q && q < 1){
		cout << "inf" << endl;
	}else if (q > 0 && b > 0){
		int k = 0;
		long long number = b;
		int count = 0;
		while (number <= l){
			if (a[k] == number){
				number *= q;
				k++;
			}else if (a[k] < number){
				k++;
			}else{
				count++;
				number *= q;
			}
			if (k >= m)
				while(number <= l){
					count++;
					number *= q;
				}
		}
		cout << count << endl;
	}else{
		int k = find(a, m, 0);
		int pl = 0, mn = 0;
		if (m > 10){
			pl = -6;
			mn = 6;
		}else{
			pl -= m / 2;
			mn += m / 2;
		}
		long long number = b;
		int count = 0;
		while (abs(number) <= l){
			if (a[k + pl] == number && k + pl < m){
				number *= q;
				pl++;
			}else if (a[k - mn] == number && k - mn > 0){
				number *= q;
				mn--;
			}else if (a[k + pl] < number && k + pl < m){
				pl++;
			}else if (a[k - mn] > number && k - mn > 0){
				mn--;
			}else{
				count++;
				number *= q;
			}
			if (k + pl >= m && k - mn < 0)
				while(abs(number) <= l){
					count++;
					number *= q;
				}
		}
		cout << count << endl;
	}

	return 0;
}


#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;

int abs(int& a){
	return a > 0 ? a : -a;
}

int find(int* array, int n, int a){
	int step = n / 2;
	int i;
	for (i = n / 2; step > 0; step /= 2)
		if (array[i] < a)
			i += step;
		else if (array[i] > a)
			i -= step;
		else
			return i;
	return i;
}

int main(){
	int b, q, l, m, a[100000];
	cin >> b >> q >> l >> m;
	bool haveNull = false, haveOne = false, havemOne = false, haveB = false, havemB = false;
	for (int i = 0; i < m; i++){
		cin >> a[i];
		if (a[i] == 1) haveOne = true;
		if (a[i] == 0) haveNull = true;
		if (a[i] == -1) havemOne = true;
		if (a[i] == b) haveB = true;
		if (a[i] == -b) havemB = true;
	}
	sort(a, a + m);

	if (b == 0){
		cout << (haveNull ? "0" : "inf") << endl;
	}else if (q == 0){
		if (haveB)
			cout << (haveNull ? "0" : "inf") << endl;
		else
			cout << (haveNull ? "1" : "inf") << endl;
	}else if (q == 1){
		cout << (haveB ? "0" : "inf") << endl;
	}else if (q == -1){
		cout << ((haveB && havemB) ? "0" : "inf") << endl;
	}else if (-1 < q && q < 1){
		cout << "inf" << endl;
	}else if (q > 0 && b > 0){
		int k = 0;
		long long number = b;
		int count = 0;
		while (number <= l){
			if (a[k] == number){
				number *= q;
				k++;
			}else if (a[k] < number){
				k++;
			}else{
				count++;
				number *= q;
			}
			if (k >= m)
				while(number <= l){
					count++;
					number *= q;
				}
		}
		cout << count << endl;
	}else{
		int k = find(a, m, 0);
		if (b < 0 && a[k] > 0 && k > 0)
			k--;
		else if (b > 0 && a[k] < 0 && k < m)
			k++;
		int pl = 0, mn = 0;
		long long number = b;
		int count = 0;
		while (abs(number) <= l){
			if (a[k + pl] == number && k + pl < m){
				number *= q;
				pl++;
			}else if (a[k - mn] == number && k - mn > 0){
				number *= q;
				mn--;
			}else if (a[k + pl] < number && k + pl < m){
				pl++;
			}else if (a[k - mn] > number && k - mn > 0){
				mn--;
			}else{
				count++;
				number *= q;
			}
			if (k + pl >= m && k - mn < 0)
				while(abs(number) <= l){
					count++;
					number *= q;
				}
		}
		cout << count << endl;
	}

	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

bool compare(int a, int b){
	return abs(a) < abs(b);
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
	const int N = 1e5;
	int b, q, l, m;
	cin >> b >> q >> l >> m;
	int a[N], s;
	bool h0 = false, h1 = false, hm1 = false, hb = false, hmb = false;
	for (int i = 0; i < m;){
		cin >> s;
		if (s == 0) h0 = true;
		else if (s == 1) h1 = true;
		else if (s == -1) hm1 = true;
		else if (s == b) hb = true;
		else if (s == -b) hmb = true;
		if (abs(s) <= l)
			a[i++] = s;
		else{
			m--;
		}
	}
	if (q == 0 && h0) cout << (hb ? "0" : "1") << endl;
	else if (q == 0) cout << "inf" << endl;
	else if (q == 1) cout << (hb ? "0" : "inf") << endl;
	else if (q == -1) cout << (hb && hmb ? "0" : "inf") << endl;
	else{
		sort(a, a + m, compare);

		long long number = b;
		int count = 0, i = 0;
		while(number <= l){
			if (i == m){
				while(number <= l){
					number *= q;
					count++;
				}
				break;
			}
			if (abs(number) > abs(a[i])) i++;
			else if (abs(number) == abs(a[i])){
				if (number == a[i]){
					number *= q;
					i++;
				}else
					i++;
			}else{
				count++;
				number *= q;
			}
		}
		cout << count << endl;
	}

	return 0;
}


#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;

int abs(int& a){
	return a > 0 ? a : -a;
}

int find(int* array, int n, int a){
	int step = n / 2;
	int i;
	for (i = n / 2; step > 0; step /= 2)
		if (array[i] < a)
			i += step;
		else if (array[i] > a)
			i -= step;
		else
			return i;
	return i;
}

int main(){
	int b, q, l, m, a[100000];
	cin >> b >> q >> l >> m;
	bool haveNull = false, haveOne = false, havemOne = false, haveB = false, havemB = false;
	for (int i = 0; i < m; i++){
		cin >> a[i];
		if (a[i] == 1) haveOne = true;
		if (a[i] == 0) haveNull = true;
		if (a[i] == -1) havemOne = true;
		if (a[i] == b) haveB = true;
		if (a[i] == -b) havemB = true;
	}
	sort(a, a + m);

	if (b == 0){
		cout << (haveNull ? "0" : "inf") << endl;
	}else if (q == 0){
		if (haveB)
			cout << (haveNull ? "0" : "inf") << endl;
		else
			cout << (haveNull ? "1" : "inf") << endl;
	}else if (q == 1){
		cout << (haveB ? "0" : "inf") << endl;
	}else if (q == -1){
		cout << ((haveB && havemB) ? "0" : "inf") << endl;
	}else if (-1 < q && q < 1){
		cout << "inf" << endl;
	}else if (q > 0 && b > 0){
		int k = 0;
		long long number = b;
		int count = 0;
		while (number <= l){
			if (a[k] == number){
				number *= q;
				k++;
			}else if (a[k] < number){
				k++;
			}else{
				count++;
				number *= q;
			}
			if (k >= m)
				while(number <= l){
					count++;
					number *= q;
				}
		}
		cout << count << endl;
	}else if (q > 0 && b < 0 || q < 0 && b > 0){
		int k = find(a, m, 0);
		if (b < 0 && a[k] > 0 && k > 0)
			k--;
		else if (b > 0 && a[k] < 0 && k < m)
			k++;
		int pl = 0, mn = 0;
		long long number = b;
		int count = 0;
		while (abs(number) <= l){
			if (a[k + pl] == number && k + pl < m){
				number *= q;
				pl++;
			}else if (a[k - mn] == number && k - mn > 0){
				number *= q;
				mn--;
			}else if (a[k + pl] < number && k + pl < m){
				pl++;
			}else if (a[k - mn] > number && k - mn > 0){
				mn--;
			}else{
				count++;
				number *= q;
			}
			if (k + pl >= m && k - mn < 0)
				while(abs(number) <= l){
					count++;
					number *= q;
				}
		}
		cout << count << endl;
	}

	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

bool compare(int a, int b){
	return abs(a) < abs(b);
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
	const int N = 1e5;
	int b, q, l, m;
	cin >> b >> q >> l >> m;
	int a[N], s;
	bool h0 = false, h1 = false, hm1 = false, hb = false, hmb = false;
	for (int i = 0; i < m;){
		cin >> s;
		if (s == 0) h0 = true;
		else if (s == 1) h1 = true;
		else if (s == -1) hm1 = true;
		else if (s == b) hb = true;
		else if (s == -b) hmb = true;
		if (abs(s) <= l)
			a[i++] = s;
		else{
			m--;
		}
	}
	if (q == 0 && h0) cout << (hb ? "0" : "1") << endl;
	else if (q == 0) cout << "inf" << endl;
	else if (q == 1) cout << (hb ? "0" : "inf") << endl;
	else if (q == -1) cout << (hb && hmb ? "0" : "inf") << endl;
	else{
		sort(a, a + m, compare);

		long long number = b;
		int count = 0, i = 0;
		while(abs(number) <= l){
			if (i == m){
				while(number <= l){
					number *= q;
					count++;
				}
				break;
			}
			if (abs(number) > abs(a[i])) i++;
			else if (abs(number) == abs(a[i])){
				if (number == a[i]){
					number *= q;
					i++;
				}else
					i++;
			}else{
				count++;
				number *= q;
			}
		}
		cout << count << endl;
	}

	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

bool compare(int a, int b){
	return abs(a) < abs(b);
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
	const int N = 1e5;
	int b, q, l, m;
	cin >> b >> q >> l >> m;
	int a[N], s;
	bool h0 = false, h1 = false, hm1 = false, hb = false, hmb = false;
	for (int i = 0; i < m;){
		cin >> s;
		if (s == 0) h0 = true;
		else if (s == 1) h1 = true;
		else if (s == -1) hm1 = true;
		else if (s == b) hb = true;
		else if (s == -b) hmb = true;
		if (abs(s) <= l)
			a[i++] = s;
		else{
			m--;
		}
	}
	if (abs(b) > l) cout << 0 << endl;
	else if (q == 0 && h0) cout << (hb ? "0" : "1") << endl;
	else if (q == 0) cout << "inf" << endl;
	else if (q == 1) cout << (hb ? "0" : "inf") << endl;
	else if (q == -1) cout << (hb && hmb ? "0" : "inf") << endl;
	else{
		sort(a, a + m, compare);

		long long number = b;
		int count = 0, i = 0;
		while(abs(number) <= l){
			if (i == m){
				while(number <= l){
					number *= q;
					count++;
				}
				break;
			}
			if (abs(number) > abs(a[i])) i++;
			else if (abs(number) == abs(a[i])){
				if (number == a[i]){
					number *= q;
					i++;
				}else
					i++;
			}else{
				count++;
				number *= q;
			}
		}
		cout << count << endl;
	}

	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

bool compare(int a, int b){
	return abs(a) < abs(b);
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
	const int N = 1e5;
	int b, q, l, m;
	cin >> b >> q >> l >> m;
	int a[N], s;
	bool h0 = false, h1 = false, hm1 = false, hb = false, hmb = false;
	for (int i = 0; i < m;){
		cin >> s;
		if (s == 0) h0 = true;
		else if (s == 1) h1 = true;
		else if (s == -1) hm1 = true;
		else if (s == b) hb = true;
		else if (s == -b) hmb = true;
		if (abs(s) <= l)
			a[i++] = s;
		else{
			m--;
		}
	}
	if (abs(b) > l) cout << 0 << endl;
	else if (q == 0 && h0) cout << (hb ? "0" : "1") << endl;
	else if (q == 0) cout << "inf" << endl;
	else if (q == 1) cout << (hb ? "0" : "inf") << endl;
	else if (q == -1) cout << (hb && hmb ? "0" : "inf") << endl;
	else{
		sort(a, a + m, compare);

		long long number = b;
		int count = 0, i = 0;
		while(abs(number) <= l){
			if (i == m){
				while(abs(number) <= l){
					number *= q;
					count++;
				}
				break;
			}
			if (abs(number) > abs(a[i])) i++;
			else if (abs(number) == abs(a[i])){
				if (number == a[i]){
					number *= q;
					i++;
				}else
					i++;
			}else{
				count++;
				number *= q;
			}
		}
		cout << count << endl;
	}

	return 0;
}


#include<bits\stdc++.h>

using namespace std;

typedef long long INT;

typedef pair<int,int> pii;

#define NN 111111

int a[NN];

INT b[NN];

int main(){

	int i,j,k;

	int q,l,m;

	INT cnt;

	int flag;

	while(scanf("%lld%d%d%d",&b[1],&q,&l,&m)==4){

		for(i=0;i<m;i++)

			scanf("%d",&a[i]);

		sort(a,a+m);

		k=2;

		flag=1;

		if(q==0 || abs(q)==1){

			if(q==0){b[2]=0;k++;}

			else{

				if(q==-1){

					b[2]=-b[1];

					k++;

				}

			}

			flag=0;

		}

		while(flag){

			if(l/b[k-1]<q)break;

			b[k]=b[k-1]*q;

			k++;

		}

		cnt=0;

		for(i=1;i<k;i++){

			for(j=0;j<m;j++){

				if(a[j]>=b[i])

					break;

				}

			if(b[i]==a[j]){continue;}

			cnt++;

		}

		if((q==-1||q==1)&&cnt){

				printf("inf\n");

			}

		else

			printf("%lld\n",cnt);

	}

	return 0;

}


#include <iostream>

#include <algorithm>

#include <stdio.h>

#include <math.h>

using namespace std;

long long b1, q, l, m, i, a[100050], c = 0, k, s = 0;

int main() {

	cin>>b1>>q>>l>>m;

	for(i = 0; i < m; i++ ) {

		cin>>a[i];

	}

	if (b1 > l || b1 < -l) {

		cout<<0<<endl; return 0;

	}

	else {

		if (q == 1){

			k = 0;

			for(i = 0; i < m; i++ ) {

				if (b1 == a[i]) k = 1;

			}

			if (k == 1) {

				cout<<0<<endl; return 0;

			}

			else {

				cout<<"inf"<<endl; return 0;

			}

		}

		else if (q == -1) {

			k = 0;

			for (i = 0; i < m; i++ ) {

				if (b1 == a[i] || b1 == -a[i]) k = 1;

			}

			if ( k == 1){

				cout<<0<<endl; return 0;

			}

			else {

				cout<<"inf"<<endl; return 0;

			}

		}

		else{

			k = 1;

			c = b1;

			while (c < l + 1 && c > -l - 1){

				k = 1;

				for(i = 0; k == 1 && i < m; i++ ) {

					if (c == a[i]) k = 0;

				}

				if (k == 1) s++;

				c = c * q;

			}

			cout<<s<<endl;

		}

	}

	return 0;

}


#include <iostream>

#include <algorithm>

#include <stdio.h>

#include <math.h>

using namespace std;

long long b1, q, l, m, i, a[100050], c = 0, k, s = 0;

int main() {

	cin>>b1>>q>>l>>m;

	for(i = 0; i < m; i++ ) {

		cin>>a[i];

	}

	if (b1 > l || b1 < -l) {

		cout<<0<<endl; return 0;

	}

	else {

		if (q == 1){

			k = 0;

			for(i = 0; i < m; i++ ) {

				if (b1 == a[i]) k = 1;

			}

			if (k == 1) {

				cout<<0<<endl; return 0;

			}

			else {

				cout<<"inf"<<endl; return 0;

			}

		}

		else if (q == -1) {

			k = 0;

			for (i = 0; i < m; i++ ) {

				if (b1 == a[i] || b1 == -a[i]) k = 1;

			}

			if ( k == 1){

				cout<<0<<endl; return 0;

			}

			else {

				cout<<"inf"<<endl; return 0;

			}

		}

		else if (q == 0 || b1 == 0) {

			k = 0;

			for (i = 0; i < m; i++ ) {

				if (a[i] == 0) k = 1;

			}

			if ( k == 1){

				cout<<0<<endl; return 0;

			}

			else {

				cout<<"inf"<<endl; return 0;

			}

		}

		else{

			k = 1;

			c = b1;

			while (c < l + 1 && c > -l - 1){

				k = 1;

				for(i = 0; k == 1 && i < m; i++ ) {

					if (c == a[i]) k = 0;

				}

				if (k == 1) s++;

				c = c * q;

			}

			cout<<s<<endl;

		}

	}

	return 0;

}


#include<bits/stdc++.h>

using namespace std;

set<int> s;

int main() {

	long long  b, q, l, n, c;

	cin >> b >> q >> l >> n;

	for( int i = 0; i < n; i ++ ) scanf("%d", &c), s.insert(c);

	if ( q == 1 ) {

		if ( s.count(b)) puts("0");

		else puts("inf");  return 0;

	}

	if ( q == -1 ) {

		if ( s.count(b) && s.count(-b) ) puts("0");

		else puts("inf");

		return 0;

	}

	if( q == 0 ) {

		if ( s.count(0) )  {

			if ( s.count(b)) puts("0");

			else puts("1");

		}

		else puts("inf");

		return 0;

	}

	int ans = 0;

	while ( abs( b ) <= l ) {

		if ( !s.count(b) ) ans++;

		b *= q;

	}

	cout << ans << endl;

	return 0;

}


#include <bits/stdc++.h>

using namespace std;

map<int, int> mp;

int main(){

	int a, b, q, l, m ,i;

	while(~scanf("%d%d%d%d", &b, &q, &l, &m)){

		mp.clear();

		for(i=0; i<m; i++){

			scanf("%d", &a);

			mp[a]=1;

		}

		int cnt=0;

		if(b==0){

			if(mp[b]==0) puts("inf");

			else puts("0");

			continue;

		}

		if(mp[b]==0&&abs(b)<=l) cnt=1;

		if(q==0){

			if(mp[0]==0) puts("inf");

			else printf("%d\n", cnt);

			continue;

		}

		if(q==1){

			if(cnt) puts("inf");

			else puts("0");

			continue;

		}

		if(q==-1){

			if(cnt||(mp[-b]==0&&abs(b)<=l)) puts("inf");

			else puts("0");

			continue;

		}

		while(abs(b*q)<=l){

			b*=q;

			if(!mp[b])cnt++;

		}

		printf("%d\n", cnt);

	}

}


#include<bits/stdc++.h>

using namespace std;

long long a[111111];

set<long long> aa;

int main(){

	long long c,q,l,m;

	scanf("%lld%lld%lld%lld",&c,&q,&l,&m);

		int i;

		for(i=0;i<m;i++){

			scanf("%lld",a+i);

			aa.insert(a[i]);

		}

		if(c==0) {

			if(aa.find(0)!= aa.end()) puts("0");

			else puts("inf");

			return 0;

		}

		if(q==0){

			if(aa.find(0)==aa.end()) puts("inf");

			else if((aa.find(c)!=aa.end())||abs(c)>l) puts("0");

			else puts("1");

			return 0;

		}

		if(abs(c)>l) {puts("0");return 0;}

		if(q==1){

			if(aa.find(c)!=aa.end()) puts("0");

			else puts("inf");

			return 0;

		}

		if(q==-1){

			if(aa.find(c)!=aa.end()&&aa.find(-c)!=aa.end()) puts("0");

			else puts("inf");

			return 0;

		}

		long long cnt=0;

		while(abs(c)<=l){

			if(aa.find(c)==aa.end()) cnt++;

			c*=q;

		}

		printf("%lld\n", cnt);

	return 0;

}


#include<bits/stdc++.h>

using namespace std;

#define NN 110000

map<long long ,int>mp;

long long b1,q,l,m,a[NN],ans;

int main()

{

//	freopen("in.txt","r",stdin);

	scanf("%I64d%I64d%I64d%I64d", &b1, &q, &l, &m);  mp.clear();

	for(int i=0; i<m; i++) scanf("%I64d", a+i),mp[a[i]]=1;

	if(abs(b1)>l){ puts("0"); return 0;}

	if(b1==0 || q==1){

		if(mp[b1])puts("0");

		else puts("inf");

	}

	else if(q==-1){

		if(!mp[b1] || !mp[-b1])puts("inf");

		else puts("inf");

	}

	else if(q==0){

		if(!mp[0])puts("inf");

		else if(!mp[b1])puts("1");

		else puts("0");

	}

	else{

		while(abs(b1)<=l){

			if(!mp[b1])ans++;

			b1*=q;

		}

		printf("%I64d\n",ans);

	}

	return 0;

}


#include<bits/stdc++.h>

using namespace std;

#define NN 111111

typedef long long INT;

map<int, int> mp;

int main (){

	INT  bad[NN], b, q, l, i, x;

	int m, flag=0, ret=1, ans=0;

	scanf("%lld%lld%lld%d", &b, &q, &l, &m );

	mp.clear();

	for( i=0; i<m; i++ ) {

		scanf("%d", &x);

		mp[x] = ret;

	}

	if( abs(b)>l ) { puts("0"); return 0; }

	if( b == 0 ){

		if( mp.find(0) != mp.end() ) puts("0");

		else puts("inf");

		return 0;

	}

	if(q==1) {

			if(mp.find(b) != mp.end())  puts("0");

			return 0;

		}

	if(q ==-1 ) {

			if(mp.find(b) != mp.end() && mp.find(-b) != mp.end())  puts("0");

			else puts("inf");

			return 0;

		}

	if(q == 0)  {

			if(mp.find(b) != mp.end() && mp.find(0) != mp.end())  puts("0");

			else puts("inf");

			return 0;

		};

	while ( abs(b)<=l ){

		if(mp.find(b) == mp.end()) ans++;

		b*=q;

	}

	printf("%d", ans);

	return 0;

}


#include<bits/stdc++.h>

using namespace std;

#define NN 111111

typedef long long INT;

set<int> s;

int main (){

	INT  bad[NN], b, q, l, i, x, m;

	int  flag=0, ret=1;

	scanf("%lld%lld%lld%lld", &b, &q, &l, &m );

	s.clear();

	for( i=0; i<m; i++ ) {

		scanf("%d", &x);

		s.insert(x);

	}

	if( abs(b)>l ) { puts("0"); return 0; }

	if( b == 0 ){

		if( s.find(0) != s.end() ) puts("0");

		else puts("inf");

		return 0;

	}

	if(q==1) {

			if(s.find(b) != s.end())  puts("0");

			puts("inf");

			return 0;

		}

	if(q ==-1 ) {

			if(s.find(b) != s.end() && s.find(-b) != s.end())  puts("0");

			else puts("inf");

			return 0;

		}

	if(q == 0)  {

			if( s.find(0) == s.end())  puts("inf");

			else if(s.find(b) != s.end()) puts("0");

			else puts("1");

			return 0;

	}

	INT ans = 0;

	while ( abs(b)<=l ){

		if(s.find(b) == s.end()) ans++;

		b*=q;

	}

	printf("%d\n", ans);

	return 0;

}


#include<bits/stdc++.h>

using namespace std;

set<long long> s;

int main() {

	long long  b, q, l, n, c;

	cin >> b >> q >> l >> n;

	for( int i = 0; i < n; i ++ ) scanf("%lld", &c), s.insert(c);

	if ( b == 0 ) {

		if ( s.count(0) ) puts("0");

		else puts("inf");

		return 0;

	}

	if ( q == 1 ) {

		if ( s.count(b)) puts("0");

		else puts("inf");

		return 0;

	}

	if ( q == -1 ) {

		if ( s.count(b) && s.count(-b) ) puts("0");

		else puts("inf");

		return 0;

	}

	if( q == 0 ) {

		if ( s.count(0) )  {

			if ( s.count(b) ) puts("0");

			else puts("1");

		}

		else puts("inf");

		return 0;

	}

	int ans = 0;

	while ( abs( b ) <= l ) {

		if ( !s.count(b) ) ans++;

		b *= q;

	}

	cout << ans << endl;

	return 0;

}


#include <bits/stdc++.h>

#define NN 1111

#define inf 0x3f3f3f3f

#define mod 1000000007

using namespace std;

typedef long long INT;

map<INT, bool> vst;

INT absss(INT u){if(u>=0) return u;return -u;}

int main(){

	int m;

	INT b, q, l, a;

	vst.clear();

	cin>>b>>q>>l>>m;

	for(int i=0; i<m; i++){

		scanf("%I64d", &a);

		vst[a]=1;

	}

	if(absss(b)>l){

		puts("0");

		return 0;

	}

	if(b==0){

		if(vst.count(0)) puts("0");

		else puts("inf");

		return 0;

	}

	int f1, f2;

	f1=f2=0;

	if(q==0){

		if(!vst.count(b)) f1=1;

		if(!vst.count(0)) f2=1;

		if(f2==1) {puts("inf");return 0;}

		if(f1==1) {puts("1");return 0;}

		puts("0");

		return 0;

	}

	if(q==1){

		if(!vst.count(b)) puts("inf");

		else puts("0");

		return 0;

	}

	if(q==-1){

		if((!vst.count(b)) || (!vst.count(-b))) puts("inf");

		else puts("0");

		return 0;

	}

	int cnt=0;

	while(absss(b)<=l){

		if(!vst.count(b)) cnt++;

		b*=q;

	}

	cout<<cnt<<endl;

	return 0;

}


#include<bits/stdc++.h>

using namespace std;

set<int> s;

int main() {

	int b, q, l, n, c;

	cin >> b >> q >> l >> n;

	for( int i = 0; i < n; i ++ ) scanf("%d", &c), s.insert(c);

	if ( q == 1 ) {

		if ( s.count(b)) puts("0");

		else puts("inf");  return 0;

	}

	if ( q == -1 ) {

		if ( s.count(b) && s.count(-b) ) puts("0");

		else puts("inf");

		return 0;

	}

	if( q == 0 ) {

		if ( s.count(0) )  {

			if ( s.count(b)) puts("0");

			else puts("1");

		}

		else puts("inf");

		return 0;

	}

	int ans = 0;

	while ( abs( b ) < l ) {

		if ( !s.count(b) ) ans++;

		b *= q;

	}

	cout << ans << endl;

	return 0;

}


#include<bits/stdc++.h>

using namespace std;

#define NN 111111

typedef long long INT;

set<int> s;

int main (){

	INT  bad[NN], b, q, l, i, x, m;

	int  flag=0, ret=1;

	scanf("%lld%lld%lld%lld", &b, &q, &l, &m );

	s.clear();

	for( i=0; i<m; i++ ) {

		scanf("%lld", &x);

		s.insert(x);

	}

	if( abs(b)>l ) { puts("0"); return 0; }

	if( b == 0 ){

		if( s.find(0) != s.end() ) puts("0");

		else puts("inf");

		return 0;

	}

	if(q==1) {

			if(s.find(b) != s.end())  puts("0");

			else puts("inf");

			return 0;

		}

	if(q ==-1 ) {

			if(s.find(b) != s.end() && s.find(-b) != s.end())  puts("0");

			else puts("inf");

			return 0;

		}

	if(q == 0)  {

			if( s.find(0) == s.end())  puts("inf");

			else if(s.find(b) != s.end()) puts("0");

			else puts("1");

			return 0;

	}

	INT ans = 0;

	while ( abs(b)<=l ){

		if(s.find(b) == s.end()) ans++;

		b*=q;

	}

	printf("%lld\n", ans);

	return 0;

}


#include<bits\stdc++.h>

using namespace std;

typedef long long INT;

typedef pair<int,int> pii;

#define NN 11111111

set <long long> mp;

long long a[NN];

int main(){

	INT b,q,l,m;

	INT cnt;

	int i;

	while(scanf("%lld%lld%lld%lld",&b,&q,&l,&m)==4){

		mp.clear();

		for(i=0;i<m;i++){

			scanf("%lld",&a[i]);

			mp.insert(a[i]);

		}

		cnt=0;

		if(abs(b)>l){puts("0");continue;}

		if(b==0){

			if(mp.find(b)==mp.end())

				puts("inf");

			else

				puts("0");

			continue;

			}

		if(q==0){

			if(mp.find(0)==mp.end())

				puts("inf");

			else{

				if(mp.find(b)!=mp.end())

					puts("0");

				else puts("1");

			}

			continue;

		}

		if(q==1){

			if(mp.find(b)==mp.end())

				puts("inf");

			else

				puts("0");

				continue;

			}

		if(q==-1){

			if(mp.find(b)!=mp.end() && mp.find(-b)!=mp.end())

				puts("0");

			else

				puts("inf");

			continue;

			}

		while(abs(b)<=l){

			if(mp.find(b)==mp.end())

				cnt++;

			b*=q;

		}

		printf("%lld\n",cnt);

	}

	return 0;

}


#include<bits/stdc++.h>

using namespace std;

long long a[111111];

set<long long> aa;

int main(){

	long long c,q,l,m;

	scanf("%lld%lld%lld%lld",&c,&q,&l,&m);

	int i;

	for(i=0;i<m;i++){

		scanf("%lld",a+i);

		aa.insert(a[i]);

	}

	if(c==0) {

		if(aa.find(0)!= aa.end()) puts("0");

		else puts("1");

		return 0;

	}

	if(abs(c)>l) {puts("0");return 0;}

	if(q==0){

		if(aa.find(c)!=aa.end()) puts("0");

		else puts("1");

		return 0;

	}

	if(q==1){

		if(aa.find(c)!=aa.end()) puts("0");

		else puts("inf");

		return 0;

	}

	if(q==-1){

		if(aa.find(c)!=aa.end()&&aa.find(-c)!=aa.end()) puts("0");

		else puts("inf");

		return 0;

	}

	int cnt=0;

	while(abs(c)<=l){

		if(aa.find(c)==aa.end()) cnt++;

		c*=q;

	}

	printf("%d\n", cnt);

	return 0;

}


#include <iostream>

#include <algorithm>

#include <cstring>

#include <string>

#include <math.h>

using namespace std;

long long b1, q, l, m, i, a[100050], c = 0, k, s = 0;

int main() {

	cin>>b1>>q>>l>>m;

	for(i = 0; i < m; i++ ) {

		cin>>a[i];

	}

	if (b1 > l || b1 < -l) {

		cout<<0<<endl; return 0;

	}

	else {

		if (q == 1){

			k = 0;

			for(i = 0; i < m; i++ ) {

				if (b1 == a[i]) k = 1;

			}

			if (k == 1) {

				cout<<0<<endl; return 0;

			}

			else {

				cout<<"inf"<<endl; return 0;

			}

		}

		else if (q == -1) {

			k = 0;

			for (i = 0; i < m; i++ ) {

				if (b1 == a[i] || b1 == -a[i]) k = 1;

			}

			if ( k == 1){

				cout<<0<<endl; return 0;

			}

			else {

				cout<<"inf"<<endl; return 0;

			}

		}

		else{

			k = 1;

			c = b1;

			while (c < l + 1 && c > -l - 1){

				k = 1;

				for(i = 0; k == 1 && i < m; i++ ) {

					if (c == a[i]) k = 0;

				}

				if (k == 1) s++;

				c = c * q;

			}

			cout<<s<<endl;

		}

	}

	return 0;

}


#include<bits/stdc++.h>

using namespace std;

map<long long,int>mp;

long long b,q,l,m,a,ans,i;

int main(){

	scanf("%I64d%I64d%I64d%I64d",&b,&q,&l,&m);

	for(i=0;i<m;i++) scanf("%I64d",&a),mp[a]=1;

	if(abs(b)>l) puts("0");

	else if(!b||q==1){

		if(mp[b]) puts("0");

		else puts("inf");

	}

	else if(q==-1){

		if(mp[b]&&mp[-b]) puts("0");

		else puts("inf");

	}

	else if(!q){

		if(mp[0]) printf("%d",!mp[b]);

		else puts("inf");

	}

	else{

		while(abs(b)<=l){

			if(!mp[b]) ans++;

			b*=q;

		}

		printf("%I64d\n",ans);

	}

	return 0;

}


#include<bits/stdc++.h>

using namespace std;

long long a[111111];

set<long long> aa;

int main(){

	long long c,q,l,m;

	scanf("%lld%lld%lld%lld",&c,&q,&l,&m);

		int i;

		for(i=0;i<m;i++){

			scanf("%lld",a+i);

			aa.insert(a[i]);

		}

		if(c==0) {

			if(aa.find(0)!= aa.end()) puts("0");

			else puts("inf");

			return 0;

		}

		if(q==0){

			if(aa.find(0)==aa.end()) puts("inf");

			else if((aa.find(c)!=aa.end())||abs(c)>l) puts("0");

			else puts("1");

			return 0;

		}

		if(abs(c)>l) {puts("0");return 0;}

		if(q==1){

			if(aa.find(c)!=aa.end()) puts("0");

			else puts("inf");

			return 0;

		}

		if(q==-1){

			if(aa.find(c)!=aa.end()&&aa.find(-c)!=aa.end()) puts("0");

			else puts("inf");

			return 0;

		}

		int cnt=0;

		while(abs(c)<=l){

			if(aa.find(c)==aa.end()) cnt++;

			c*=q;

		}

		printf("%d\n", cnt);

	return 0;

}


#include<bits/stdc++.h>

using namespace std;

long long a[111111];

set<long long> aa;

int main(){

	long long c,q,l,m;

	scanf("%lld%lld%lld%lld",&c,&q,&l,&m);

		int i;

		for(i=0;i<m;i++){

			scanf("%lld",a+i);

			aa.insert(a[i]);

		}

		if(c==0) {

			if(aa.find(0)!= aa.end()) puts("0");

			else puts("1");

			return 0;

		}

		if(q==0){

			if(aa.find(0)==aa.end()) puts("inf");

			else if(aa.find(c)!=aa.end()||abs(c)>l) puts("0");

			else puts("0");

			return 0;

		}

		if(abs(c)>l) {puts("0");return 0;}

		if(q==1){

			if(aa.find(c)!=aa.end()) puts("0");

			else puts("inf");

			return 0;

		}

		if(q==-1){

			if(aa.find(c)!=aa.end()&&aa.find(-c)!=aa.end()) puts("0");

			else puts("inf");

			return 0;

		}

		int cnt=0;

		while(abs(c)<=l){

			if(aa.find(c)==aa.end()) cnt++;

			c*=q;

		}

		printf("%d\n", cnt);

	return 0;

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define mod 1000000007

#define pb push_back

#define mp make_pair

#define sq(x) ((x)*(x))

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

inline void gn(long long&x){

	int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');

	while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;

}

inline void gn(int&x){long long t;gn(t);x=t;}

inline void gn(unsigned long long&x){long long t;gn(t);x=t;}

inline void gn(double&x){double t;scanf("%lf",&t);x=t;}

inline void gn(long double&x){double t;scanf("%lf",&t);x=t;}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

INT a[100010];

map<INT, int> vst;

int main(){

	INT b, q, l, m, cnt=0;

	scanf("%I64d%I64d%I64d%I64d", &b, &q, &l, &m);

	for(int i=0; i<m; i++){

		scanf("%I64d", a+i);

		vst[a[i]]=1;

	}

	if (abs(b)>l) {

		puts("0");

		return 0;

	}

	if (abs(q)<2 || b==0) {

		INT bb=b*q;

		if (abs(bb)<=l && (!vst.count(b*q) || !vst.count(b*q*q))) {

			puts("inf");

			return 0;

		}

		if (vst.count(b) || abs(b)>l) puts("0");

		else puts("1");

		return 0;

	}

	while (abs(b)<=l){

		if(!vst.count(b)) cnt++;

		b*=q;

	}

	cout<<cnt<<endl;

	return 0;

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define mod 1000000007

#define pb push_back

#define mp make_pair

#define sq(x) ((x)*(x))

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

inline void gn(long long&x){

	int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');

	while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;

}

inline void gn(int&x){long long t;gn(t);x=t;}

inline void gn(unsigned long long&x){long long t;gn(t);x=t;}

inline void gn(double&x){double t;scanf("%lf",&t);x=t;}

inline void gn(long double&x){double t;scanf("%lf",&t);x=t;}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

INT a[100010];

map<INT, int> vst;

int main(){

	INT b, q, l, m, cnt=0;

	scanf("%I64d%I64d%I64d%I64d", &b, &q, &l, &m);

	for(int i=0; i<m; i++){

		scanf("%I64d", a+i);

		vst[a[i]]=1;

	}

	if (abs(q)<2 || b==0) {

		if (!vst.count(b*q) || !vst.count(b*q*q)) {

			puts("inf");

			return 0;

		}

		if (vst.count(b) || abs(b)>l) puts("0");

		else puts("1");

		return 0;

	}

	while (abs(b)<=l){

		if(!vst.count(b)) cnt++;

		b*=q;

	}

	cout<<cnt<<endl;

	return 0;

}


#include<bits/stdc++.h>

using namespace std;

#define NN 111111

#define ESP 1e-12

typedef long long INT;

typedef pair <int, int> pii;

int main (){

	INT  bad[NN], b, q, l;

	int m;

	scanf("%lld%lld%lld%d", &b, &q, &l, &m );

	for ( int i =0; i<m; i++ ) scanf("%lld", &bad[i]);

	sort(bad, bad+m);

	if(q<1)  reverse(bad, bad+m);

	int x, ans=0, flag = 1 ;

	for(int i=0; fabs(b)<l, i<m; i++)  {

		if( flag == 0 ) break;

 		if(q<1 ){

			if( b == bad[i] ) continue;

			if( b >  bad[i] ){

				while(b>bad[i] && fabs(b)<l){

					ans++;

					b*=q;

				}

			}

		}

		if(q>1 ){

			if( b == bad[i] ) continue;

			if( b <  bad[i] ){

				while(b < bad[i] && fabs(b)<l){

					b*=q;

					ans ++;

				}

				ans--;

			}

		}

		if(q==1) {

			if( b == bad[i]) break;

			if( b <bad[i] ) {  flag = 0;  break; }

			}

	}

	if(fabs(b)>l) ans -=log(b/l)/log(q);

 	if( flag )  printf("%d\n", ans);

	else  puts("inf");

}


#include <bits/stdc++.h>

using namespace std;

map<int, int> mp;

int main(){

	long long a, b, q, l, m ,i;

	while(~scanf("%I64d%I64d%I64d%I64d", &b, &q, &l, &m)){

		mp.clear();

		for(i=0; i<m; i++){

			scanf("%I64d", &a);

			mp[a]=1;

		}

		long long cnt=0;

		if(b==0){

			if(mp[b]==0) puts("inf");

			else puts("0");

			continue;

		}

		if(mp[b]==0&&abs(b)<=l) cnt=1;

		if(q==0){

			if(mp[0]==0) puts("inf");

			else printf("%I64d\n", cnt);

			continue;

		}

		if(q==1){

			if(cnt) puts("inf");

			else puts("0");

			continue;

		}

		if(q==-1){

			if(cnt||(mp[-b]==0&&abs(b)<=l)) puts("inf");

			else puts("0");

			continue;

		}

		while(abs(b*q)<=l){

			b*=q;

			if(!mp[b])cnt++;

		}

		printf("%I64d\n", cnt);

	}

}


#include<bits/stdc++.h>

using namespace std;

long long b,q,l,a;

set<long long> s;

int m,i,num,ans;

int main(){

	scanf("%I64d%I64d%I64d%d",&b,&q,&l,&m);

	for(i=0;i<m;i++){

		scanf("%I64d",&a);

		if(a%b) continue;

		s.insert(a);

	}

	if(q==0){

		if(s.count(0)){

			if(s.count(b)) puts("0");

			else puts("1");

		}

		else puts("inf");

		return 0;

	}

	if(q==1){

		if(!s.count(b)) puts("inf");

		else puts("0");

		return 0;

	}

	if(q==-1){

		if(s.count(b)&&s.count(-b)) puts("0");

		else puts("inf");

		return 0;

	}

	while(abs(b)<=l){

		if(!s.count(b)) ans++;

		b*=q;

	}

	printf("%d\n",ans);

	return 0;

}


#include<bits/stdc++.h>

using namespace std;

#define NN 110000

map<long long ,int>mp;

long long b1,q,l,m,a[NN],ans;

int main()

{

//	freopen("in.txt","r",stdin);

	scanf("%I64d%I64d%I64d%I64d", &b1, &q, &l, &m);

    mp.clear();

	for(int i=0; i<m; i++) scanf("%I64d", a+i), mp[a[i]]=1;

	if(abs(b1)>l){ puts("0"); return 0;}

	if(b1==0 || q==1){

		if(!mp[b1]) puts("inf");

		else  puts("0");

	}

	else if(q==-1){

		if(!mp[b1] || !mp[-b1])puts("inf");

		else puts("0");

	}

	else if(q==0){

		if(!mp[0])puts("inf");

		else if(!mp[b1])puts("1");

		else puts("0");

	}

	else{

		while(abs(b1)<=l){

			if(!mp[b1])ans++;

			b1*=q;

		}

		printf("%I64d\n",ans);

	}

	return 0;

}


#include<bits\stdc++.h>

using namespace std;

typedef long long INT;

typedef pair<int,int> pii;

#define NN 11111111

set <long long> mp;

long long a[NN];

int main(){

	INT b,q,l,m;

	INT cnt;

	int i;

	while(scanf("%lld%lld%lld%lld",&b,&q,&l,&m)==4){

		mp.clear();

		for(i=0;i<m;i++){

			scanf("%lld",&a[i]);

			mp.insert(a[i]);

		}

		cnt=0;

		if(abs(b)>l){puts("0");continue;}

		if(b==0){

			if(mp.find(b)==mp.end())

				puts("inf");

			else

				puts("0");

			continue;

			}

		if(q==0){

			if(mp.find(0)==mp.end())

				puts("inf");

			else{

				if(mp.find(b)==mp.end())

					puts("0");

				else puts("1");

			}

			continue;

		}

		if(q==1){

			if(mp.find(b)==mp.end())

				puts("inf");

			else

				puts("0");

				continue;

			}

		if(q==-1){

			if(mp.find(b)!=mp.end() && mp.find(-b)!=mp.end())

				puts("2");

			else

				puts("inf");

			continue;

			}

		while(b<=l){

			if(mp.find(b)==mp.end())

				cnt++;

			b*=q;

		}

		printf("%lld\n",cnt);

	}

	return 0;

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define mod 1000000007

#define pb push_back

#define mp make_pair

#define sq(x) ((x)*(x))

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

inline void gn(long long&x){

	int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');

	while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;

}

inline void gn(int&x){long long t;gn(t);x=t;}

inline void gn(unsigned long long&x){long long t;gn(t);x=t;}

inline void gn(double&x){double t;scanf("%lf",&t);x=t;}

inline void gn(long double&x){double t;scanf("%lf",&t);x=t;}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

INT a[100010];

map<INT, int> vst;

int main(){

	INT b, q, l, m, cnt=0;

	scanf("%I64d%I64d%I64d%I64d", &b, &q, &l, &m);

	for(int i=0; i<m; i++){

		scanf("%I64d", a+i);

		vst[a[i]]=1;

	}

	if (abs(q)<2 || b==0) {

		INT bb=b*q;

		if (abs(bb)<=l && (!vst.count(b*q) || !vst.count(b*q*q))) {

			puts("inf");

			return 0;

		}

		if (vst.count(b) || abs(b)>l) puts("0");

		else puts("1");

		return 0;

	}

	while (abs(b)<=l){

		if(!vst.count(b)) cnt++;

		b*=q;

	}

	cout<<cnt<<endl;

	return 0;

}


#include<bits/stdc++.h>

using namespace std;

typedef long long INT;

#define MM 101000

int b1,q,l,m,a[MM];

long long pow(int k,int p)

{

	if(p==0)return 1;

	if(p%2==1) return pow(k,p/2)*pow(k,p/2)*k;

	else return pow(k,p/2)*pow(k,p/2);

}

int main()

{

	int i,j;

//	freopen("in.txt","r",stdin);

	scanf("%d%d%d%d",&b1,&q,&l,&m);

	for(int i=0;i<m;i++) scanf("%d",a+i);

	if(l<abs(b1)){puts("inf");return 0;}

	else if(q==-1 || q==0){

			int f=0;

			for(i=0;i<m;i++){

				if(a[i]==b1)f++;

				if(a[i]==-b1 && q==-1)f++;

				else if(a[i]==0 && q==0)f++;

				if(f==2)break;

			}

			if(f==2)puts("0");

			else if(f==1)puts("1");

			else puts("inf"); return 0;

	}

	else if(b1==0 || q==1){

			for(i=0;i<m;i++)if(a[i]==b1)break;

			if(i<m)puts("0");

			else puts("inf"); return 0;

	}

	else {

		int qq=q,bb1=b1;

		if(q<0)qq=-q;

		if(b1<0)bb1=-b1;

		int k=log(double(l)/double(bb1))/log(double(qq))+1;

		for(i=0;i<m;i++){

			if(a[i]>l)continue;

			int r=a[i]/b1;

			if(r<0)r=-r;

			int p=log(double(r))/log(double(qq));

			if(1LL*pow(q,p)*b1==1LL*a[i])k--;

		}

		printf("%d\n",k);

	}

}


#include<bits/stdc++.h>

using namespace std;

long long b,q,l,a[100010];

int ok(long long a,long long q){

	while(a>q){

		if(a%q) return 0;

		a/=q;

	}

	if(a%q) return 0;

	else return 1;

}

int m,i,x0,x_1,x1,xb,x_b,ans;

int main(){

	scanf("%I64d%I64d%I64d%d",&b,&q,&l,&m);

	for(i=0;i<m;i++){

		scanf("%I64d",a+i);

		if(!a[i]) x0=1;

		if(a[i]==1) x1=1;

		if(a[i]==-1) x_1=1;

		if(a[i]==b) xb=1;

		if(a[i]==-b) x_b=1;

	}

	if(!q){

		if(x0){

			if(xb) puts("0");

			else puts("1");

		}

		else puts("inf");

		return 0;

	}

	if(q==1){

		if(xb) puts("0");

		else puts("inf");

		return 0;

	}

	if(q==-1){

		if(xb||x_b) puts("inf");

		else puts("0");

		return 0;

	}

	while(abs(b)<=l){

		int o=1;

		for(i=0;i<m;i++)

			if(a[i]%b==0&&ok(a[i]/b,q)&&a[i]<=l){

				o=0;

				break;

			}

		if(o) ans++;

		b*=q;

	}

	printf("%d\n",ans);

	return 0;

}


#include<bits/stdc++.h>

using namespace std;

#define NN 111111

typedef long long INT;

set<int> s;

int main (){

	INT  bad[NN], b, q, l, i, x, m;

	int  flag=0, ret=1, ans=0;

	scanf("%lld%lld%lld%lld", &b, &q, &l, &m );

	s.clear();

	for( i=0; i<m; i++ ) {

		scanf("%d", &x);

		s.insert(x);

	}

	if( abs(b)>l ) { puts("0"); return 0; }

	if( b == 0 ){

		if( s.find(0) != s.end() ) puts("0");

		else puts("inf");

		return 0;

	}

	if(q==1) {

			if(s.find(b) != s.end())  puts("0");

			puts("inf");

			return 0;

		}

	if(q ==-1 ) {

			if(s.find(b) != s.end() && s.find(-b) != s.end())  puts("0");

			else puts("inf");

			return 0;

		}

	if(q == 0)  {

			if( s.find(0) == s.end())  puts("inf");

			else if(s.find(b) != s.end()) puts("0");

			else puts("1");

			return 0;

		};

	while ( abs(b)<=l ){

		if(s.find(b) == s.end()) ans++;

		b*=q;

	}

	printf("%d\n", ans);

	return 0;

}


#include<bits/stdc++.h>

using namespace std;

long long b,q,l,n,a[100010];

int ok(long long a,long long q){

	while(a>q){

		if(a%q) return 0;

		a/=q;

	}

	if(a%q) return 0;

	else return 1;

}

int m,i,x0,x_1,x1,xb,x_b,num;

int main(){

	scanf("%I64d%I64d%I64d%d",&b,&q,&l,&m);

	for(i=0;i<m;i++){

		scanf("%I64d",a+i);

		if(!a[i]) x0=1;

		if(a[i]==1) x1=1;

		if(a[i]==-1) x_1=1;

		if(a[i]==b) xb=1;

		if(a[i]==-b) x_b=1;

	}

	if(!q){

		if(x0){

			if(xb) puts("0");

			else puts("1");

		}

		else puts("inf");

		return 0;

	}

	if(q==1){

		if(xb) puts("0");

		else puts("inf");

		return 0;

	}

	if(q==-1){

		if(xb||x_b) puts("inf");

		else puts("0");

		return 0;

	}

	n=l/abs(b);

	while(n){

		num++;

		n/=q;

	}

	for(i=0;i<m;i++)

		if(a[i]%b==0&&a[i]<=l){

			a[i]/=b;

			num-=ok(a[i],q);

		}

	printf("%d\n",num);

	return 0;

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define mod 1000000007

#define pb push_back

#define mp make_pair

#define sq(x) ((x)*(x))

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

inline void gn(long long&x){

	int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');

	while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;

}

inline void gn(int&x){long long t;gn(t);x=t;}

inline void gn(unsigned long long&x){long long t;gn(t);x=t;}

inline void gn(double&x){double t;scanf("%lf",&t);x=t;}

inline void gn(long double&x){double t;scanf("%lf",&t);x=t;}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

INT a[100010];

map<INT, int> vst;

int main(){

	INT b, q, l, m, cnt=0;

	scanf("%I64d%I64d%I64d%I64d", &b, &q, &l, &m);

	for(int i=0; i<m; i++){

		scanf("%I64d", a+i);

		vst[a[i]]=1;

	}

	if (abs(q)<2) {

		if (!vst.count(b*q) || !vst.count(b*q*q)) {

			puts("inf");

			return 0;

		}

		if (vst.count(b)) puts("0");

		else puts("1");

		return 0;

	}

	while (abs(b)<=l){

		if(!vst.count(b)) cnt++;

		b*=q;

	}

	cout<<cnt<<endl;

	return 0;

}


#include <bits/stdc++.h>

using namespace std;

map<int, int> mp;

int main(){

	int a, b, q, l, m ,i;

	while(~scanf("%d%d%d%d", &b, &q, &l, &m)){

		mp.clear();

		for(i=0; i<m; i++){

			scanf("%d", &a);

			mp[a]=1;

		}

		int cnt=0;

		if(b==0){

			if(mp[b]==0) puts("inf");

			else puts("0");

			continue;

		}

		if(mp[b]==0&&b<=l) cnt=1;

		if(q==0){

			if(mp[0]==0) puts("inf");

			else printf("%d\n", cnt);

			continue;

		}

		if(q==1){

			if(cnt) puts("inf");

			else puts("0");

			continue;

		}

		if(q==-1){

			if(cnt||(mp[-b]==0&&b<=l)) puts("inf");

			else puts("0");

			continue;

		}

		while(abs(b*q)<=l){

			b*=q;

			if(mp[b]==0) cnt++;

		}

		printf("%d\n", cnt);

	}

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define mod 1000000007

#define pb push_back

#define mp make_pair

#define sq(x) ((x)*(x))

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

inline void gn(long long&x){

	int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');

	while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;

}

inline void gn(int&x){long long t;gn(t);x=t;}

inline void gn(unsigned long long&x){long long t;gn(t);x=t;}

inline void gn(double&x){double t;scanf("%lf",&t);x=t;}

inline void gn(long double&x){double t;scanf("%lf",&t);x=t;}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

INT a[100010];

map<INT, int> vst;

int main(){

	INT b, q, l, m, cnt=0;

	scanf("%I64d%I64d%I64d%I64d", &b, &q, &l, &m);

	for(int i=0; i<m; i++){

		scanf("%I64d", a+i);

		vst[a[i]]=1;

	}

	while (abs(b)<=l){

		if(!vst.count(b)) cnt++;

		b*=q;

	}

	cout<<cnt<<endl;

	while(abs(q)<=1){

		if(!vst.count(b)) puts("inf");

		else puts("0");}

	return 0;

}


#include<bits/stdc++.h>

using namespace std;

typedef long long int64;

int64 a[110000];

set<int64> aa;

int main(){

	long long c,q,l,m;

	scanf("%lld%lld%lld%lld",&c,&q,&l,&m);

		int i;

		aa.clear();

		for(i=0;i<m;i++){

			cin>>a[i];

			aa.insert(a[i]);

		}

		if(abs(c)>l){ puts("0"); return 0;}

		if(c==0) {

			if(aa.find(0)!= aa.end()) puts("0");

			else puts("inf");

			return 0;

		}

		if(q==0){

			if(aa.find(0)==aa.end()) puts("inf");

			else if((aa.find(c)!=aa.end())) puts("0");

			else puts("1");

			return 0;

		}

		if(q==1){

			if(aa.find(c)!=aa.end()) puts("0");

			else puts("inf");

			return 0;

		}

		if(q==-1){

			if(aa.find(c)!=aa.end()&&aa.find(-c)!=aa.end()) puts("0");

			else puts("inf");

			return 0;

		}

		long long cnt=0;

		while(abs(c)<=l){

			if(aa.find(c)==aa.end()) cnt++;

			c*=q;

		}

		cout<<cnt<<endl;

	return 0;

}


#include <iostream>

#include <algorithm>

#include <stdio.h>

#include <math.h>

using namespace std;

long long b1, q, l, m, i, a[100050], c = 0, k, s = 0;

int main() {

	cin>>b1>>q>>l>>m;

	for(i = 0; i < m; i++ ) {

		cin>>a[i];

	}

	if (b1 = 0){

			for(i = 0; i < m; i++ ) {

					if ( a[i] == 0) s = 0;return 0;

			}

			cout<<1<<endl; return 0;

	}

	else if (b1 > l || b1 < -l) {

		cout<<0<<endl; return 0;

	}

	else {

		if (q == 1){

			k = 0;

			for(i = 0; i < m; i++ ) {

				if (b1 == a[i]) k = 1;

			}

			if (k == 1) {

				cout<<0<<endl; return 0;

			}

			else {

				cout<<"inf"<<endl; return 0;

			}

		}

		else if (q == -1) {

			k = 0;

			for (i = 0; i < m; i++ ) {

				if (b1 == a[i] || b1 == -a[i]) k = 1;

			}

			if ( k == 1){

				cout<<0<<endl; return 0;

			}

			else {

				cout<<"inf"<<endl; return 0;

			}

		}

		else{

			k = 1;

			c = b1;

			while (c < l + 1 && c > -l - 1){

				k = 1;

				for(i = 0; k == 1 && i < m; i++ ) {

					if (c == a[i]) k = 0;

				}

				if (k == 1) s++;

				c = c * q;

			}

			cout<<s<<endl;

		}

	}

	return 0;

}


#include<bits/stdc++.h>

using namespace std;

#define NN 111111

typedef long long INT;

set<int> s;

int main (){

	INT  bad[NN], b, q, l, i, x, m;

	int  flag=0, ret=1;

	scanf("%lld%lld%lld%lld", &b, &q, &l, &m );

	s.clear();

	for( i=0; i<m; i++ ) {

		scanf("%d", &x);

		s.insert(x);

	}

	if( abs(b)>l ) { puts("0"); return 0; }

	if( b == 0 ){

		if( s.find(0) != s.end() ) puts("0");

		else puts("inf");

		return 0;

	}

	if(q==1) {

			if(s.find(b) != s.end())  puts("0");

			puts("inf");

			return 0;

		}

	if(q ==-1 ) {

			if(s.find(b) != s.end() && s.find(-b) != s.end())  puts("0");

			else puts("inf");

			return 0;

		}

	if(q == 0)  {

			if( s.find(0) == s.end())  puts("inf");

			else if(s.find(b) != s.end()) puts("0");

			else puts("1");

			return 0;

	}

	INT ans = 0;

	while ( abs(b)<=l ){

		if(s.find(b) == s.end()) ans++;

		b*=q;

	}

	printf("%lld\n", ans);

	return 0;

}


#include <bits/stdc++.h>

using namespace std;

map<long long, int> mp;

int main(){

	long long a, b, q, l, m ,i;

	while(~scanf("%I64d%I64d%I64d%I64d", &b, &q, &l, &m)){

		mp.clear();

		for(i=0; i<m; i++){

			scanf("%I64d", &a);

			mp[a]=1;

		}

		if(abs(b)>l){

			puts("0");

			continue;

		}

		long long cnt=0;

		if(b==0){

			if(mp[b]==0) puts("inf");

			else puts("0");

			continue;

		}

		if(mp[b]==0&&abs(b)<=l) cnt=1;

		if(q==0){

			if(mp[0]==0) puts("inf");

			else printf("%I64d\n", cnt);

			continue;

		}

		if(q==1){

			if(cnt) puts("inf");

			else puts("0");

			continue;

		}

		if(q==-1){

			if(cnt||(mp[-b]==0&&abs(b)<=l)) puts("inf");

			else puts("0");

			continue;

		}

		while(abs(b*q)<=l){

			b*=q;

			if(!mp[b])cnt++;

		}

		printf("%I64d\n", cnt);

	}

}


#include<bits/stdc++.h>

using namespace std;

#define NN 111111

typedef long long INT;

map<int, int> mp;

int main (){

	INT  bad[NN], b, q, l, i, x;

	int m, flag=0, ret=1, ans=0;

	scanf("%lld%lld%lld%d", &b, &q, &l, &m );

	mp.clear();

	for( i=0; i<m; i++ ) {

		scanf("%d", &x);

		mp[x] = ret;

	}

	if( abs(b)>l ) { puts("0"); return 0; }

	if(q==1) {

			if(mp.find(b) != mp.end())  puts("0");

			return 0;

		}

	if(q ==-1 ) {

			if(mp.find(b) != mp.end() && mp.find(-b) != mp.end())  puts("0");

			else puts("inf");

			return 0;

		}

	if(q == 0)  {

			if(mp.find(b) != mp.end() && mp.find(0) != mp.end())  puts("0");

			else puts("inf");

			return 0;

		};

	while ( abs(b)<l ){

		if(mp.find(b) == mp.end()) ans++;

		b*=q;

	}

	printf("%d", ans);

	return 0;

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define mod 1000000007

#define pb push_back

#define mp make_pair

#define sq(x) ((x)*(x))

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

inline void gn(long long&x){

	int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');

	while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;

}

inline void gn(int&x){long long t;gn(t);x=t;}

inline void gn(unsigned long long&x){long long t;gn(t);x=t;}

inline void gn(double&x){double t;scanf("%lf",&t);x=t;}

inline void gn(long double&x){double t;scanf("%lf",&t);x=t;}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

INT a[100010];

map<INT, int> vst;

int main(){

	INT b, q, l, m, cnt=0;

	scanf("%I64d%I64d%I64d%I64d", &b, &q, &l, &m);

	for(int i=0; i<m; i++){

		scanf("%I64d", a+i);

		vst[a[i]]=1;

	}

	if (abs(q)<2) {

		if (!vst.count(b*q) || !vst.count(b*q*q)) {

			puts("inf");

			return 0;

		}

		if (vst.count(b) || abs(b)>l) puts("0");

		else puts("1");

		return 0;

	}

	while (abs(b)<=l){

		if(!vst.count(b)) cnt++;

		b*=q;

	}

	cout<<cnt<<endl;

	return 0;

}


#include <bits/stdc++.h>

using namespace std;

map<long long, int> mp;

int main(){

	long long a, b, q, l, m ,i;

	while(~scanf("%I64d%I64d%I64d%I64d", &b, &q, &l, &m)){

		mp.clear();

		for(i=0; i<m; i++){

			scanf("%I64d", &a);

			mp[a]=1;

		}

		long long cnt=0;

		if(b==0){

			if(mp[b]==0) puts("inf");

			else puts("0");

			continue;

		}

		if(mp[b]==0&&abs(b)<=l) cnt=1;

		if(q==0){

			if(mp[0]==0) puts("inf");

			else printf("%I64d\n", cnt);

			continue;

		}

		if(q==1){

			if(cnt) puts("inf");

			else puts("0");

			continue;

		}

		if(q==-1){

			if(cnt||(mp[-b]==0&&abs(b)<=l)) puts("inf");

			else puts("0");

			continue;

		}

		while(abs(b*q)<=l){

			b*=q;

			if(!mp[b])cnt++;

		}

		printf("%I64d\n", cnt);

	}

}


#include <iostream>

#include <algorithm>

#include <stdio.h>

#include <math.h>

using namespace std;

long long b1, q, l, m, i, a[100050], c = 0, k, s = 0;

int main() {

	cin>>b1>>q>>l>>m;

	for(i = 0; i < m; i++ ) {

		cin>>a[i];

	}

	if (b1 = 0){

			for(i = 0; i < m; i++ ) {

					if ( a[i] != 0) s++;

			}

			cout<<s<<endl; return 0;

	}

	else if (b1 > l || b1 < -l) {

		cout<<0<<endl; return 0;

	}

	else {

		if (q == 1){

			k = 0;

			for(i = 0; i < m; i++ ) {

				if (b1 == a[i]) k = 1;

			}

			if (k == 1) {

				cout<<0<<endl; return 0;

			}

			else {

				cout<<"inf"<<endl; return 0;

			}

		}

		else if (q == -1) {

			k = 0;

			for (i = 0; i < m; i++ ) {

				if (b1 == a[i] || b1 == -a[i]) k = 1;

			}

			if ( k == 1){

				cout<<0<<endl; return 0;

			}

			else {

				cout<<"inf"<<endl; return 0;

			}

		}

		else{

			k = 1;

			c = b1;

			while (c < l + 1 && c > -l - 1){

				k = 1;

				for(i = 0; k == 1 && i < m; i++ ) {

					if (c == a[i]) k = 0;

				}

				if (k == 1) s++;

				c = c * q;

			}

			cout<<s<<endl;

		}

	}

	return 0;

}


#include<bits\stdc++.h>

using namespace std;

typedef long long INT;

typedef pair<int,int> pii;

#define NN 11111111

set <long long> mp;

long long a[NN];

int main(){

	INT b,q,l,m;

	INT cnt;

	int i;

	while(scanf("%lld%lld%lld%lld",&b,&q,&l,&m)==4){

		mp.clear();

		for(i=0;i<m;i++){

			scanf("%lld",&a[i]);

			mp.insert(a[i]);

		}

		cnt=0;

		if(abs(b)>l){puts("0");continue;}

		if(b==0){

			if(mp.find(b)==mp.end())

				puts("inf");

			else

				puts("0");

			continue;

			}

		if(q==0){

			if(mp.find(0)==mp.end())

				puts("inf");

			else{

				if(mp.find(b)==mp.end())

					puts("0");

				else puts("1");

			}

			continue;

		}

		if(q==1){

			if(mp.find(b)==mp.end())

				puts("inf");

			else

				puts("0");

				continue;

			}

		if(q==-1){

			if(mp.find(b)!=mp.end() && mp.find(-b)!=mp.end())

				puts("0");

			else

				puts("inf");

			continue;

			}

		while(b<=l){

			if(mp.find(b)==mp.end())

				cnt++;

			b*=q;

		}

		printf("%lld\n",cnt);

	}

	return 0;

}


#include<bits/stdc++.h>

using namespace std;

map<long long,int>mp;

long long b,q,l,m,a,ans,i;

int main(){

	scanf("%I64d%I64d%I64d%I64d",&b,&q,&l,&m);

	for(i=0;i<m;i++) scanf("%I64d",&a),mp[a]=1;

	if(abs(b)>l) puts("0");

	else if(!b||q==1){

		if(mp[b]) puts("0");

		else puts("inf");

	}

	else if(q==-1){

		if(mp[b]&&mp[-b]) puts("0");

		else puts("inf");

	}

	else if(!q){

		if(mp[0]) printf("%d",!mp[b]);

		else puts("inf");

	}

	else{

		while(abs(b)<=l){

			if(!mp[b]) ans++;

			b*=q;

		}

		printf("%I64d\n",ans);

	}

	return 0;

}


#include <iostream>

#include <algorithm>

#include <stdio.h>

#include <math.h>

using namespace std;

long long b1, q, l, m, i, a[100050], c = 0, k, s = 0;

int main() {

	cin>>b1>>q>>l>>m;

	for(i = 0; i < m; i++ ) {

		cin>>a[i];

	}

	if (b1 > l || b1 < -l) {

		cout<<0<<endl; return 0;

	}

	else {

		if (q == 1){

			k = 0;

			for(i = 0; k == 0 && i < m; i++ ) {

				if (b1 == a[i]) k = 1;

			}

			if (k == 1) {

				cout<<0<<endl; return 0;

			}

			else {

				cout<<"inf"<<endl; return 0;

			}

		}

		else if (q == -1) {

			k = 0;

			for (i = 0; k == 0 && i < m; i++ ) {

				if (b1 == a[i] || b1 == -a[i]) k = 1;

			}

			if ( k == 1){

				cout<<0<<endl; return 0;

			}

			else {

				cout<<"inf"<<endl; return 0;

			}

		}

		else if (q == 0 || b1 == 0) {

			k = 0;

			for (i = 0; k == 0 && i < m; i++ ) {

				if (a[i] == 0) k = 1;

			}

			if ( k == 1){

				cout<<0<<endl; return 0;

			}

			else {

				cout<<"inf"<<endl; return 0;

			}

		}

		else{

			k = 1;

			c = b1;

			while (c < l + 1 && c > -l - 1){

				k = 1;

				for(i = 0; k == 1 && i < m; i++ ) {

					if (c == a[i]) k = 0;

				}

				if (k == 1) s++;

				c = c * q;

			}

			cout<<s<<endl;

		}

	}

	return 0;

}


#include <bits/stdc++.h>

using namespace std;

map<int, int> mp;

int main(){

	int a, b, q, l, m ,i;

	while(~scanf("%d%d%d%d", &b, &q, &l, &m)){

		mp.clear();

		for(i=0; i<m; i++){

			scanf("%d", &a);

			mp[a]=1;

		}

		int cnt=0;

		if(b==0){

			if(mp[b]==0) puts("inf");

			else puts("0");

			continue;

		}

		if(mp[b]==0&&b<=l) cnt=1;

		if(q==0){

			if(mp[0]==0) puts("inf");

			else printf("%d\n", cnt);

			continue;

		}

		if(q==1){

			if(cnt) puts("inf");

			else puts("0");

			continue;

		}

		if(q==-1){

			if(cnt||(mp[-b]==0&&b<=l)) puts("inf");

			else puts("0");

			continue;

		}

		cnt=1;

		while(abs(b*q)<=l){

			b*=q;

			cnt++;

		}

		printf("%d\n", cnt);

	}

}


#include<bits/stdc++.h>

using namespace std;

#define NN 111111

typedef long long INT;

map<int, int> mp;

int main (){

	INT  bad[NN], b, q, l, i, x;

	int m, flag=0, ret=1, ans=0;

	scanf("%lld%lld%lld%d", &b, &q, &l, &m );

	mp.clear();

	for( i=0; i<m; i++ ) {

		scanf("%d", &x);

		mp[x] = ret;

	}

	if( abs(b)>l ) { puts("0"); return 0; }

	if(q==1) {

			if(mp.find(b) != mp.end())  puts("0");

			return 0;

		}

	if(q ==-1 ) {

			if(mp.find(b) != mp.end() && mp.find(-b) != mp.end())  puts("0");

			else puts("inf");

			return 0;

		}

	if(q == 0)  {

			if(mp.find(b) != mp.end() && mp.find(0) != mp.end())  puts("0");

			else puts("inf");

			return 0;

		};

	while ( abs(b)<=l ){

		if(mp.find(b) == mp.end()) ans++;

		b*=q;

	}

	printf("%d", ans);

	return 0;

}


#include<bits/stdc++.h>

using namespace std;

long long a[111111];

set<long long> aa;

int main(){

	long long c,q,l,m;

	scanf("%lld%lld%lld%lld",&c,&q,&l,&m);

		int i;

		for(i=0;i<m;i++){

			scanf("%lld",a+i);

			aa.insert(a[i]);

		}

		if(c==0) {

			if(aa.find(0)!= aa.end()) puts("0");

			else puts("inf");

			return 0;

		}

		if(q==0){

			if(aa.find(0)==aa.end()) puts("inf");

			else if(aa.find(c)!=aa.end()||abs(c)>l) puts("0");

			else puts("0");

			return 0;

		}

		if(abs(c)>l) {puts("0");return 0;}

		if(q==1){

			if(aa.find(c)!=aa.end()) puts("0");

			else puts("inf");

			return 0;

		}

		if(q==-1){

			if(aa.find(c)!=aa.end()&&aa.find(-c)!=aa.end()) puts("0");

			else puts("inf");

			return 0;

		}

		int cnt=0;

		while(abs(c)<=l){

			if(aa.find(c)==aa.end()) cnt++;

			c*=q;

		}

		printf("%d\n", cnt);

	return 0;

}


#include<bits/stdc++.h>

using namespace std;

long long a[111111];

set<long long> aa;

int main(){

	long long c,q,l,m;

	scanf("%lld%lld%lld%lld",&c,&q,&l,&m);

		int i;

		aa.clear();

		for(i=0;i<m;i++){

			scanf("%lld",a+i);

			aa.insert(a[i]);

		}

		if(c==0) {

			if(aa.find(0)!= aa.end()) puts("0");

			else puts("inf");

			return 0;

		}

		if(q==0){

			if(aa.find(0)==aa.end()) puts("inf");

			else if((aa.find(c)!=aa.end())||abs(c)>l) puts("0");

			else puts("1");

			return 0;

		}

		if(abs(c)>l) {puts("0");return 0;}

		if(q==1){

			if(aa.find(c)!=aa.end()) puts("0");

			else puts("inf");

			return 0;

		}

		if(q==-1){

			if(aa.find(c)!=aa.end()&&aa.find(-c)!=aa.end()) puts("0");

			else puts("inf");

			return 0;

		}

		long long cnt=0;

		while(abs(c)<=l){

			if(aa.find(c)==aa.end()) cnt++;

			c*=q;

		}

		printf("%lld\n", cnt);

	return 0;

}


#include <iostream>
#include <cstring>
#include <string>
using namespace std;
int main()
{
    char ch;
    char b[4];
    int a,x=0;
    cin>>a;
    cin.get(ch);
    //cin.get();
    for(int i=0;i<a;i++)
    {

    cin.getline(b,4,'\n');

    if(!strcmp(b,"X++")||!strcmp(b,"++X"))
    	++x;

	if(!strcmp(b,"X--")||!strcmp(b,"--X"))
    	--x;

}
cout<<x;
return 0;
}


#include <iostream>
#include <cstring>
#include <string>
using namespace std;
int main()
{
    char ch;
    char b[4];
    int a,x=0;
    cin>>a;
    cin.get(ch);
    //cin.get();
    for(int i=0;i<a;i++)
    {

    cin.getline(b,3,'\n');

    if(strcmp(b,"X++")||strcmp(b,"++X"))
    	++x;

	if(strcmp(b,"X--")||strcmp(b,"--X"))
    	--x;

}
cout<<x;
return 0;
}


#include <stdio.h>

int main()
{
	int lim;
	int len, num = 0;
	char input[4];

	scanf("%d", &lim);

	for(int i = 0; i < lim; i++)
	{
		scanf("%s", &input[i]);

		if(input[0] == 'X')
		{
			if(input[1] == '+')
			{
				num++;
			}
			else if(input[1] == '-')
			{
				num--;
			}
		}
		else if(input[0] == '+')
		{
			++num;
		}
		else if(input[0] == '-')
		{
			--num;
		}
	}

	printf("%d", num);

	return 0;
}


#include <stdio.h>

int main()
{
	int lim;
	int len, num = 0;
	char input[100] = {NULL};

	scanf("%d", &lim);getchar();

	for(int i = 0; i < lim; i++)
	{
		scanf("%s", &input[i]);getchar();

		if(input[1] == '+')
		{
			num++;
		}
		else if(input[1] == '-')
		{
			num--;
		}

		printf("%d\n", num);
	}

	printf("%d", num);

	return 0;
}


#include<stdio.h>

int main()
{

	int lim, num = 0;
	char input[4];

	scanf("%d\n", &lim);

	for(int i = 0; i < lim; i++)
	{
		gets(input);

		num = num + 44 - input[1];
	}

	printf("%d",num);

	return 0;
}


#include <stdio.h>

int main()
{
	int lim;
	int len, num;
	char input[100];

	scanf("%d", &lim);getchar();

	for(int i = 0; i < lim; i++)
	{
		num = 0;

		scanf("%s", &input[i]);getchar();

		if(input[0] == 'X')
		{
			if(input[1] == '+')
			{
				num++;
			}
			else if(input[1] == '-')
			{
				num--;
			}
		}
		else if(input[0] == '+')
		{
			++num;
		}
		else if(input[0] == '-')
		{
			--num;
		}
	}

	printf("%d", num);

	return 0;
}


#include <stdio.h>

int main()
{
	int lim;
	int len, num = 0;
	char input[100] = {NULL};

	scanf("%d", &lim);getchar();

	for(int i = 0; i < lim; i++)
	{
		scanf("%s", &input[i]);getchar();

		if(input[0] == 'X')
		{
			if(input[1] == '+')
			{
				num += 1;
			}
			else if(input[1] == '-')
			{
				num -= 1;
			}
		}
		else if(input[0] == '+')
		{
			num += 1;
		}
		else if(input[0] == '-')
		{
			num -= 1;
		}
	}

	printf("%d", num);

	return 0;
}


#include <stdio.h>

int main()
{
	int lim;
	int len, num = 0;
	char input[100] = {NULL};

	scanf("%d", &lim);getchar();

	for(int i = 0; i < lim; i++)
	{
		scanf("%s", &input[i]);getchar();

		if(input[1] == '+')
		{
			num++;
		}
		else num--;
	}

	printf("%d", num);

	return 0;
}


#include <stdio.h>

int main()
{
	int lim;
	int len, num;
	char input[100];

	scanf("%d", &lim);getchar();

	for(int i = 0; i < lim; i++)
	{
		num = 0;

		scanf("%s", &input[i]);getchar();

		if(input[0] == 'X')
		{
			if(input[1] == '+')
			{
				num++;
			}
			else if(input[1] == '-')
			{
				num--;
			}
		}
		else if(input[0] == '+')
		{
			num++;
		}
		else if(input[0] == '-')
		{
			num++;
		}
	}

	printf("%d", num);

	return 0;
}


#include <stdio.h>

int main()
{
	int lim;
	int len, num = 0;
	char input[100] = {NULL};

	scanf("%d", &lim);getchar();

	for(int i = 0; i < lim; i++)
	{
		scanf("%s", &input[i]);getchar();

		if(input[0] == 'X')
		{
			if(input[1] == '+')
			{
				num++;
			}
			else if(input[1] == '-')
			{
				num--;
			}
		}
		else if(input[0] == '+')
		{
			++num;
		}
		else if(input[0] == '-')
		{
			--num;
		}
	}

	printf("%d", num);

	return 0;
}


#include <stdio.h>

int main()
{
	int lim;
	int len, num = 0;
	char input[100] = {NULL};

	scanf("%d", &lim);getchar();

	for(int i = 0; i < lim; i++)
	{
		scanf("%s", &input[i]);getchar();

		if(input[1] == '+')
		{
			num++;
		}
		else if(input[1] == '-')
		{
			num--;
		}
	}

	printf("%d", num);

	return 0;
}


#include <stdio.h>

int main()
{
	int lim;
	int len, num = 0;
	char input[100] = {NULL};

	scanf("%d", &lim);getchar();

	for(int i = 0; i < lim; i++)
	{
		scanf("%s", &input[i]);getchar();

		if(input[0] == 'X')
		{
			if(input[1] == '+')
			{
				num + 1;
			}
			else if(input[1] == '-')
			{
				num - 1;
			}
		}
		else if(input[0] == '+')
		{
			num + 1;
		}
		else if(input[0] == '-')
		{
			num - 1;
		}
	}

	printf("%d", num);

	return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main(){
	int n , result=0;
	string str;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin>>str;
			switch (str[1])
			{
			case '+':
				result++;
				break;
			case '-':
				result--;
				break;
			}

	}
	cout << result << endl;
	return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main(){
	int n , result=0;
	string str;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin>>str;
		for (int j = 0; j < 2; j++)
		{
			switch (str[j])
			{
			case '+':
				result++;
				break;
				break;
			case '-':
				result--;
				break;
				break;
			}

		}
	}
	cout << result << endl;
	system("pause");
	return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main(){
	int n , result=0;
	string str;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin>>str;
			switch (str[1])
			{
			case '+':
				result++;
				break;
			case '-':
				result--;
				break;
			}

	}
	cout << result << endl;
	system("pause");
	return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main(){
	int n , result=0;
	string str;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin>>str;
		for (int j = 0; j < 2; j++)
		{
			if (str[j] != '+')
			{
				if (str[j] == '-')
				{
					result--;
					break;
				}
			}
			else
				result++;
		}
	}
	cout << result << endl;
	system("pause");
	return 0;
}


#include <iostream>
using namespace std;
void main(){
	int n , result=0;
	string s;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> s;
		for (int j = 0; j < s.length(); j++)
		{
			if (s[i] == '+')
			{
				result++;
				break;
			}
			if (s[i] == '-')
			{
				result--;
				break;
			}
		}
	}
	system("pause");
	return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main(){
	int n , result=0;
	string str;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin>>str;
		for (int j = 0; j < 2; j++)
		{
			if (str[j] == '+')
			{
				result++;
				break;
			}

			else if (str[j] == '-')
			{
				result--;
				break;
			}
		}
	}
	cout << result << endl;
	system("pause");
	return 0;
}


#include <iostream>
using namespace std;
int main(){
	int n , result=0;
	char str[3];
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin>>str;
		for (int j = 0; j < strlen(str); j++)
		{
			if (str[j] == '+')
			{
				result++;
				break;
			}

			if (str[j] == '-')
			{
				result--;
				break;
			}
		}
	}
	cout << result << endl;
	system("pause");
	return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main(){
	int n , result=0;
	string str;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin>>str;
		for (int j = 0; j < str.length(); j++)
		{
			if (str[j] == '+')
			{
				result++;
				break;
			}

			if (str[j] == '-')
			{
				result--;
				break;
			}
		}
	}
	cout << result << endl;
	system("pause");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
     long long int k,answer=0;
     string s;
	 cin>>k;
	 for(int i=1;i<=k;i=i+1){
		cin>>s;
		if(s[1]=='+') answer=answer+1;
		else answer=answer-1;
	 }
	 cout<<answer<<endl;
	 return 0;
}


#include<iostream>

using namespace std;

int main () {
	int n,ans=0;
	cin>>n;
	string a;
	while(n--)
	{
		cin>>a;
		if(a=="++X"||a=="X++")
			ans++;
		if(a=="--X"||a=="X--")
			ans--;
	}
	cout<<ans<<endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int n;
string a;
string b;
int ans;
int output(int a,int b){
	cout<<"这是为了测试执行顺序情况的测试"<<"a"<<a<<"b"<<b<<endl;
	return 666;
}
int main(){
	//cin>>n;
    cin>>n;
    for(int i=1;i<=n;i++){
    	cin>>b;
    	for(int j=0;j<b.size();j++){
    		if(b[j]=='+'){
    			ans++;
    			break;
			}
			if(b[j]=='-'){
				ans--;
				break;
			}
		}
	}

	cout<<ans<<endl;
	return 0;

}


#include<bits/stdc++.h>
using namespace std;

int main()
{
	int n,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		char a[3];
		cin>>a;
		if(a[1]=='-') ans--;
		else ans++;
	}
	cout<<ans<<endl;
	return 0;
}


#include<iostream>
#include<cstdio>
using namespase std;
int main()
{
    long long a,b=0;
    cin>>a;
    char b[a+1];
    for(int i=0;i<a;i++)
    {
        scanf("%s",&b[i]);
    }
    for(int i=0;i<a;i++)
    {
        if(b[i]==x++ || ++x)
        {
            b++;
        }
        else
        {
            b--;
        }
    }
    printf("%d",b);
    return 0;
}


#include<iostream>
#include<string>
using namespace std;
string a[10001];
int n,x=0;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]=="X++" || a[i]=="++X")
		x++;
		else
		x--;
	}
	cout<<x<<endl;
	return 0;
}


#include <cstdio>
#include <string>
#include <cstring>
using namespace std;
char s[5];
int n,x;
int main(){
    cin>>n;
    while(n--)
    {
        scanf("%s",s);
        if(s=="X++"||s=="++X")
            x++;
        else
            x--;
    }
    cout<<x;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a=0;
	char x,y,z;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x>>y>>z;
		if(y=='+'){
			a+=1;
		}
		if(y=='-'){
			a-=1;
		}
	}
	cout<<a<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
string s ;
int main() {
	int n , X = 0;
	cin >> n ;
	for(int i = 1 ; i <= n ; i++){
		cin >> s ;
		if(s[1] == '+') X++ ;
		else X-- ;
	}
	cout << X << endl ;
	return 0 ;
}


#include<bits/stdc++.h>
using namespace std;
int main() {
	int ans=0;
	int n;
	string s;
	cin>>n;
	for (int i=1; i<=n; i++) {
		cin>>s;
		if(s[1]=='+') ans++;
		else ans--;
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main() {
	int n, x = 0;
	string s;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> s;
		if (s == "X++" || s == "++X") {
			x++;
		} else {
			x--;
		}
	}
	cout << x;
	return 0;
}


#include <iostream>
#include <cmath>
using namespace std;
int main(){
	int m,n;
	cin>>n>>m;
	int mod=pow(2,n);
	if(n>=27) cout<<m<<endl;
	else cout<<m%mod<<endl;
	return 0;
}


#include<iostream>
using namespace std;
int n,x,i;
char a,b,c;
int main()
{
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>a>>b>>c;
		if(b=='+')
		x++;
		else
		x--;
	}
	cout<<x<<endl;
	return 0;
}


#include <cstdio>
#include <algorithm>
using namespace std;
int n,x;
char s[4];
int main()
{
//	freopen("test.in","r",stdin);
//	freopen("test.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",s);
		if(s[1]==43)x++;
		else	x--;
	}
	printf("%d",x);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		char a,b,c;
		cin>>a>>b>>c;
		if(b=='+')ans++;
		else ans--;
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x=0,s;
	string a;
	cin>>s;
	for(int i=1;i<=s;i++)
	{
		cin>>a;
		if(a=="X++"||a=="++X") x++;
		if(a=="X--"||a=="--X") x--;
	}
	cout<<x<<endl;
	return 0;
}


#include<iostream>
using namespace std;

int x;
int n, ans;

void work()
{
	cin>>n;

	for(int i=1;i<=n;i++)
	{
		cin>>x;
		for(int i=0;i<x.size();i++)
		{
			if(x[i] == 'X')
				continue;
			else if(x[i] == '+')
				ans++;break;
			else
				ans--;break;
		}
	}

	cout<<ans<<endl;
}

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


#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	int n,si=0;
	cin>>n;
	for(int i=0;i<n;++i)
	{
		cin>>s;
		if(s[1]=='+') si++;
		else if(s[1]=='-')si--;
	}
	cout<<si;
}


#include<cmath>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	int ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		string s;
		cin>>s;
		if(s[1]=='+')
		ans++;
		else
		ans--;
	}
	printf("%d\n",ans);
	return 0;
}


#include<iostream>
using namespace std;
int x,n,i;
string s;
int main(){
    cin>>n;
    for(i=1;i<n;++i){
        cin>>s;
        if(s=="++X"||s=="X++")++x;
        else --x;
    }cout<<x;
    return 0;
}


#include <iostream>
#include <cstring>

using namespace std;

int main()
{

	int n, x = 0;
	string s;

	cin >> n;

	for (int i = 1; i <= n; ++i)
	{
		cin >> s;

		if (s[1] == '+')
		{
			x++;
		}
		else
		{
			x--;
		}
	}

	cout << x;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main() {
	int x;
	string s;
	int n;
	cin>>n;
	for(int i=1; i<=n; i++) {
		cin>>s;
		if(s=="X++"||s=="++X")x++;
		else x--;
	}
	cout<<x<<endl;
	return 0;
}


#include<iostream>
using namespace std;
int x,n,i;
string s;
int main(){
    cin>>n;
    for(i=1;i<n;++i){
        cin>>s;
        if(s=="++X"||"X++")++x;
        else --x;
    }cout<<x;
    return 0;
}


#include <iostream>
using namespace std;

int main()
{
    int n, X = 0;
    cin >> n;
    string code[n];
    for(int i = 0; i <= n - 1; i++)
    {
        cin >> code[i];
    }
    for(int i = 0; i <= n - 1; i++)
    {
        if(code[i] == "X++" || code[i] == "++X")
        {
            X++;
        }
        else if(code[i] == "--X" || code[i] == "X--")
        {
            X--;
        }
    }
    cout << X << endl;
    return 0;
}


#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
using namespace std;
int main()
{
    int i,n,s;
    char a,b,c;
    cin>>n;
    s=0;
    for(i=1;i<=n;i++)
    {
    	cin>>a>>b>>c;
    	if(a=='+'||c=='+')
    		s=s+1;
    	if(s=='-'||c=='-')
    		s=s-1;
	}
	cout<<s<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,i,x;
string s;
int main()
{
	cin>>n;
	for(i=1;i<=n;i++)
	 {
			cin>>s;
			if(s=="++X"||s=="X++") x++;
			 else x--;
	 }
	cout<<x;
	return 0;
}


#include<stdio.h>
int main(){
    int n=0;
    char a[200][5];
    int count=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%s",a[i]);
    for(int i=1;i<=n;i++){
        if(a[i][2]=='+')count++;
        if(a[i][2]=='-')count--;
        }

    printf("%d\n",count);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k=0,ans=0;
	string donk;
	cin>>n;
	while(n--)
	{
	cin>>donk;
	if (donk=="X++"||donk=="++X")ans++;
	else ans--;
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long n,ans;
string s;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>s;
        if(s[1]=='+') ans++;
        else ans--;
    }
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
int n,sum=0;
cin>>n;
char a[5];
while(n--){
cin>>a;
if(a[0]=='+'||a[1]=='+')
sum++;
else if(a[0]=='-'||a[1]=='-')
sum--;
}
cout<<sum;
return 0;
}


#include<iostream>
#include<string>
using namespace std;
int main()
{
	int x=0,a;
	cin>>a;
	string b;
	for(int c=0;c<a;c++)
	{
		cin>>b;
		if(b=="X++"||b=="++X")
		{
			x++;
		}
		if(b=="X--"||b=="--X")
		{
			x--;
		}
	}
	cout<<x;
}


#include<bits/stdc++.h>
using namespace std;
int n,x;
string s;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>s;
		if(s[1]=='+') x++;
		else x--;
	}
	cout<<x;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,x=0;
	cin>>n;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		if(s[0]=='+'||s[2]=='+')
			x++;
		else
			x--;
	}
	cout<<x;
	return 0;
}


#include<iostream>
using namespace std;
long long n,ans;
string s;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>s;
		if(s[1]=='+') ans++;
		else ans--;
	}
	cout<<ans;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
char st[101];
int n,i,s;
int main(){
	cin>>n;s=0;
	for (i=1;i<=n;i++) {
		cin>>st;
		if (st[1]=='+') s++;
		      else s--;
		  }
		  cout<<s<<endl;
   return 0;
}


#include <bits/stdc++.h>
using namespace std;
string s[5];
int n,x;
int main(){
    scanf("%d",&n),x=0;
    while(n--){
        scanf("%s",s);
        if(s=="X++" || s=="++X") x++;
        else x--;
    }
    return printf("%d",x)-1;
}


#include<bits/stdc++.h>
using namespace std;
long long n,s=0;
string o;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>o;
        if(o=="++X"||o=="X++"){
        	s++;
		}
        else s--;
    }
    cout<<s;
    return 0;;
}


#include<bits/stdc++.h>
using namespace std;
int a,c=-1,d;
char b[4];
int main()
{
	cin>>a;
	while(++c<a)
	{
		cin>>b;
		if(b[0]==88)
		{
			if(b[1]==43)
			{
				++d;
			}
			else
			{
				--d;
			}
		}
		else if(b[0]==43)
		{
			++d;
		}
		else
		{
			--d;
		}
	}
	cout<<d;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,a[1000002],i,ans=0;
char k;
int main()
{
  	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>k;
		if(k=='++X'||k=='X++')
		ans++;
		else
		if(k=='--X'||k=='X--')
		ans--;
	}
	cout<<ans;
}


#include<bits/stdc++>
using namespace std;
int main()
{
    int n,k=0;
    string S;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>S;
        if(S[1]=='+')k++;
        else k--;
    }
    cout<<k;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,x=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		string s;
		cin>>s;
		if(s=="x++"||s=="++x") x++;
		if(s=="x--"||s=="--x") x--;
	}
	cout<<x<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,s=0;
string a;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a;
		if(a=="++X"||a=="X++") s++;
		if(a=="--X"||a=="X--") s--;
	}
	cout<<s;
    return 0;
}


#include <cstdio>
#include <string>
#include <cstring>
char s[5];
int n,x;
int main(){
    scanf("%d",&n),x=0;
    while(n--){scanf("%s",s);if(std::string(s)=="X++"||std::string(s)=="++X") x++;else x--;}
    return printf("%d",x),0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x=0;
	string a;
	int n;
	cin>>n;
	for (int i=1;i<=n;++i)
	{
		cin>>a;
		if (a=="X++"||a=="++X"||a=="x++"||a=="++x") ++x;
		else x-=1;
	}
	cout<<x;
	return 0;
}


#include<bits/stdc++.h>
uing namespace std;
long long a,ans;
string s;
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
 	cin>>a;
 	for(int i=0;i<a;i++)
 	{
  		cin>>s;
  		if(s[1]=='+')ans++;
  		else ans--;
	}
 	cout<<ans<<endl;
 	return 0;
}


#include<iostream>
using namespace std;

string x;
int n, ans;

void work()
{
	cin>>n;

	for(int i=1;i<=n;i++)
	{
		cin>>x;

		for(int i=0;i<x.size();i++)
		{
			if(x[i] == 'X')
				continue;
			else if(x[i] == '+')
				ans++;break;
			else if(x[i] == '-')
				ans--;break;
		}
	}

	cout<<ans<<endl;
}

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


#include<bits/stdc++.h>
using namespace std;
int x,n;
int main(){
    cin>>n;
    for (int i=1;i<=n;i++){
        string a;
        cin>>a;
        if (a=="x++"||x=="++x") x++;
        else x--;
    }
    cout<<x;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
long long h,n,i,j;
string s;
int main ()
{
	h=0;
	cin>>n;
	for (i=1;i<=n;i++)
	{
		cin>>s;
		for (j=0;j<s.size();j++)
		{
			if (s[j]=='+')
			{
				h++;
				break;
			}
			if (s[j]=='-')
			{
				h--;
				break;
		    }
		}
    }
	cout<<h<<endl;
	return 00;
}


#include<iostream>
using namespace std;
string a[151];
int main()
{
    short n;
    int x=0;
    cin>>n;
    for(short i=1;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]=="--X"||a[i]=="X--") x-=1
        if(a[i]=="++X"||a[i]=="X++") x+=1;
    }
    cout<<x;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,x;
string a;
int main(){
    scanf("%d" , &n);
    for(int i = 1; i <= n; i ++) {
        cin >> a;
        if(a == "X++")x++;
        else if(a == "--X")x--;
        else if(a == "++X")x++;
        else if(a == "X--")x--;
    }
    printf("%d" , x);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int x,n,i;
string s;
int j;
int main(){
cin>>n;
for(i=1;i<=n;i++){
cin>>s;
for(j=0;j<s.size();j++) {
if(s[j]=='-'){x--;break;}
if(s[j]=='+'){x++;break;}
}
}
cout<<x;
return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
int x;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		string a;
		cin>>a;
		if(a[1]=='+'||a[2]=='+'||a[0]=='+')
		  x++;
		else
		  x--;
	}
	cout<<x;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int i,n,x,w;
string s;
int main()
{	cin>>n;
    for(i=1;i<=n;i++){
    	cin>>s;
    	w=s.find('+');
    	if(w==-1) x--;
    	else x++;
	}cout<<x;
    return 0;
}


#include<iostream>
using namespace std;
int n,x;
string s;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		if(s=="++X"||s=="X++")
		x++;
		if(s=="--X"||s=="X--")
		x--;
	}
	cout<<x;
	return 0;
}


#include<iostream>
using namespace std;
int a=0;
string c;
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>c;
		if(c=="x++")
		{
			a++;
		}
		if(c=="++x")
		{
			++a;
		}
		if(c=="x--")
		{
			a--;
		}
		if(c=="--x")
		{
			--a;
		}
	}
	cout<<a;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,x;
string s;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		for(int j=0;j<s.size();j++)
		{
			if(s[j]=='+')
			{
				x++;
				break;
			}
			else if(s[j]=='-')
			{
				x--;
				break;
			}
		}
	}
	cout<<x<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x=0,n;
	char code[3];
	cin>>n;
	for(int i1=1;i1<=n;i1++)
	{
		cin>>code;
		for(int i1=0;i1<=2;i1++)
		{
			if(code[i1]!='X')
			{
				if(code[i1]=='+')
				    x++;
				else
				    x--;
				break;
			}
		}
	}
	cout<<x;
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int n,x;
string st;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    	cin>>st;
    	if(st[0]==88)
    	{
    		if(st[1]==43)
    			x++;
    		else
    			x--;
    	}
    	else
    	{
    		if(st[1]==43)
    			x++;
    		else
    			x--;
    	}
    }
    int Wo_zhen_shuai=x;
    cout<<Wo_zhen_shuai<<"\n";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n;
char a,b,c;
int ans=0;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a>>b>>c;
		if(b=='+')
		{
			ans++;
		}
		if(b=='-')
		{
			ans--;
		}
	}
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x=0,s;
	string s;
	cin>>s;
	for(int i=1;i<=s;i++)
	{
		if(s=="X++"||s=="++X") x++;
		if(s=="X--"||s=="--X") x--;
	}
	cout<<x<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
string s;
int n,x;
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		cin>>s;
		if(s=="++X"||s=="X++")x++;
		else x--;
	}
	printf("%d\n",x);
	return 0;
}


#include <iostream>
#include <string>
#include <string.h>
#include <bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <math.h>
// #include <windows.h>
// #include <conio.h>
#include <set>
#include <list>
#include <map>
#include <time.h>
#include <algorithm>
#include <sstream>
using namespace std;
int P_(int &n){
   n=n+1;
   return n;
}
int M_(int &n){
    n=n-1;
    return n;
}
int Check(string IO,int &n){
    if(IO=="X++") n++;
    if(IO=="++X") n++;
    if(IO=="X--") n--;
    if(IO=="--X") n--;
    return n;
}
int main(){
    int n;
    cin>>n;
    string s;
    int Ans=0;
    for(int i=0;i<n;i++){
        cin>>s;
        Ans=Check(s,Ans);
    }
    cout<<Ans;
    return 0;
}