// #include <iostream>
#include <cstdio>
// #include <vector>
// #include <algorithm>
// #include <queue>
#include <utility>
// #include <stack>
#include <cstring>
// #include <cstdlib>
// #include <string>
// #include <unordered_set>

#define REP(i,a,b) for(int i = a; i < b;++i)
#define FOR(i,n) REP(i,0,n)
#define mp make_pair
#define pb push_back
#define inp1(a) scanf("%d",&a)
#define inp2(a,b) scanf("%d%d",&a,&b)
#define inp3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define inp4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
using namespace std;

const int INF = 0x3a3a3a3a;
const long long INFL = 0x3a3a3a3a3a3a3a3a;
const int MAX_N = 1000000;

#include <stdio.h>
template <class T> void swap(T& a, T& b) { T tmp = a; a = b; b = tmp; }
template <class T> class vector {
	int cap;
	int _size;
	T *arr;
public:
	vector() :_size(0), cap(32), arr(new T[32]) {}
	T& operator[](int idx) { return arr[idx]; }
	bool empty() { return _size == 0; }
	void reserve(int newCap) {
		T *newArr = new T[newCap];
		for (int i = 0; i < cap; i++) newArr[i] = arr[i];
		delete[] arr;
		arr = newArr;
		cap = newCap;
	}
	void push_back(T v) {
		if (_size == cap) reserve(cap << 1);
		arr[_size++] = v;
	}
	T back() { return arr[_size - 1]; }
	void pop_back() { --_size; }
	int size() { return _size; }
	T* begin() { return arr; }
	T* end() { return arr + _size; }
};
template <class T> class priority_queue {
	vector<T> tree;
public:
	T top() { return tree.size() ? tree[0] : T(); }
	bool empty() { return tree.empty(); }
	void push(T v) {
		tree.push_back(v);
		int cur = tree.size() - 1;
		while (cur > 0) {
			int next = (cur - 1) / 2;
			if (!(tree[next] < tree[cur])) break;
			swap(tree[next], tree[cur]);
			cur = next;
		}
	}
	void pop() {
		if (empty()) return;
		tree[0] = tree.back();
		tree.pop_back();
		int cur = 0;
		while (1) {
			int next1 = 2 * cur + 1;
			int next2 = 2 * cur + 2;
			int next;
			if (next1 >= tree.size()) break;
			if (next2 >= tree.size()) next = next1;
			else next = !(tree[next1] < tree[next2]) ? next1 : next2;
			if (!(tree[cur] < tree[next])) break;
			swap<T>(tree[cur], tree[next]);
			cur = next;
		}
	}
};
template <class T>
void sort(T* s, T* e) {
	priority_queue<T> pq;
	for (T* pos = s; pos != e; pos++) {
		pq.push(*pos);
	}
	for (T* pos = --e; pos >= s; pos--) {
		*pos = pq.top();
		pq.pop();
	}
}
struct RNG {
	long long seed;
	RNG() :seed(12387621) {}
	int next() {
		int ret = (int)seed;
		seed = (seed * 2123978 + 122178) % 1000000007;
		return ret;
	}
};
template <class T> class set {
	struct Node {
		Node *l, *r;
		T key;
		int prior;
		Node() {}
		Node(T ky, int pr) :l(0), r(0), key(ky), prior(pr) {}
	};
	typedef Node* pNode;
	pNode root;
	RNG rng;
public:
	set() : root(0),rng(RNG()) {}
	void merge(pNode& par, pNode l, pNode r) {
		if (l == 0 || r == 0) par = (l == 0 ? r : l);
		else if (l->prior < r->prior) merge(r->l, l, r->l), par = r;
		else merge(l->r, l->r, r), par = l;
	}
	void split(pNode cur, pNode breaker, pNode& l, pNode& r) {
		if (cur == 0) l = r = 0;
		else if (cur->key < breaker->key) split(cur->r, breaker, cur->r, r), l = cur;
		else split(cur->l, breaker, l, cur->l), r = cur;
	}
	void insert(pNode& cur, pNode target) {
		if (cur == 0) { cur = target; }
		else if (cur->prior < target->prior) split(cur, target, target->l, target->r), cur = target;
		else insert((cur->key < target->key ? cur->r : cur->l), target);
	}
	void erase(pNode &cur, pNode target) {
		if (cur == 0) return;
		else if (cur->key != target->key) erase((cur->key < target->key ? cur->r : cur->l), target);
		else merge(cur, cur->l, cur->r);
	}
	void inorder(pNode cur) {
		if (cur == 0) return;
		inorder(cur->l);
		printf("%d ", cur->key);
		inorder(cur->r);
	}
	void insert(T v) { insert(root, new Node(v, rng.next())); }
	void erase(T v) { erase(root, new Node(v,rng.next())); }
	void printAll() { inorder(root); }
};

int cnt[262144];
set<int> ms[262144];
int n;
char in[30];
int main() {
	inp1(n);
	getchar();
	FOR(i,n){
		gets(in);
		int len = strlen(in);
		int num=0;
		int pos=0;
		REP(i,2,len) {
			if((in[i]-'0')%2==0) {
				pos*=2;
			}
			else {
				pos*=2;
				pos+=1;
			}
			num*=10;
			num+=in[i]-'0';
		}

		if(in[0] == '+') {
			ms[pos].insert(num);
			++cnt[pos];
		}
		else if(in[0] == '-') {
			ms[pos].erase(num);
			--cnt[pos];
		}
		else if(in[0] == '?') {
			printf("%d\n",cnt[pos]);
		}
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <stack>
#include <cstring>
#include <cstdlib>
#include <string>
#include <unordered_set>
#include <set>
// #include <map>
#define REP(i,a,b) for(int i = a; i < b;++i)
#define FOR(i,n) REP(i,0,n)
#define mp make_pair
#define pb push_back
#define inp1(a) scanf("%d",&a)
#define inp2(a,b) scanf("%d%d",&a,&b)
#define inp3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define inp4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)

using namespace std;

typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int,int> pii;

const int INF = 0x3a3a3a3a;
const long long INFL = 0x3a3a3a3a3a3a3a3a;
const int MAX_N = 1000000;

int cnt[262144];
multiset<int> ms[262144];
int n;
char in[30];
int main() {
	inp1(n);
	getchar();
	FOR(i,n){
		gets(in);
		int len = strlen(in);
		int num=0;
		int pos=0;
		REP(i,2,len) {
			if((in[i]-'0')%2==0) {
				pos*=2;
			}
			else {
				pos*=2;
				pos+=1;
			}
			num*=10;
			num+=in[i]-'0';
		}

		// printf("pos:%d, num:%d\n",pos,num);
		if(in[0] == '+') {
			ms[pos].insert(num);
			++cnt[pos];
		}
		else if(in[0] == '-') {
			ms[pos].erase(ms[pos].find(num));
			--cnt[pos];
		}
		else if(in[0] == '?') {
			printf("%d\n",cnt[pos]);
		}
	}

	return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <stack>
#include <cstring>
#include <cstdlib>
#include <string>
#include <unordered_set>
#include <set>
// #include <map>
#define REP(i,a,b) for(int i = a; i < b;++i)
#define FOR(i,n) REP(i,0,n)
#define mp make_pair
#define pb push_back
#define inp1(a) scanf("%d",&a)
#define inp2(a,b) scanf("%d%d",&a,&b)
#define inp3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define inp4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
using namespace std;

typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int,int> pii;

const int INF = 0x3a3a3a3a;
const long long INFL = 0x3a3a3a3a3a3a3a3a;
const int MAX_N = 1000000;

int cnt[262144];
multiset<int> ms[262144];
int n;
char in[30];
int main() {
	inp1(n);
	getchar();
	FOR(i,n){
		gets(in);
		int len = strlen(in);
		int num=0;
		int pos=0;
		REP(i,2,len) {
			if((in[i]-'0')%2==0) {
				pos*=2;
			}
			else {
				pos*=2;
				pos+=1;
			}
			num*=10;
			num+=in[i]-'0';
		}

		// printf("pos:%d, num:%d\n",pos,num);
		if(in[0] == '+') {
			ms[pos].insert(num);
			++cnt[pos];
		}
		else if(in[0] == '-') {
			ms[pos].erase(ms[pos].find(num));
			--cnt[pos];
		}
		else if(in[0] == '?') {
			printf("%d\n",cnt[pos]);
		}
	}

	return 0;
}


// #include <iostream>
#include <cstdio>
// #include <vector>
// #include <algorithm>
// #include <queue>
#include <utility>
// #include <stack>
#include <cstring>
// #include <cstdlib>
// #include <string>
// #include <unordered_set>

#define REP(i,a,b) for(int i = a; i < b;++i)
#define FOR(i,n) REP(i,0,n)
#define mp make_pair
#define pb push_back
#define inp1(a) scanf("%d",&a)
#define inp2(a,b) scanf("%d%d",&a,&b)
#define inp3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define inp4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
using namespace std;

const int INF = 0x3a3a3a3a;
const long long INFL = 0x3a3a3a3a3a3a3a3a;
const int MAX_N = 1000000;

#include <stdio.h>
template <class T> void swap(T& a, T& b) { T tmp = a; a = b; b = tmp; }
template <class T> class vector {
	int cap;
	int _size;
	T *arr;
public:
	vector() :_size(0), cap(32), arr(new T[32]) {}
	T& operator[](int idx) { return arr[idx]; }
	bool empty() { return _size == 0; }
	void reserve(int newCap) {
		T *newArr = new T[newCap];
		for (int i = 0; i < cap; i++) newArr[i] = arr[i];
		delete[] arr;
		arr = newArr;
		cap = newCap;
	}
	void push_back(T v) {
		if (_size == cap) reserve(cap << 1);
		arr[_size++] = v;
	}
	T back() { return arr[_size - 1]; }
	void pop_back() { --_size; }
	int size() { return _size; }
	T* begin() { return arr; }
	T* end() { return arr + _size; }
};
template <class T> class priority_queue {
	vector<T> tree;
public:
	T top() { return tree.size() ? tree[0] : T(); }
	bool empty() { return tree.empty(); }
	void push(T v) {
		tree.push_back(v);
		int cur = tree.size() - 1;
		while (cur > 0) {
			int next = (cur - 1) / 2;
			if (!(tree[next] < tree[cur])) break;
			swap(tree[next], tree[cur]);
			cur = next;
		}
	}
	void pop() {
		if (empty()) return;
		tree[0] = tree.back();
		tree.pop_back();
		int cur = 0;
		while (1) {
			int next1 = 2 * cur + 1;
			int next2 = 2 * cur + 2;
			int next;
			if (next1 >= tree.size()) break;
			if (next2 >= tree.size()) next = next1;
			else next = !(tree[next1] < tree[next2]) ? next1 : next2;
			if (!(tree[cur] < tree[next])) break;
			swap<T>(tree[cur], tree[next]);
			cur = next;
		}
	}
};
template <class T>
void sort(T* s, T* e) {
	priority_queue<T> pq;
	for (T* pos = s; pos != e; pos++) {
		pq.push(*pos);
	}
	for (T* pos = --e; pos >= s; pos--) {
		*pos = pq.top();
		pq.pop();
	}
}
struct RNG {
	long long seed;
	RNG() :seed(12387621) {}
	int next() {
		int ret = (int)seed;
		seed = (seed * 2123978 + 122178) % 1000000007;
		return ret;
	}
};
template <class T> class set {
	struct Node {
		Node *l, *r;
		T key;
		int prior;
		Node() {}
		Node(T ky, int pr) :l(0), r(0), key(ky), prior(pr) {}
	};
	typedef Node* pNode;
	pNode root;
	RNG rng;
public:
	set() : root(0),rng(RNG()) {}
	void merge(pNode& par, pNode l, pNode r) {
		if (l == 0 || r == 0) par = (l == 0 ? r : l);
		else if (l->prior < r->prior) merge(r->l, l, r->l), par = r;
		else merge(l->r, l->r, r), par = l;
	}
	void split(pNode cur, pNode breaker, pNode& l, pNode& r) {
		if (cur == 0) l = r = 0;
		else if (cur->key < breaker->key) split(cur->r, breaker, cur->r, r), l = cur;
		else split(cur->l, breaker, l, cur->l), r = cur;
	}
	void insert(pNode& cur, pNode target) {
		if (cur == 0) { cur = target; }
		else if (cur->prior < target->prior) split(cur, target, target->l, target->r), cur = target;
		else insert((cur->key < target->key ? cur->r : cur->l), target);
	}
	void erase(pNode &cur, pNode target) {
		if (cur == 0) return;
		else if (cur->key != target->key) erase((cur->key < target->key ? cur->r : cur->l), target);
		else merge(cur, cur->l, cur->r);
	}
	void inorder(pNode cur) {
		if (cur == 0) return;
		inorder(cur->l);
		printf("%d ", cur->key);
		inorder(cur->r);
	}
	void insert(T v) { insert(root, new Node(v, rng.next())); }
	void erase(T v) { erase(root, new Node(v,rng.next())); }
	void printAll() { inorder(root); }
};

int cnt[262144];
set<int> ms[262144];
int n;
char in[30];
int main() {
	inp1(n);
	getchar();
	FOR(i,n){
		gets(in);
		int len = strlen(in);
		int num=0;
		int pos=0;
		REP(i,2,len) {
			if((in[i]-'0')%2==0) {
				pos*=2;
			}
			else {
				pos*=2;
				pos+=1;
			}
			num*=10;
			num+=in[i]-'0';
		}

		if(in[0] == '+') {
			ms[pos].insert(num);
			++cnt[pos];
		}
		else if(in[0] == '-') {
			ms[pos].erase(num);
			--cnt[pos];
		}
		else if(in[0] == '?') {
			printf("%d\n",cnt[pos]);
		}
	}

	return 0;
}


// #include <iostream>
#include <cstdio>
// #include <vector>
// #include <algorithm>
// #include <queue>
#include <utility>
// #include <stack>
#include <cstring>
// #include <cstdlib>
// #include <string>
// #include <unordered_set>

#define REP(i,a,b) for(int i = a; i < b;++i)
#define FOR(i,n) REP(i,0,n)
#define mp make_pair
#define pb push_back
#define inp1(a) scanf("%d",&a)
#define inp2(a,b) scanf("%d%d",&a,&b)
#define inp3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define inp4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
using namespace std;

const int INF = 0x3a3a3a3a;
const long long INFL = 0x3a3a3a3a3a3a3a3a;
const int MAX_N = 1000000;

#include <stdio.h>
template <class T> void swap(T& a, T& b) { T tmp = a; a = b; b = tmp; }
template <class T> class vector {
	int cap;
	int _size;
	T *arr;
public:
	vector() :_size(0), cap(32), arr(new T[32]) {}
	T& operator[](int idx) { return arr[idx]; }
	bool empty() { return _size == 0; }
	void reserve(int newCap) {
		T *newArr = new T[newCap];
		for (int i = 0; i < cap; i++) newArr[i] = arr[i];
		delete[] arr;
		arr = newArr;
		cap = newCap;
	}
	void push_back(T v) {
		if (_size == cap) reserve(cap << 1);
		arr[_size++] = v;
	}
	T back() { return arr[_size - 1]; }
	void pop_back() { --_size; }
	int size() { return _size; }
	T* begin() { return arr; }
	T* end() { return arr + _size; }
};
template <class T> class priority_queue {
	vector<T> tree;
public:
	T top() { return tree.size() ? tree[0] : T(); }
	bool empty() { return tree.empty(); }
	void push(T v) {
		tree.push_back(v);
		int cur = tree.size() - 1;
		while (cur > 0) {
			int next = (cur - 1) / 2;
			if (!(tree[next] < tree[cur])) break;
			swap(tree[next], tree[cur]);
			cur = next;
		}
	}
	void pop() {
		if (empty()) return;
		tree[0] = tree.back();
		tree.pop_back();
		int cur = 0;
		while (1) {
			int next1 = 2 * cur + 1;
			int next2 = 2 * cur + 2;
			int next;
			if (next1 >= tree.size()) break;
			if (next2 >= tree.size()) next = next1;
			else next = !(tree[next1] < tree[next2]) ? next1 : next2;
			if (!(tree[cur] < tree[next])) break;
			swap<T>(tree[cur], tree[next]);
			cur = next;
		}
	}
};
template <class T>
void sort(T* s, T* e) {
	priority_queue<T> pq;
	for (T* pos = s; pos != e; pos++) {
		pq.push(*pos);
	}
	for (T* pos = --e; pos >= s; pos--) {
		*pos = pq.top();
		pq.pop();
	}
}
struct RNG {
	long long seed;
	RNG() :seed(12387621) {}
	int next() {
		int ret = (int)seed;
		seed = (seed * 2123978 + 122178) % 1000000007;
		return ret;
	}
};
template <class T> class set {
	struct Node {
		Node *l, *r;
		T key;
		int prior;
		Node() {}
		Node(T ky, int pr) :l(0), r(0), key(ky), prior(pr) {}
	};
	typedef Node* pNode;
	pNode root;
	RNG rng;
public:
	set() : root(0),rng(RNG()) {}
	void merge(pNode& par, pNode l, pNode r) {
		if (l == 0 || r == 0) par = (l == 0 ? r : l);
		else if (l->prior < r->prior) merge(r->l, l, r->l), par = r;
		else merge(l->r, l->r, r), par = l;
	}
	void split(pNode cur, pNode breaker, pNode& l, pNode& r) {
		if (cur == 0) l = r = 0;
		else if (cur->key < breaker->key) split(cur->r, breaker, cur->r, r), l = cur;
		else split(cur->l, breaker, l, cur->l), r = cur;
	}
	void insert(pNode& cur, pNode target) {
		if (cur == 0) { cur = target; }
		else if (cur->prior < target->prior) split(cur, target, target->l, target->r), cur = target;
		else insert((cur->key < target->key ? cur->r : cur->l), target);
	}
	void erase(pNode &cur, pNode target) {
		if (cur == 0) return;
		else if (cur->key != target->key) erase((cur->key < target->key ? cur->r : cur->l), target);
		else merge(cur, cur->l, cur->r);
	}
	void inorder(pNode cur) {
		if (cur == 0) return;
		inorder(cur->l);
		printf("%d ", cur->key);
		inorder(cur->r);
	}
	void insert(T v) { insert(root, new Node(v, 1)); }
	void erase(T v) { erase(root, new Node(v, 1)); }
	void printAll() { inorder(root); }
};

int cnt[262144];
set<int> ms[262144];
int n;
char in[30];
int main() {
	inp1(n);
	getchar();
	FOR(i,n){
		gets(in);
		int len = strlen(in);
		int num=0;
		int pos=0;
		REP(i,2,len) {
			if((in[i]-'0')%2==0) {
				pos*=2;
			}
			else {
				pos*=2;
				pos+=1;
			}
			num*=10;
			num+=in[i]-'0';
		}

		if(in[0] == '+') {
			ms[pos].insert(num);
			++cnt[pos];
		}
		else if(in[0] == '-') {
			ms[pos].erase(num);
			--cnt[pos];
		}
		else if(in[0] == '?') {
			printf("%d\n",cnt[pos]);
		}
	}

	return 0;
}


// #include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#define f(i,s,n) for( ll i = s; i < n; i++ )
#define la(n) for(ll i=0; i<n; i++ ) // loop a
#define lb(n) for(ll j=0; j<n; j++ ) // loop b
#define ve vector
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define it iterator
#define master_shifu main
#define c cout
#define e '\n'
using namespace std;
typedef long long ll;
// author: gabriel hofer

string digitparity( ll a ) {
   string str = to_string( a );
   ll len = str.length();
   ve < ll > v;
   string uu = "";
   la( len ) {
      if( str[i] % 2 == 0 ) {
	 uu.append( "0" ); }
      else if( str[i] % 2 == 1 ) {
	 uu.append( "1" ); }}
   return uu;
}

// converts a binary string representation
// to a number base ten
ll tobin( string str ) {
   ll nn = str.length();
   ll ee = 0;
   la( nn ) {
      ee += pow( 2, i ) * ((ll)str[ nn - i - 1 ] - 48); }
   return ee;
}

int master_shifu() {

   ll t;
   cin >> t;

   char ch;
   ll f;
   // dynamicall allocate an array
   ll n = pow( 2, 18 ) + 1;
   ll * v = new ll[ n ];
   la( n+1 ) {
      v[i] = 0; }
   la( t ) {
      cin >> ch >> f;
      string a = digitparity( f );
      ll val = tobin( a );
      if( ch == '+' ) {
	 v[ val ] += 1; }
      else if( ch == '-' ) {
	 if( v[ val ] > 0 ) {
	    v[ val ] -= 1; }}
      else if( ch == '?' ) {
   	 c << v[ val ] << e; }}

   return 0;
}


// #include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#define f(i,s,n) for( ll i = s; i < n; i++ )
#define la(n) for(ll i=0; i<n; i++ ) // loop a
#define lb(n) for(ll j=0; j<n; j++ ) // loop b
#define ve vector
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define it iterator
#define master_shifu main
#define c cout
#define e '\n'
using namespace std;
typedef long long ll;
// author: gabriel hofer

string digitparity( ll a ) {
   string str = to_string( a );
   ll len = str.length();
   ve < ll > v;
   string uu = "";
   la( len ) {
      if( str[i] % 2 == 0 ) {
	 uu.append( "0" ); }
      else if( str[i] % 2 == 1 ) {
	 uu.append( "1" ); }}
   return uu;
}

int master_shifu() {

   ll t;
   cin >> t;

   char ch;
   ll f;
   unordered_map < ll, ll > mm;
   pair < ll, ll > pp;

   la( t ) {
      cin >> ch >> f;
      ll val = stoll( digitparity( f ), nullptr );
      if( ch == '+' ) {
   	 if( mm.find( val ) == mm.end() ) {
   	    pp = mp( val, 1 );
   	    mm.insert( pp ); }
   	 else {
   	    mm[ val ] += 1; }}
      else if( ch == '-' ) {
	 if( mm[ val ] > 0 ) {
	    mm[ val ] -= 1; }}
      else if( ch == '?' ) {
   	 c << mm[ val ] << e; }}
   return 0;
}


// #include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#define f(i,s,n) for( ll i = s; i < n; i++ )
#define la(n) for(ll i=0; i<n; i++ ) // loop a
#define lb(n) for(ll j=0; j<n; j++ ) // loop b
#define ve vector
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define it iterator
#define master_shifu main
#define c cout
#define e '\n'
using namespace std;
typedef long long ll;
// author: gabriel hofer

// string digitparity( ll a ) {
//    string str = to_string( a );
//    ll len = str.length();
//    ve < ll > v;
//    string uu = "";
//    la( len ) {
//       if( str[i] % 2 == 0 ) {
// 	 uu.append( "0" ); }
//       else if( str[i] % 2 == 1 ) {
// 	 uu.append( "1" ); }}
//    return uu;
// }

// converts a binary string representation
// to a number base ten
ll tobin( string & str ) {
   ll nn = str.length();
   ll ee = 0;
   la( nn ) {
      ee += pow( 2, i ) * (((ll)str[ nn - i - 1 ] - 48) % 2); }
   return ee;
}

int master_shifu() {

   ll t;
   cin >> t;

   char ch;
   string str;
   // dynamicall allocate an array
   ll n = pow( 2, 18 ) + 1;
   ll * v = new ll[ n ];
   la( n+1 ) { v[i] = 0; }
   la( t ) {
      cin >> ch >> str;
      ll val = tobin( str );
      if( ch == '?' ) {
   	 c << v[ val ] << e; }
      else if( ch == '+' ) {
	 v[ val ] += 1; }
      else if( ch == '-' && ( v[ val ] > 0 ) ) {
	    v[ val ] -= 1; }}

   return 0;
}


// #include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#define f(i,s,n) for( ll i = s; i < n; i++ )
#define la(n) for(ll i=0; i<n; i++ ) // loop a
#define lb(n) for(ll j=0; j<n; j++ ) // loop b
#define ve vector
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define it iterator
#define master_shifu main
#define c cout
#define e '\n'
using namespace std;
typedef long long ll;
// author: gabriel hofer

string digitparity( ll a ) {
   string str = to_string( a );
   ll len = str.length();
   ve < ll > v;
   string uu = "";
   la( len ) {
      if( str[i] % 2 == 0 ) {
	 uu.append( "0" ); }
      else if( str[i] % 2 == 1 ) {
	 uu.append( "1" ); }}
   return uu;
}

int master_shifu() {

   ll t;
   cin >> t;

   char ch;
   ll f;
   map < ll, ll > mm;
   pair < ll, ll > pp;

   la( t ) {
      cin >> ch >> f;
      ll val = stoll( digitparity( f ), nullptr );
      if( ch == '+' ) {
   	 if( mm.find( val ) == mm.end() ) {
   	    pp = mp( val, 1 );
   	    mm.insert( pp ); }
   	 else {
   	    mm[ val ] += 1; }}
      else if( ch == '-' ) {
	 if( mm[ val ] > 0 ) {
	    mm[ val ] -= 1; }}
      else if( ch == '?' ) {
   	 c << mm[ val ] << e; }}
   return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

vector<ll> v;

bool solve(ll x, ll y)
{
    while(x || y){
        if(x % 2 != y % 2) return false;
        x /= 10;
        y /= 10;
    }
    return true;
}

int main()
{
    int t, input, cnt(0);
    char c;
    cin >> t;
    while(t--){
        cin >> c >> input;
        if(c == '+') v.push_back(input);
        else if(c == '-') {
            for(int i = 0; i < v.size(); ++i)
                if(v[i] == input) v.erase(v.begin() + i);
        }
        else if(c == '?') {
            cnt = 0;
            for(ll i:v){
                cnt += solve(input,i);
            }
            cout << cnt << endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

map<int, int> parity;

ll solve(ll x)
{
    string s;
    stringstream ss;
    ll res;
    if(x == 0) {
        parity[x] = 0;
        return 0;
    }
    while(x){
        s += ((x % 10) % 2 + '0');
        x /= 10;
    }
    reverse(s.begin(), s.end());
    ss << s;
    ss >> res;
    return res;
}

int main()
{
    ll t, input, cnt(0);
    char c;
    cin >> t;
    while(t--){
        cin >> c >> input;
        if(!parity[input])
            solve(input);
        if(c == '+') parity[solve(input)]++;
        else if(c == '-') {
            parity[solve(input)]--;
        }
        else if(c == '?') {
            cout << parity[input] << endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

map<int, int> parity;

ll solve(ll x)
{
    string s;
    stringstream ss;
    int res;
    if(x == 0) {
        parity[x] = 0;
        return 0;
    }
    while(x){
        s += ((x % 10) % 2 + '0');
        x /= 10;
    }
    reverse(s.begin(), s.end());
    ss << s;
    ss >> res;
    return res;
}

int main()
{
    ll t, input, cnt(0);
    char c;
    cin >> t;
    while(t--){
        cin >> c >> input;
        if(!parity[input])
            solve(input);
        if(c == '+') parity[solve(input)]++;
        else if(c == '-') {
            parity[solve(input)]--;
        }
        else if(c == '?') {
            cout << parity[input] << endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

vector<ll> v;

bool solve(ll x, ll y)
{
    while(x || y){
        if(x % 2 != y % 2) return false;
        x /= 10;
        y /= 10;
    }
    return true;
}

int main()
{
    ll t, input, cnt(0);
    char c;
    cin >> t;
    while(t--){
        cin >> c >> input;
        if(c == '+') v.push_back(input);
        else if(c == '-') {
            for(int i = 0; i < v.size(); ++i)
                if(v[i] == input) v.erase(v.begin() + i);
        }
        else if(c == '?') {
            cnt = 0;
            for(ll i:v){
                cnt += solve(input,i);
            }
            cout << cnt << endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

vector<int> v;

bool solve(int x, int y)
{
    while(x || y){
        if(x % 2 != y % 2) return false;
        x /= 10;
        y /= 10;
    }
    return true;
}

int main()
{
    int t, input, cnt(0);
    char c;
    cin >> t;
    while(t--){
        cin >> c >> input;
        if(c == '+') v.push_back(input);
        else if(c == '-') {
            for(int i = 0; i < v.size(); ++i)
                if(v[i] == input) v.erase(v.begin() + i);
        }
        else if(c == '?') {
            cnt = 0;
            for(int i:v){
                cnt += solve(input,i);
            }
            cout << cnt << endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

vector<ll> v;
map<int, string> parity;

void solve(ll x)
{
    if(x == 0) parity[x] = "0";
    while(x){
        parity[x] += (x % 10 + '0');
        x /= 10;
    }
    reverse(parity[x].begin(), parity[x].end());
}

int main()
{
    ll t, input, cnt(0);
    char c;
    cin >> t;
    while(t--){
        cin >> c >> input;
        if(parity[input] == "")
            solve(input);
        if(c == '+') v.push_back(input);
        else if(c == '-') {
            for(int i = 0; i < v.size(); ++i)
                if(v[i] == input) v.erase(v.begin() + i);
        }
        else if(c == '?') {
            cnt = 0;
            for(ll i:v){
                cnt += (parity[input] == parity[i]);
            }
            cout << cnt << endl;
        }
    }
    return 0;
}


#include <cstdio>
typedef long long ll;
const int N = 262144;
int c[N];
int main() {
	int t, i, p; ll d; char op;
	scanf("%d", &t);
	while (t--) {
		for (op = getchar(); op == '\n'; op = getchar());
		scanf("%I64d", &d);
		for (i = p = 0; i < 18; ++i)
			p |= ((d % 10) & 1) << i, d /= 10;
		switch(op) {
		case '+': ++c[p]; break;
		case '-': --c[p]; break;
		case '?': printf("%d\n", c[p]); break;
		}
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 10005;
int cnt = 0;
int c[N][2], val[N];
void modify(char *s, int d) {
	int i, p = 0, x, l = strlen(s);
	reverse(s, s + l);
	for (i = 0; s[i]; ++i) {
		x = (s[i] - '0') & 1;
		if (!c[p][x]) c[p][x] = ++cnt;
		p = c[p][x]; val[p] += d;
	}
}
int query(char *s) {
	int i, p = 0, x, l = strlen(s);
	reverse(s, s + l);
	for (i = 0; s[i]; ++i) {
		x = (s[i] - '0') & 1;
		if (!c[p][x]) {
			if (x) return 0;
		} else p = c[p][x];
	}
	return val[p];
}
char valid_char() {
	char ch = getchar();
	while (ch == ' ' || ch == '\n') ch = getchar();
	return ch;
}
char d[N];
int main() {
	int t; char op;
	scanf("%d", &t);
	while (t--) {
		op = valid_char(); scanf("%s", d);
		switch(op) {
		case '+': modify(d, 1); break;
		case '-': modify(d, -1); break;
		case '?': printf("%d\n", query(d)); break;
		}
	}
	return 0;
}


#include <cstdio>
#include <algorithm>
using namespace std;
const int N = 10005;
int cnt = 0;
int c[N][2], val[N];
void modify(char *s, int d) {
	int i, p = 0, x, l = strlen(s);
	reverse(s, s + l);
	for (i = 0; s[i]; ++i) {
		x = (s[i] - '0') & 1;
		if (!c[p][x]) c[p][x] = ++cnt;
		p = c[p][x]; val[p] += d;
	}
}
int query(char *s) {
	int i, p = 0, x, l = strlen(s);
	reverse(s, s + l);
	for (i = 0; s[i]; ++i) {
		x = (s[i] - '0') & 1;
		if (!c[p][x]) {
			if (x) return 0;
		} else p = c[p][x];
	}
	return val[p];
}
char valid_char() {
	char ch = getchar();
	while (ch == ' ' || ch == '\n') ch = getchar();
	return ch;
}
char d[N];
int main() {
	int t; char op;
	scanf("%d", &t);
	while (t--) {
		op = valid_char(); scanf("%s", d);
		switch(op) {
		case '+': modify(d, 1); break;
		case '-': modify(d, -1); break;
		case '?': printf("%d\n", query(d)); break;
		}
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 500005;
int cnt = 0;
int c[N];
void modify(char *s, int d) {
	int i, p = -1, q, x, l = strlen(s);
	reverse(s, s + l);
	for (; l < 19; ++l) s[l] = '0';
	for (i = 0; i < l; ++i) {
		x = (s[i] - '0') & 1;
		q = p; if (p == -1) p = 0; p |= x << i;
		if (q != p) c[p] += d;
	}
}
int query(char *s) {
	int i, b = 0, j, p = 0, x, l = strlen(s);
	reverse(s, s + l);
	for (i = 0; i < l; ++i) {
		x = (s[i] - '0') & 1;
		p |= x << i;
	}
	return c[p];
}
char valid_char() {
	char ch = getchar();
	while (ch == ' ' || ch == '\n') ch = getchar();
	return ch;
}
char d[N];
int main() {
	int t; char op;
	scanf("%d", &t);
	while (t--) {
		op = valid_char(); scanf("%s", d);
		switch(op) {
		case '+': modify(d, 1); break;
		case '-': modify(d, -1); break;
		case '?': printf("%d\n", query(d)); break;
		}
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 500005;
int cnt = 0;
int c[N][2], val[N];
void modify(char *s, int d) {
	int i, p = 0, x, l = strlen(s);
	reverse(s, s + l);
	for (; l < 19; ++l) s[l] = '0';
	for (i = 0; i < l; ++i) {
		x = (s[i] - '0') & 1;
		if (!c[p][x]) c[p][x] = ++cnt;
		p = c[p][x]; val[p] += d;
	}
}
int query(char *s) {
	int i, b = 0, j, p = 0, x, l = strlen(s);
	reverse(s, s + l);
	for (; l < 19; ++l) s[l] = '0';
	for (i = 0; i < l; ++i) {
		x = (s[i] - '0') & 1;
		if (!c[p][x]) return 0;
		p = c[p][x];
	}
	return val[p];
}
char valid_char() {
	char ch = getchar();
	while (ch == ' ' || ch == '\n') ch = getchar();
	return ch;
}
char d[N];
int main() {
	int t; char op;
	scanf("%d", &t);
	while (t--) {
		op = valid_char(); scanf("%s", d);
		switch(op) {
		case '+': modify(d, 1); break;
		case '-': modify(d, -1); break;
		case '?': printf("%d\n", query(d)); break;
		}
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 262144;
int c[N];
void modify(char *s, int d) {
	int i, p = 0, l = strlen(s);
	for (i = l - 1; i >= 0; --i)
		p |= ((s[i] - '0') & 1) << (l - i - 1);
	c[p] += d;
}
int query(char *s) {
	int i, p = 0, l = strlen(s);
	for (i = l - 1; i >= 0; --i)
		p |= ((s[i] - '0') & 1) << (l - i - 1);
	return c[p];
}
char valid_char() {
	char ch = getchar();
	while (ch == ' ' || ch == '\n') ch = getchar();
	return ch;
}
char d[N];
int main() {
	int t; char op;
	scanf("%d", &t);
	while (t--) {
		op = valid_char(); scanf("%s", d);
		switch(op) {
		case '+': modify(d, 1); break;
		case '-': modify(d, -1); break;
		case '?': printf("%d\n", query(d)); break;
		}
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = (int)100007;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef long double ld;

typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

ll n, a[N];

int to_binary (string s){
  int ans = 0;
  for (int i = 0; i < s.size(); ++i){
      ans *= 2;
      ans += (s[i] - '0') % 2;
  }

  return ans;
}

int main (){
  scanf ("%d", &n);

  for (int i = 1; i <= n; ++i){
      char c;
      scanf (" %c", &c);
      string s;
      cin >> s;

      int t = to_binary (s);

      if (c == '+'){
          ++a[t];
      }

      if (c == '-'){
          --a[t];
      }

      if (c == '?'){
          printf ("%d\n", a[t]);
      }
  }

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = (int)1e6 + 1;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef long double ld;

typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

int n, a[(1 << 19) + 2];
int main (){
  scanf ("%d", &n);

  for (int i = 1; i <= n; ++i){
      char c;
      scanf (" %c", &c);
      string s;
      cin >> s;

      int to = 0;

      for (int i = 0; i < s.size(); ++i){
          to *= 2;
          to += (s[i] - '0') % 2;
      }

      if (c == '+'){
          ++a[to];
      }

      if (c == '-'){
          --a[to];
      }

      if (c == '?'){
          printf ("%d\n", a[to]);
      }
  }

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = (int)(1 << 19) + 2;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef long double ld;

typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

int n, a[N];

int to_binary (string s){
  int ans = 0;
  for (int i = 0; i < s.size(); ++i){
      ans *= 2;
      ans += (s[i] - '0') % 2;
  }

  return ans;
}

int main (){
  scanf ("%d", &n);

  for (int i = 1; i <= n; ++i){
      char c;
      scanf (" %c", &c);
      string s;
      cin >> s;

      int t = to_binary (s);

      if (c == '+'){
          ++a[t];
      }

      if (c == '-'){
          --a[t];
      }

      if (c == '?'){
          printf ("%d\n", a[t]);
      }
  }

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = (int)1e5 + 1;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef long double ld;

typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

int n, a[N];

int to_binary (string s){
  int ans = 0;
  for (int i = 0; i < s.size(); ++i){
      ans *= 2;
      ans += (s[i] - '0') % 2;
  }

  return ans;
}

int main (){
  scanf ("%d", &n);

  for (int i = 1; i <= n; ++i){
      char c;
      scanf (" %c", &c);
      string s;
      cin >> s;

      int t = to_binary (s);

      if (c == '+'){
          ++a[t];
      }

      if (c == '-'){
          --a[t];
      }

      if (c == '?'){
          printf ("%d\n", a[t]);
      }
  }

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define lli long long int
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back
#define eb emplace_back
#define em emplace
#define all(v) v.begin(), v.end()
#define mod 1000000007
lli power_mod(lli a, lli x)
{
	if (x == 0)
		return 1;
	lli y = power_mod(a, x / 2);
	lli ans = (y * y) % mod;
	if (x % 2)
		ans = (ans * a) % mod;
	return ans;
}
lli inv(lli a) { return power_mod(a, mod - 2); }
lli power(lli a, lli x)
{
	if (x == 0)
		return 1;
	lli y = power(a, x / 2);
	lli ans = (y * y);
	if (x % 2)
		ans *= a;
	return ans;
}
template <class T>
void printvec(vector<T> &a)
{
	for (int i = 0; i < a.size(); i++)
	{
		cout << a[i] << " ";
	}
	cout << endl;
}
template <class T>
void printarr(T a[], int n)
{
	for (int i = 0; i < n; i++)
	{
		cout << a[i] << " ";
	}
	cout << endl;
}
lli nocc(lli pato, multiset<lli> &a)
{
	lli c = 0;
	for (auto it = a.begin(); it != a.end(); it++)
	{
		lli x = *it;
		lli pat = pato;
		int found = 1;
		while (x != 0 || pat != 0)
		{
			int d = x % 10;
			int dpat = pat % 10;
			d = d % 2;
			if (d != dpat)
			{
				found = 0;
				break;
			}
			x /= 10;
			pat /= 10;
		}
		if (found)
			c++;
	}
	return c;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	lli t;
	cin >> t;
	multiset<lli> a;
	while (t--)
	{
		char ch;
		cin >> ch;
		lli x;
		cin >> x;
		if (ch == '+')
		{
			a.insert(x);
		}
		else if (ch == '-')
		{
			auto it = a.find(x);
			a.erase(it);
		}
		else
		{
			lli m = nocc(x, a);
			cout << m << endl;
		}
	}
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define lli long long int
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back
#define eb emplace_back
#define em emplace
#define all(v) v.begin(), v.end()
#define mod 1000000007
lli power_mod(lli a, lli x)
{
	if (x == 0)
		return 1;
	lli y = power_mod(a, x / 2);
	lli ans = (y * y) % mod;
	if (x % 2)
		ans = (ans * a) % mod;
	return ans;
}
lli inv(lli a) { return power_mod(a, mod - 2); }
lli power(lli a, lli x)
{
	if (x == 0)
		return 1;
	lli y = power(a, x / 2);
	lli ans = (y * y);
	if (x % 2)
		ans *= a;
	return ans;
}
template <class T>
void printvec(vector<T> &a)
{
	for (int i = 0; i < a.size(); i++)
	{
		cout << a[i] << " ";
	}
	cout << endl;
}
template <class T>
void printarr(T a[], int n)
{
	for (int i = 0; i < n; i++)
	{
		cout << a[i] << " ";
	}
	cout << endl;
}
int nocc(lli pato, multiset<lli> &a)
{
	int c = 0;
	for (auto it = a.begin(); it != a.end(); it++)
	{
		lli x = *it;
		lli pat = pato;
		int found = 1;
		while (x != 0 || pat != 0)
		{
			int d = x % 10;
			int dpat = pat % 10;
			d = d % 2;
			if (d != dpat)
			{
				found = 0;
				break;
			}
			x /= 10;
			pat /= 10;
		}
		if (found)
			c++;
	}
	return c;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	lli t;
	cin >> t;
	unordered_map<lli, int> mp;
	while (t--)
	{
		char ch;
		cin >> ch;
		lli x;
		string lol;
		cin >> lol;
		for (int i = 0; i < lol.size(); i++)
		{
			int x = lol[i] - '0';
			x = x % 2;
			lol[i] = '0' + x;
		}
		stringstream ss;
		ss << lol;
		ss >> x;
		if (ch == '+')
		{
			mp[x]++;
		}
		else if (ch == '-')
		{
			mp[x]--;
		}
		else
		{
			if (mp.find(x) == mp.end())
			{
				cout << 0 << endl;
			}
			else
				cout << mp[x] << endl;
		}
	}
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define lli long long int
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back
#define eb emplace_back
#define em emplace
#define all(v) v.begin(), v.end()
#define mod 1000000007
lli power_mod(lli a, lli x)
{
	if (x == 0)
		return 1;
	lli y = power_mod(a, x / 2);
	lli ans = (y * y) % mod;
	if (x % 2)
		ans = (ans * a) % mod;
	return ans;
}
lli inv(lli a) { return power_mod(a, mod - 2); }
lli power(lli a, lli x)
{
	if (x == 0)
		return 1;
	lli y = power(a, x / 2);
	lli ans = (y * y);
	if (x % 2)
		ans *= a;
	return ans;
}
template <class T>
void printvec(vector<T> &a)
{
	for (int i = 0; i < a.size(); i++)
	{
		cout << a[i] << " ";
	}
	cout << endl;
}
template <class T>
void printarr(T a[], int n)
{
	for (int i = 0; i < n; i++)
	{
		cout << a[i] << " ";
	}
	cout << endl;
}
int nocc(lli pato, multiset<lli> &a)
{
	int c = 0;
	for (auto it = a.begin(); it != a.end(); it++)
	{
		lli x = *it;
		lli pat = pato;
		int found = 1;
		while (x != 0 || pat != 0)
		{
			int d = x % 10;
			int dpat = pat % 10;
			d = d % 2;
			if (d != dpat)
			{
				found = 0;
				break;
			}
			x /= 10;
			pat /= 10;
		}
		if (found)
			c++;
	}
	return c;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	lli t;
	cin >> t;
	multiset<lli> a;
	while (t--)
	{
		char ch;
		cin >> ch;
		lli x;
		cin >> x;
		if (ch == '+')
		{
			a.insert(x);
		}
		else if (ch == '-')
		{
			auto it = a.find(x);
			a.erase(it);
		}
		else
		{
			int m = nocc(x, a);
			cout << m;
			cout << '\n';
		}
	}
}


#include<bits/stdc++.h>
#define ll          long long int
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define Max(a,b)    ((a)>(b)?(a):(b))
#define Min(a,b)    ((a)<(b)?(a):(b))
#define rep(i,a,b)  for (__typeof((b)) i=(a);i<(b);i+=1)
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define debug(a)    cerr<<#a<<": ";for(auto i:a)cerr<<i<<" ";cerr<<'\n';
using namespace std;

void solve(){
    int n;
    scanf("%d",&n);
    map<string,ll>m;
    while(n--){
        char ch;
        ll p;
        cin>>ch;
        if(ch=='+'){
            scanf("%I64d",&p);
            string s;
            while(p){
                s.pb('0'+p%2);
                p/=10;
            }
            while(sz(s) && s.back()=='0')s.pop_back();
            m[s]++;
        }
        else if(ch=='-'){
            scanf("%I64d",&p);
            string s;
            while(p){
                s.pb('0'+p%2);
                p/=10;
            }
            while(sz(s) && s.back()=='0')s.pop_back();
            m[s]--;
        }
        else{
            string s;
            cin>>s;
            reverse(all(s));
            while(sz(s) && s.back()=='0')s.pop_back();
            printf("%I64d\n",m[s]);
        }
    }
}

int main(){
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll          long long int
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define Max(a,b)    ((a)>(b)?(a):(b))
#define Min(a,b)    ((a)<(b)?(a):(b))
#define rep(i,a,b)  for (__typeof((b)) i=(a);i<(b);i+=1)
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define debug(a)    cerr<<#a<<": ";for(auto i:a)cerr<<i<<" ";cerr<<'\n';
using namespace std;

void solve(){
    int n;
    cin>>n;
    map<string,int>m;
    while(n--){
        char ch;
        int p;
        cin>>ch;
        if(ch=='+'){
            cin>>p;
            string s;
            rep(i,0,18){
                s.pb('0'+p%2);
                m[s]++;
                p/=10;
            }
        }
        else if(ch=='-'){
            cin>>p;
            string s;
            rep(i,0,18){
                s.pb('0'+p%2);
                m[s]--;
                p/=10;
            }
        }
        else{
            string s;
            cin>>s;
            reverse(all(s));
            cout<<m[s]<<endl;
        }
    }
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll          long long int
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define Max(a,b)    ((a)>(b)?(a):(b))
#define Min(a,b)    ((a)<(b)?(a):(b))
#define rep(i,a,b)  for (__typeof((b)) i=(a);i<(b);i+=1)
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define debug(a)    cerr<<#a<<": ";for(auto i:a)cerr<<i<<" ";cerr<<'\n';
using namespace std;

void solve(){
    ll n;
    cin>>n;
    map<string,ll>m;
    while(n--){
        char ch;
        ll p;
        cin>>ch;
        if(ch=='+'){
            cin>>p;
            string s;
            while(p){
                s.pb('0'+p%2);
                p/=10;
            }
            while(sz(s) && s.back()=='0')s.pop_back();
            rep(i,0,18){
                m[s]++;
                s.pb('0');
            }
        }
        else if(ch=='-'){
            cin>>p;
            string s;
            while(p){
                s.pb('0'+p%2);
                p/=10;
            }
            while(sz(s) && s.back()=='0')s.pop_back();
            rep(i,0,18){
                m[s]--;
                s.pb('0');
            }
        }
        else{
            string s;
            cin>>s;
            reverse(all(s));
            while(sz(s) && s.back()=='0')s.pop_back();
            cout<<m[s]<<endl;
        }
    }
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll          long long int
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define Max(a,b)    ((a)>(b)?(a):(b))
#define Min(a,b)    ((a)<(b)?(a):(b))
#define rep(i,a,b)  for (__typeof((b)) i=(a);i<(b);i+=1)
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define debug(a)    cerr<<#a<<": ";for(auto i:a)cerr<<i<<" ";cerr<<'\n';
using namespace std;

void solve(){
    ll n;
    cin>>n;
    map<string,ll>m;
    while(n--){
        char ch;
        ll p;
        cin>>ch;
        if(ch=='+'){
            cin>>p;
            string s;
            rep(i,0,18){
                s.pb('0'+p%2);
                m[s]++;
                p/=10;
            }
        }
        else if(ch=='-'){
            cin>>p;
            string s;
            rep(i,0,18){
                s.pb('0'+p%2);
                m[s]--;
                p/=10;
            }
        }
        else{
            string s;
            cin>>s;
            reverse(all(s));
            cout<<m[s]<<endl;
        }
    }
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


#include <iostream>
#include <set>
#include <map>
#include <string>
#include <cassert>
using namespace std;
typedef unsigned long long ll;

string bitize(ll x){
    string s("0000000000000000");
    int p=17;
    while(x!=0){
        assert(p>=0);
        if(x%2==1) s[p]='1';
        p--;
        x/=10;
    }
    return s;
}

int main()
{
    int n;
    cin>>n;
    multiset<ll> numbers;
    map<string,int> bit_count;
    for(int i=0;i<n;i++){
        char c;
        ll x;
        cin>>c;
        if(c=='+'){
            cin>>x;
            numbers.insert(x);
            string s = bitize(x);
            bit_count[s]++;
        }else if(c=='-'){
            cin>>x;
            numbers.erase(x);
            string s = bitize(x);
            bit_count[s]--;
        }else{
            string pattern;
            cin>>pattern;
            pattern=string(18-pattern.size(),'0')+pattern;
            assert(pattern.size()==18);
            cout<<bit_count[pattern]<<endl;
        }
    }
    return 0;
}


#include <iostream>
#include <set>
#include <map>
#include <string>
#include <cassert>
using namespace std;
typedef unsigned long long ll;

ll bitize(ll x){
    ll s=0;
    ll p=1;
    while(x!=0){
        if(x%2==1) s+=p;
        p*=10;
        x/=10;
    }
    return s;
}

int main()
{
    int n;
    cin>>n;
    multiset<ll> numbers;
    map<ll,int> bit_count;
    for(int i=0;i<n;i++){
        char c;
        ll x;
        cin>>c;
        if(c=='+'){
            cin>>x;
            numbers.insert(x);
            ll s = bitize(x);
            bit_count[s]++;
        }else if(c=='-'){
            cin>>x;
            numbers.erase(x);
            ll s = bitize(x);
            bit_count[s]--;
        }else{
            ll pattern;
            cin>>pattern;
            cout<<bit_count[pattern]<<endl;
        }
    }
    return 0;
}


#include <iostream>
#include <set>
#include <map>
#include <string>
#include <cassert>
using namespace std;
typedef unsigned long long ll;

int bitize(ll x){
    int s=0;
    int p=1;
    while(x!=0){
        if(x%2==1) s+=p;
        p*=10;
        x/=10;
    }
    return s;
}

int main()
{
    int n;
    cin>>n;
    multiset<ll> numbers;
    map<int,int> bit_count;
    for(int i=0;i<n;i++){
        char c;
        ll x;
        cin>>c;
        if(c=='+'){
            cin>>x;
            numbers.insert(x);
            int s = bitize(x);
            bit_count[s]++;
        }else if(c=='-'){
            cin>>x;
            numbers.erase(x);
            int s = bitize(x);
            bit_count[s]--;
        }else{
            int pattern;
            cin>>pattern;
            cout<<bit_count[pattern]<<endl;
        }
    }
    return 0;
}


#include <iostream>
#include <set>
#include <map>
#include <unordered_map>
#include <string>
#include <cassert>
using namespace std;
typedef unsigned long long ll;
typedef int bits;
bits bitize(ll x){
    bits s=0, p=1;
    while(x!=0){
        if(x%2==1) s|=p;
        p<<=1;
        x/=10;
    }
    return s;
}

int main()
{
    int n;
    cin>>n;
    multiset<ll> numbers;
    unordered_map<bits,int> bit_count;
    for(int i=0;i<n;i++){
        char c;
        ll x;
        cin>>c;
        if(c=='+'){
            cin>>x;
            numbers.insert(x);
            bits s = bitize(x);
            bit_count[s]++;
        }else if(c=='-'){
            cin>>x;
            numbers.erase(x);
            bits s = bitize(x);
            bit_count[s]--;
        }else{
            string pattern;
            cin>>pattern;
            bits s=0;
            for(int i=0;i<pattern.size();i++){
                s<<=1;
                if(pattern[i]=='1') s|=1;

            }
            cout<<bit_count[s]<<endl;
        }
    }
    return 0;
}


#include <iostream>
#include <set>
#include <map>
#include <string>
#include <cassert>
using namespace std;
typedef unsigned long long ll;

int bitize(ll x){
    int s=0;
    while(x!=0){
        if(x%2==0) s*=10;
        else s=s*10+1;
        x/=10;
    }
    return s;
}

int main()
{
    int n;
    cin>>n;
    multiset<ll> numbers;
    map<int,int> bit_count;
    for(int i=0;i<n;i++){
        char c;
        ll x;
        cin>>c;
        if(c=='+'){
            cin>>x;
            numbers.insert(x);
            int s = bitize(x);
            bit_count[s]++;
        }else if(c=='-'){
            cin>>x;
            numbers.erase(x);
            int s = bitize(x);
            bit_count[s]--;
        }else{
            int pattern;
            cin>>pattern;
            cout<<bit_count[pattern]<<endl;
        }
    }
    return 0;
}


#include <cstdlib>
#include <cctype>
#include <unordered_map>
using namespace std;
typedef unsigned long long ll;
typedef int bits;
char str[30];

bits bitize(char *s){
    bits b=0;
    while( *s ==' ')s++;
    while(isdigit(*s)){
        b<<=1;
        if((*s-'0')%2==1) b|=1;
        s++;
    }
    return b;
}

int main()
{
    int n;
    scanf("%d\n", &n);
    //multiset<ll> numbers;
    unordered_map<bits,int> bit_count;
    for(int i=0;i<n;i++){
        gets(str);
        char *s=str;
        if(s[0]=='+'){
            bits b=bitize(s+1);
            bit_count[b]++;
        }else if(s[0]=='-'){
            bits b=bitize(s+1);
            bit_count[b]--;
        }else{
            s++;
            while( *s ==' ')s++;
            bits b=0;
            while(isdigit(*s)){
                b<<=1;
                if(*s=='1') b|=1;
                s++;
            }
            printf("%d\n",bit_count[b]);
        }
    }
    return 0;
}


#include <iostream>
#include <set>
#include <map>
#include <string>
#include <cassert>
using namespace std;
typedef unsigned long long ll;

string bitize(ll x){
    string s("0000000000000000");
    int p=15;
    while(x!=0){
        if(x%2==1) s[p]='1';
        p--;
        x/=10;
        assert(p>=0);
    }
    return s;
}

int main()
{
    int n;
    cin>>n;
    multiset<ll> numbers;
    map<string,int> bit_count;
    for(int i=0;i<n;i++){
        char c;
        ll x;
        cin>>c;
        if(c=='+'){
            cin>>x;
            numbers.insert(x);
            string s = bitize(x);
            bit_count[s]++;
        }else if(c=='-'){
            cin>>x;
            numbers.erase(x);
            string s = bitize(x);
            bit_count[s]--;
        }else{
            string pattern;
            cin>>pattern;
            pattern=string(16-pattern.size(),'0')+pattern;
            assert(pattern.size()==16);
            cout<<bit_count[pattern]<<endl;
        }
    }
    return 0;
}


#include <iostream>
#include <set>
#include <map>
#include <string>
#include <cassert>
using namespace std;
typedef unsigned long long ll;
typedef int bits;
bits bitize(ll x){
    bits s=0, p=1;
    while(x!=0){
        if(x%2==1) s|=p;
        p<<=1;
        x/=10;
    }
    return s;
}

int main()
{
    int n;
    cin>>n;
    multiset<ll> numbers;
    map<bits,int> bit_count;
    for(int i=0;i<n;i++){
        char c;
        ll x;
        cin>>c;
        if(c=='+'){
            cin>>x;
            numbers.insert(x);
            bits s = bitize(x);
            bit_count[s]++;
        }else if(c=='-'){
            cin>>x;
            numbers.erase(x);
            bits s = bitize(x);
            bit_count[s]--;
        }else{
            string pattern;
            cin>>pattern;
            bits s=0;
            for(int i=0;i<pattern.size();i++){
                s<<=1;
                if(pattern[i]=='1') s|=1;

            }
            cout<<bit_count[s]<<endl;
        }
    }
    return 0;
}


#include <iostream>
#include <set>
#include <map>
#include <string>
#include <cassert>
using namespace std;
typedef unsigned long long ll;

string bitize(ll x){
    string s("000000000000000000");
    int p=17;
    while(x!=0){
        assert(p>=0);
        if(x%2==1) s[p]='1';
        p--;
        x/=10;
    }
    return s;
}

int main()
{
    int n;
    cin>>n;
    multiset<ll> numbers;
    map<string,int> bit_count;
    for(int i=0;i<n;i++){
        char c;
        ll x;
        cin>>c;
        if(c=='+'){
            cin>>x;
            numbers.insert(x);
            string s = bitize(x);
            bit_count[s]++;
        }else if(c=='-'){
            cin>>x;
            numbers.erase(x);
            string s = bitize(x);
            bit_count[s]--;
        }else{
            string pattern;
            cin>>pattern;
            pattern=string(18-pattern.size(),'0')+pattern;
            assert(pattern.size()==18);
            cout<<bit_count[pattern]<<endl;
        }
    }
    return 0;
}


#include <iostream>
//#include <set>
//#include <map>
#include <unordered_map>
#include <string>
#include <cassert>
using namespace std;
typedef unsigned long long ll;
typedef int bits;
bits bitize(ll x){
    bits s=0, p=1;
    while(x!=0){
        if(x%2==1) s|=p;
        p<<=1;
        x/=10;
    }
    return s;
}

int main()
{
    int n;
    cin>>n;
    //multiset<ll> numbers;
    unordered_map<bits,int> bit_count;
    for(int i=0;i<n;i++){
        char c;
        ll x;
        cin>>c;
        if(c=='+'){
            cin>>x;
            //numbers.insert(x);
            bits s = bitize(x);
            bit_count[s]++;
        }else if(c=='-'){
            cin>>x;
            //numbers.erase(x);
            bits s = bitize(x);
            bit_count[s]--;
        }else{
            string pattern;
            cin>>pattern;
            bits s=0;
            for(int i=0;i<pattern.size();i++){
                s<<=1;
                if(pattern[i]=='1') s|=1;

            }
            cout<<bit_count[s]<<endl;
        }
    }
    return 0;
}


#include <iostream>
#include <set>
#include <map>
#include <string>
#include <cassert>
using namespace std;
typedef unsigned long long ll;

string bitize(ll x){
    string s("0000000000000000");
    int p=15;
    while(x!=0){
        if(x%2==1) s[p]='1';
        p--;
        x/=10;
        assert(p>=0);
    }
    return s;
}

int main()
{
    int n;
    cin>>n;
    multiset<ll> numbers;
    map<string,int> bit_count;
    for(int i=0;i<n;i++){
        char c;
        ll x;
        cin>>c;
        if(c=='+'){
            cin>>x;
            numbers.insert(x);
            string s = bitize(x);
            bit_count[s]++;

            for(int p=0;p<15;p++){
                s[p]='*';
                bit_count[s]++;
            }
        }else if(c=='-'){
            cin>>x;
            numbers.erase(x);
            string s = bitize(x);
            bit_count[s]--;
            assert(bit_count[s]>=0);
            for(int p=0;p<15;p++){
                s[p]='*';
                bit_count[s]--;
                assert(bit_count[s]>=0);
            }
        }else{
            string pattern;
            cin>>pattern;
            pattern=string(16-pattern.size(),'*')+pattern;
            assert(pattern.size()==16);
            cout<<bit_count[pattern]<<endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long double DB;
typedef pair<int,int> PII;
typedef vector<int> VI;
#define MP make_pair
#define ST first
#define ND second
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define DBG(x) cerr<<#x<<" = "<<x<<"\n";
#define DBGV(x) { cerr<<#x<<" = { "; \
	for(auto yy:x) cerr<<yy<<" "; \
	cerr<<"}\n"; \
}
const int MX = 1e6 + 5;
const int INF = 1e9 + 5;
const LL MOD = 1e9 + 7;
LL fastPow(LL a, LL b, LL p=MOD) {
	LL res = 1;
	while (b) {
		if (b & 1LL) { res *= a; res %= p; }
		a *= a; a %= p;
		b >>= 1;
	}
	return res;
}
LL revMod(LL a, LL p=MOD) {
	return fastPow(a,p-2,p);
}
/* ----------------------------------------------------------------------------- */

int t;
unordered_multiset<LL> S;
char wcz[20];

int solve()
{
	cin >> t;
	while (t--)
	{
		string x, y;
		scanf("%s", wcz); x = wcz;
		scanf("%s", wcz); y = wcz;
		y = string(y.rbegin(), y.rend());
		while (y.size() < 18)
			y += '0';

		if (x == "+")
		{
			for (auto &r: y)
				if ((r-'0')%2 == 0)
					r='0';
				else
					r='1';

			long long z = 0;
			for (auto r: y){
				z *= 10LL;
				z += r - '0';
			}
			S.insert(z);
		}
		if (x == "-")
		{
			for (auto &r: y)
				if ((r-'0')%2 == 0)
					r='0';
				else
					r='1';

			long long z = 0;
			for (auto r: y){
				z *= 10LL;
				z += r - '0';
			}
			S.erase(S.find(z));
		}
		if (x == "?")
		{
			long long z = 0;
			for (auto r: y){
				z *= 10LL;
				z += r - '0';
			}
			printf("%d\n", S.count(z));
		}
	}

	return 0;
}

int main()
{
	// ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	// int ttt; scanf("%d", &ttt); while (ttt--)
		solve();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long double DB;
typedef pair<int,int> PII;
typedef vector<int> VI;
#define MP make_pair
#define ST first
#define ND second
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define DBG(x) cerr<<#x<<" = "<<x<<"\n";
#define DBGV(x) { cerr<<#x<<" = { "; \
	for(auto yy:x) cerr<<yy<<" "; \
	cerr<<"}\n"; \
}
const int MX = 1e6 + 5;
const int INF = 1e9 + 5;
const LL MOD = 1e9 + 7;
LL fastPow(LL a, LL b, LL p=MOD) {
	LL res = 1;
	while (b) {
		if (b & 1LL) { res *= a; res %= p; }
		a *= a; a %= p;
		b >>= 1;
	}
	return res;
}
LL revMod(LL a, LL p=MOD) {
	return fastPow(a,p-2,p);
}
/* ----------------------------------------------------------------------------- */

int t;
multiset<LL> S;
char wcz[20];

int solve()
{
	cin >> t;
	while (t--)
	{
		string x, y;
		scanf("%s", wcz); x = wcz;
		scanf("%s", wcz); y = wcz;
		y = string(y.rbegin(), y.rend());
		while (y.size() < 18)
			y += '0';

		if (x == "+")
		{
			for (auto &r: y)
				if ((r-'0')%2 == 0)
					r='0';
				else
					r='1';

			long long z = 0;
			for (auto r: y){
				z *= 10LL;
				z += r - '0';
			}
			S.insert(z);
		}
		if (x == "-")
		{
			for (auto &r: y)
				if ((r-'0')%2 == 0)
					r='0';
				else
					r='1';

			long long z = 0;
			for (auto r: y){
				z *= 10LL;
				z += r - '0';
			}
			S.erase(S.find(z));
		}
		if (x == "?")
		{
			long long z = 0;
			for (auto r: y){
				z *= 10LL;
				z += r - '0';
			}
			printf("%d\n", S.count(z));
		}
	}

	return 0;
}

int main()
{
	// ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	// int ttt; scanf("%d", &ttt); while (ttt--)
		solve();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long double DB;
typedef pair<int,int> PII;
typedef vector<int> VI;
#define MP make_pair
#define ST first
#define ND second
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define DBG(x) cerr<<#x<<" = "<<x<<"\n";
#define DBGV(x) { cerr<<#x<<" = { "; \
	for(auto yy:x) cerr<<yy<<" "; \
	cerr<<"}\n"; \
}
const int MX = 1e6 + 5;
const int INF = 1e9 + 5;
const LL MOD = 1e9 + 7;
LL fastPow(LL a, LL b, LL p=MOD) {
	LL res = 1;
	while (b) {
		if (b & 1LL) { res *= a; res %= p; }
		a *= a; a %= p;
		b >>= 1;
	}
	return res;
}
LL revMod(LL a, LL p=MOD) {
	return fastPow(a,p-2,p);
}
/* ----------------------------------------------------------------------------- */

int t;
unordered_multiset<string> S;
char wcz[20];

int solve()
{
	cin >> t;
	while (t--)
	{
		string x, y;
		scanf("%s", wcz); x = wcz;
		scanf("%s", wcz); y = wcz;
		y = string(y.rbegin(), y.rend());
		while (y.size() < 18)
			y += '0';

		if (x == "+")
		{
			for (auto &r: y)
				if ((r-'0')%2 == 0)
					r='0';
				else
					r='1';

			S.insert(y);
		}
		if (x == "-")
		{
			for (auto &r: y)
				if ((r-'0')%2 == 0)
					r='0';
				else
					r='1';

			S.erase(S.find(y));
		}
		if (x == "?")
		{
			printf("%d\n", S.count(y));
		}
	}

	return 0;
}

int main()
{
	// ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	// int ttt; scanf("%d", &ttt); while (ttt--)
		solve();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long double DB;
typedef pair<int,int> PII;
typedef vector<int> VI;
#define MP make_pair
#define ST first
#define ND second
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define DBG(x) cerr<<#x<<" = "<<x<<"\n";
#define DBGV(x) { cerr<<#x<<" = { "; \
	for(auto yy:x) cerr<<yy<<" "; \
	cerr<<"}\n"; \
}
const int MX = 1e6 + 5;
const int INF = 1e9 + 5;
const LL MOD = 1e9 + 7;
LL fastPow(LL a, LL b, LL p=MOD) {
	LL res = 1;
	while (b) {
		if (b & 1LL) { res *= a; res %= p; }
		a *= a; a %= p;
		b >>= 1;
	}
	return res;
}
LL revMod(LL a, LL p=MOD) {
	return fastPow(a,p-2,p);
}
/* ----------------------------------------------------------------------------- */

int t;
multiset<string> S[20];

int solve()
{
	cin >> t;
	while (t--)
	{
		string x, y; cin >> x >> y;
		y = string(y.rbegin(), y.rend());
		while (y.size() < 20)
			y += '0';

		if (x == "+")
		{
			for (auto &r: y)
				if ((r-'0')%2 == 0)
					r='0';
				else
					r='1';

			string d = "";
			int i = 0;
			for (auto r: y)
			{
				d += r;
				S[i++].insert(d);
			}
		}
		if (x == "-")
		{
			for (auto &r: y)
				if ((r-'0')%2 == 0)
					r='0';
				else
					r='1';

			string d = "";
			int i = 0;
			for (auto r: y)
			{
				d += r;
				S[i].erase(S[i].find(d)); i++;
			}
		}
		if (x == "?")
		{
			cout << S[(int)y.size()-1].count(y) << "\n";
		}
	}

	return 0;
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	// int ttt; scanf("%d", &ttt); while (ttt--)
		solve();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long double DB;
typedef pair<int,int> PII;
typedef vector<int> VI;
#define MP make_pair
#define ST first
#define ND second
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define DBG(x) cerr<<#x<<" = "<<x<<"\n";
#define DBGV(x) { cerr<<#x<<" = { "; \
	for(auto yy:x) cerr<<yy<<" "; \
	cerr<<"}\n"; \
}
const int MX = 1e6 + 5;
const int INF = 1e9 + 5;
const LL MOD = 1e9 + 7;
LL fastPow(LL a, LL b, LL p=MOD) {
	LL res = 1;
	while (b) {
		if (b & 1LL) { res *= a; res %= p; }
		a *= a; a %= p;
		b >>= 1;
	}
	return res;
}
LL revMod(LL a, LL p=MOD) {
	return fastPow(a,p-2,p);
}
/* ----------------------------------------------------------------------------- */

int t;
map<long long, int> M;
char wcz[20];

int solve()
{
	cin >> t;
	while (t--)
	{
		string x, y;
		scanf("%s", wcz); x = wcz;
		scanf("%s", wcz); y = wcz;
		y = string(y.rbegin(), y.rend());
		while (y.size() < 18)
			y += '0';

		if (x == "+")
		{
			for (auto &r: y)
				if ((r-'0')%2 == 0)
					r='0';
				else
					r='1';

			long long z = 0;
			for (auto r: y){
				z *= 10LL;
				z += r - '0';
			}
			M[z]++;
		}
		if (x == "-")
		{
			for (auto &r: y)
				if ((r-'0')%2 == 0)
					r='0';
				else
					r='1';

			long long z = 0;
			for (auto r: y){
				z *= 10LL;
				z += r - '0';
			}
			M[z] --;
		}
		if (x == "?")
		{
			long long z = 0;
			for (auto r: y){
				z *= 10LL;
				z += r - '0';
			}
			printf("%d\n", M[z]);
		}
	}

	return 0;
}

int main()
{
	// ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	// int ttt; scanf("%d", &ttt); while (ttt--)
		solve();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long double DB;
typedef pair<int,int> PII;
typedef vector<int> VI;
#define MP make_pair
#define ST first
#define ND second
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define DBG(x) cerr<<#x<<" = "<<x<<"\n";
#define DBGV(x) { cerr<<#x<<" = { "; \
	for(auto yy:x) cerr<<yy<<" "; \
	cerr<<"}\n"; \
}
const int MX = 1e6 + 5;
const int INF = 1e9 + 5;
const LL MOD = 1e9 + 7;
LL fastPow(LL a, LL b, LL p=MOD) {
	LL res = 1;
	while (b) {
		if (b & 1LL) { res *= a; res %= p; }
		a *= a; a %= p;
		b >>= 1;
	}
	return res;
}
LL revMod(LL a, LL p=MOD) {
	return fastPow(a,p-2,p);
}
/* ----------------------------------------------------------------------------- */

int t;
unordered_multiset<string> S[20];
char wcz[20];

int solve()
{
	cin >> t;
	while (t--)
	{
		string x, y;
		scanf("%s", wcz); x = wcz;
		scanf("%s", wcz); y = wcz;
		y = string(y.rbegin(), y.rend());
		while (y.size() < 18)
			y += '0';

		if (x == "+")
		{
			for (auto &r: y)
				if ((r-'0')%2 == 0)
					r='0';
				else
					r='1';

			string d = "";
			int i = 0;
			for (auto r: y)
			{
				d += r;
				S[i++].insert(d);
			}
		}
		if (x == "-")
		{
			for (auto &r: y)
				if ((r-'0')%2 == 0)
					r='0';
				else
					r='1';

			string d = "";
			int i = 0;
			for (auto r: y)
			{
				d += r;
				S[i].erase(S[i].find(d)); i++;
			}
		}
		if (x == "?")
		{
			printf("%d\n", S[(int)y.size()-1].count(y));
		}
	}

	return 0;
}

int main()
{
	// ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	// int ttt; scanf("%d", &ttt); while (ttt--)
		solve();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long double DB;
typedef pair<int,int> PII;
typedef vector<int> VI;
#define MP make_pair
#define ST first
#define ND second
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define DBG(x) cerr<<#x<<" = "<<x<<"\n";
#define DBGV(x) { cerr<<#x<<" = { "; \
	for(auto yy:x) cerr<<yy<<" "; \
	cerr<<"}\n"; \
}
const int MX = 1e6 + 5;
const int INF = 1e9 + 5;
const LL MOD = 1e9 + 7;
LL fastPow(LL a, LL b, LL p=MOD) {
	LL res = 1;
	while (b) {
		if (b & 1LL) { res *= a; res %= p; }
		a *= a; a %= p;
		b >>= 1;
	}
	return res;
}
LL revMod(LL a, LL p=MOD) {
	return fastPow(a,p-2,p);
}
/* ----------------------------------------------------------------------------- */

int t;
unordered_multiset<string> S[20];
char wcz[100];

int solve()
{
	cin >> t;
	while (t--)
	{
		string x, y;
		scanf("%s", wcz); x = wcz;
		scanf("%s", wcz); y = wcz;
		y = string(y.rbegin(), y.rend());
		while (y.size() < 20)
			y += '0';

		if (x == "+")
		{
			for (auto &r: y)
				if ((r-'0')%2 == 0)
					r='0';
				else
					r='1';

			string d = "";
			int i = 0;
			for (auto r: y)
			{
				d += r;
				S[i++].insert(d);
			}
		}
		if (x == "-")
		{
			for (auto &r: y)
				if ((r-'0')%2 == 0)
					r='0';
				else
					r='1';

			string d = "";
			int i = 0;
			for (auto r: y)
			{
				d += r;
				S[i].erase(S[i].find(d)); i++;
			}
		}
		if (x == "?")
		{
			printf("%d\n", S[(int)y.size()-1].count(y));
		}
	}

	return 0;
}

int main()
{
	// ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	// int ttt; scanf("%d", &ttt); while (ttt--)
		solve();
	return 0;
}


#include <iostream>
#include <thread>
#include <cstdio>
#include <string>
#include <map>
#include <vector>
#include <stdio.h>
#include <set>

using namespace std;

typedef long long ll;
multiset<ll> S;
map<ll, ll > ans;

ll get(ll x) {
	ll ret = 0, p = 1;
	while (x) {
		int u = x % 10;
		if (u & 1) ret += p;
		p *= 10;
		x /= 10;
	}
	return ret;
}

int main () {
	int t;
	cin >> t;
	while (t--) {
		char ch;
		cin >> ch;
		ll x;
		if (ch == '+') {
			cin >> x;
			if (S.find(x) == S.end()) ;ans[get(x)]++;
			S.insert(x);
		}
		else if (ch == '-') {
			cin >> x;
			S.erase(S.find(x));
			if (S.find(x) == S.end()) ;ans[get(x)]--;
		}
		else {
			char ch[20];
			cin >> ch;
			ll num = 0;
			for (int i = 0; ch[i]; i++) {
				num = (num * 10 + ch[i] - '0');
			}
			cout << ans[num] << endl;
		}
	}
}


#include <iostream>
#include <thread>
#include <cstdio>
#include <string>
#include <map>
#include <vector>
#include <stdio.h>
#include <set>

using namespace std;

typedef long long ll;
multiset<ll> S, ans;

ll get(int x) {
	ll ret = 0, p = 1;
	while (x) {
		int u = x % 10;
		if (u & 1) ret += p;
		p *= 10;
		x /= 10;
	}
	return ret;
}

int main () {
	int t;
	cin >> t;
	while (t--) {
		char ch;
		cin >> ch;
		ll x;
		if (ch == '+') {
			cin >> x;
			if (S.count(x) == 0) ans.insert(get(x));
			S.insert(x);
		}
		else if (ch == '-') {
			cin >> x;
			S.erase(S.find(x));
			if (S.count(x) == 0) ans.erase(ans.find(get(x)));
		}
		else {
			char ch[20];
			cin >> ch;
			ll num = 0;
			for (int i = 0; ch[i]; i++) {
				num = (num * 10 + ch[i] - '0');
			}
			cout << ans.count(num) << endl;
		}
	}
}


#include <iostream>
#include <thread>
#include <cstdio>
#include <string>
#include <map>
#include <vector>
#include <stdio.h>
#include <set>

using namespace std;

typedef long long ll;
multiset<ll> S, ans;

ll get(ll x) {
	ll ret = 0, p = 1;
	while (x) {
		int u = x % 10;
		if (u & 1) ret += p;
		p *= 10;
		x /= 10;
	}
	return ret;
}

int main () {
	int t;
	cin >> t;
	while (t--) {
		char ch;
		scanf("%c", &ch);
		ll x;
		if (ch == '+') {
			scanf("%I64d", &x);
			if (S.count(x) == 0) ans.insert(get(x));
			S.insert(x);
		}
		else if (ch == '-') {
			scanf("%I64d", &x);
			S.erase(S.find(x));
			if (S.count(x) == 0) ans.erase(ans.find(get(x)));
		}
		else {
			char ch[20];
			scanf("%s", ch);
			ll num = 0;
			for (int i = 0; ch[i]; i++) {
				num = (num * 10 + ch[i] - '0');
			}
			printf ("%d\n", (int)ans.count(num));
		}
	}
}


#include <iostream>
#include <thread>
#include <cstdio>
#include <string>
#include <map>
#include <vector>
#include <stdio.h>
#include <set>

using namespace std;

typedef long long ll;
multiset<ll> S, ans;

ll get(ll x) {
	ll ret = 0, p = 1;
	while (x) {
		int u = x % 10;
		if (u & 1) ret += p;
		p *= 10;
		x /= 10;
	}
	return ret;
}

int main () {
	int t;
	cin >> t;
	while (t--) {
		char ch;
		cin >> ch;
		ll x;
		if (ch == '+') {
			cin >> x;
			if (S.count(x) == 0) ans.insert(get(x));
			S.insert(x);
		}
		else if (ch == '-') {
			cin >> x;
			S.erase(S.find(x));
			if (S.count(x) == 0) ans.erase(ans.find(get(x)));
		}
		else {
			char ch[20];
			cin >> ch;
			ll num = 0;
			for (int i = 0; ch[i]; i++) {
				num = (num * 10 + ch[i] - '0');
			}
			cout << ans.count(num) << endl;
		}
	}
}


#include <iostream>
#include <thread>
#include <cstdio>
#include <string>
#include <map>
#include <vector>
#include <stdio.h>
#include <set>

using namespace std;

typedef long long ll;
multiset<ll> S;
map<ll, ll > ans;

ll get(ll x) {
	ll ret = 0, p = 1;
	while (x) {
		int u = x % 10;
		if (u & 1) ret += p;
		p *= 10;
		x /= 10;
	}
	return ret;
}

int main () {
	int t;
	cin >> t;
	while (t--) {
		char ch;
		cin >> ch;
		ll x;
		if (ch == '+') {
			cin >> x;
			if (S.find(x) == S.end()) ans[get(x)]++;
			S.insert(x);
		}
		else if (ch == '-') {
			cin >> x;
			S.erase(S.find(x));
			if (S.find(x) == S.end()) ans[get(x)]--;
		}
		else {
			char ch[20];
			cin >> ch;
			ll num = 0;
			for (int i = 0; ch[i]; i++) {
				num = (num * 10 + ch[i] - '0');
			}
			cout << ans[num] << endl;
		}
	}
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;

 int h[262150]={0};
string convert(ll n)
{
	string s;
	while(n)
	{
		s.push_back((n%10)%2+'0');
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;

}

string bin(int n)
{
    string s;
    while(n)
    {s.push_back(n%2 + '0');
     n/=2;
    }
    reverse(s.begin(),s.end());
    if(s.size()==0)
        return "0";
    return s;
}
int f(string s)
{
  //reverse(s.begin(),s.end());
  int ans=0;
  int n=s.size();
  for(int i=0;i<n;i++)
  {
  	ans+= pow(2,i)*(s[n-i-1]-'0');
  }
	return ans;
}

int main()
{
  int t;
  cin>>t;

  while(t--)
  {
  	char ch;
  	ll n;
  	cin>>ch>>n;

  	if(ch=='+' || ch=='-')
  	{
  		string s= convert(n);
  		int i= f(s);

  		if(ch=='+')
  		h[i]++;
  		else
  		h[i]--;
  	}

  	else
  	{
  		string a = convert(n);
        int c= h[f(a)];

  		cout<<c<<"\n";
  	}
  }
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;

 int h[262150]={0};
string convert(ll n)
{
	string s;
	while(n)
	{
		s.push_back((n%10)%2+'0');
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;

}

string bin(int n)
{
    string s;
    while(n)
    {s.push_back(n%2 + '0');
     n/=2;
    }
    reverse(s.begin(),s.end());
    return s;
}
int f(string s)
{
  reverse(s.begin(),s.end());
  int ans=0;
  int n=s.size();
  for(int i=0;i<n;i++)
  {
  	ans+= pow(2,i)*(s[n-i-1]-'0');
  }
	return ans;
}

int main()
{
  int t;
  cin>>t;

  while(t--)
  {
  	char ch;
  	ll n;
  	cin>>ch>>n;

  	if(ch=='+' || ch=='-')
  	{
  		string s= convert(n); //cout<<"string "<<s<<" ";
  		int i= f(s);
  		//cout<<"add "<<i<<" ";
  		if(ch=='+')
  		h[i]++;
  		else
  		h[i]--;
  	}

  	else
  	{
  		string a = convert(n);  //to_string(n)
  		//cout<<"a="<<a<<" ";
  		int c=0;
  		int flag;
  		for(int i=0;i<=262144;i++)
  		{
  			flag=0;
  			if(h[i])
  			{
  				 string b= bin(i);
                 //cout<<"b="<<b<<" ";
  				if(a.size()>=b.size())
  				{
  					int p1=0;int p2=0;

  					while(p2<b.size())
  					{
  						if(a[p1]!=b[p2])
  						{flag=1;
  					     break;
  					    }
  					    p1++;p2++;
  					}
  					if(!flag)
  					{
  						for(int j=p1;j<a.size();j++)
  						if(a[j]!='0')
  						{
  							flag=1;
  							break;
  						}
  					}
  					if(!flag)
  					c+=h[i];

  				}
  				else //a.size<b.size
  				{
  				    reverse(a.begin(),a.end());
  			     	int p2=0;int p1=0;
  					while(p2<a.size())
  					{
  						if(b[p1]!=a[p2])
  						{flag=1;
  					     break;
  					    }
  					    p1++;p2++;
  					}  					//cout<<"flag="<<flag;
  					if(!flag)
  					{
  						for(int j=p1;j<b.size();j++)
  						if(b[j]!='0')
  						{
  							flag=1;
  							break;
  						}
  					}
  					//cout<<"flag="<<flag;
  					if(!flag)
  					c+=h[i];
  				}
  			}
  		}
  		cout<<c<<"\n";
  	}
  }
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp  make_pair
#define mod 1000000007

using namespace std;

struct node
{
    ll val;
    ll freq;
    node(ll v)
    {
      val=v;
      freq=1;
    }
};
ll count(ll n)
{
    ll c=0;
    while(n)
    {
        c++;
        n/=10;
    }

    return c;
}

main()
{
    ll t;
    cin>>t;
    vector<node>v;
    while(t--)
    {
       char ch;
       ll n;
       cin>>ch>>n;
       ll flag;
       if(ch=='+' || ch=='-')
       {
           flag=0;
       for(ll i=0;i<v.size();i++)
       {

         if(v[i].val==n)
         {
             if(ch=='+')v[i].freq++;
             else if(ch=='-')v[i].freq--;
             flag=1;
             break;
         }

       }
       if(!flag && ch=='+')
        {
          node *p=new node(n);
          v.pb(*p);
        }
       }

       else
       {
           ll c=0;
           ll N=n;
        for(ll i=0;i<v.size();i++)
       {
          ll k= v[i].val;
          n=N;
          if(count(n)>=count(k))
          {
              flag=0;
             while(k)
             {
                 if((k%10)%2!=n%10)
                 {
                     flag=1;
                     break;
                 }
                 k/=10;
                 n/=10;
             }
                 if(!flag)
                 {
                     while(n)
                     {
                         if((n%10)!=0)
                            {flag=1;break;}
                        n/=10;
                     }
                 }
               if(!flag)c+=v[i].freq; //cout<<"c="<<c<<" ";
          }

           else //n<k
           {
               flag=0;
               while(n)
             {
                 if((k%10)%2!=n%10)
                 {
                     flag=1;
                     break;
                 }
                 k/=10; //cout<<k<<endl;
                 n/=10; //cout<<n<<endl;
             }

             //cout<<"flag="<<flag<<"k="<<k<<"\n";
                 if(!flag)
                 {
                     while(k)
                     {
                         if((k%10)%2!=0)
                            {flag=1;break;}
                        k/=10;
                     }
                 }

                  //cout<<flag<<"n="<<n<<"k="<<k<<" ";
               if(!flag)c+=v[i].freq; //cout<<"v[i]="<<v[i].val<<"freq"<<v[i].freq<<" ";}

           }
         }
          cout<<c<<"\n";
       }
    }

}


#include<bits/stdc++.h>
#define ll long long
using namespace std;

 int h[262150]={0};
string convert(ll n)
{
	string s;
	while(n)
	{
		s.push_back((n%10)%2+'0');
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;

}

string bin(int n)
{
    string s;
    while(n)
    {s.push_back(n%2 + '0');
     n/=2;
    }
    reverse(s.begin(),s.end());
    if(s.size()==0)
        return "0";
    return s;
}
int f(string s)
{
  //reverse(s.begin(),s.end());
  int ans=0;
  int n=s.size();
  for(int i=0;i<n;i++)
  {
  	ans+= pow(2,i)*(s[n-i-1]-'0');
  }
	return ans;
}

int main()
{
  int t;
  cin>>t;

  while(t--)
  {
  	char ch;
  	ll n;
  	cin>>ch>>n;

  	if(ch=='+' || ch=='-')
  	{
  		string s= convert(n); //cout<<"string "<<s<<" ";
  		int i= f(s);
  		//cout<<"add "<<i<<" ";
  		if(ch=='+')
  		h[i]++;
  		else
  		h[i]--;
  	}

  	else
  	{
  		string a = convert(n);  //to_string(n)
  		//cout<<"a="<<a<<" ";
  		reverse(a.begin(),a.end());
  		int c=0;
  		int flag;
  		for(int i=0;i<=262144;i++)
  		{
  			flag=0;
  			if(h[i])
  			{
  				 string b= bin(i);
                 //cout<<"b="<<b<<" ";
  				if(a.size()>=b.size())
  				{

  					reverse(b.begin(),b.end());
  					//cout<<a<<" "<<b<<endl;
  					int p1=0;int p2=0;
  					while(p2<b.size())
  					{
  						if(a[p1]!=b[p2])
  						{flag=1;
  					     break;
  					    }
  					    p1++;p2++;
  					} //cout<<"flag="<<flag<<" ";
  					if(!flag)
  					{
  						for(int j=p1;j<a.size();j++)
  						if(a[j]!='0')
  						{
  							flag=1;
  							break;
  						}
  					}
  					//cout<<"flag="<<flag<<" ";
  					if(!flag)
  					c+=h[i];
  					//cout<<"C="<<c<<" ";

  				}
  				else //a.size<b.size
  				{

  				    reverse(b.begin(),b.end());
  			     	int p2=0;int p1=0;
  					while(p2<a.size())
  					{
  						if(b[p1]!=a[p2])
  						{flag=1;
  					     break;
  					    }
  					    p1++;p2++;
  					}  					//cout<<"flag="<<flag;
  					if(!flag)
  					{
  						for(int j=p1;j<b.size();j++)
  						if(b[j]!='0')
  						{
  							flag=1;
  							break;
  						}
  					}
  					//cout<<"flag="<<flag;

  					if(!flag)
  					c+=h[i];
  				}
  			}
  		}
  		cout<<c<<"\n";
  	}
  }
}


#include<bits/stdc++.h>

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define len(s) s.length()
#define forp(i,a,b) for( i=a;i<=b;i++)
#define rep(i,n)    for( i=0;i<n;i++)
#define ren(i,n)    for( i=n-1;i>=0;i--)
#define forn(i,a,b) for( i=a;i>=b;i--)
#define on cout<<endl
#define all(v) v.begin(),v.end()
#define mem(n,m) memset(n,m,sizeof(n))
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int>
#define vll vector<long long>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++)

#define boost ios_base::sync_with_stdio(0)
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100001
#define SIZE 200001

typedef long long  ll;
typedef long double  ldo;
typedef double  db ;
using namespace std;

ll func2(string p)
{
    ll m=0,i;
    reverse(all(p));
    rep(i,(ll)len(p))
    {
        if(p[i]=='1')
        {
            m+=(1<<i);
        }
    }

    return m;
}

ll func(ll a)
{
    ll k=a,i;
    ll m=0,rem;
    string l;
    while(a!=0)
    {
        rem=a%10;
        if(rem%2!=0)
        {
            l+='1';
        }
        else
        l+='0';

        a/=10;
    }
    //cout<<k<<":"<<m;on;
    //reverse(all(l));
    m=0;
    rep(i,(ll)len(l))
    {
        if(l[i]=='1')
        {
            m+=(1<<i);
        }
    }

    //m = stoi(l);

    //m = bintodec(m);
    return m;
}

int main()
{
    boost;

    ll q,a,ctr,tp,i,tp4;
    string p;
    char ty;
    mll m,m2,m3;
    m.clear();
    m2.clear();
    m3.clear();
    cin>>q;
    getchar();
    while(q--)
    {
        cin>>ty;
        getchar();
        ctr=0;
        if(ty == '?')
        {
            cin>>p;
            tp4 = func2(p);
            cout<<m3[tp4];on;

        }

        else if(ty == '+')
        {
            cin>>a;
            m2[a]++;
            if(m[a]==0)
            {
                m[a] = func(a);
                //cout<<m[a];on;
            }
            m3[m[a]]++;
        }

        else if(ty == '-')
        {
            cin>>a;
            m2[a]--;
            m3[m[a]]--;
        }
    }

    return 0;
}


#include<bits/stdc++.h>

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define len(s) s.length()
#define forp(i,a,b) for( i=a;i<=b;i++)
#define rep(i,n)    for( i=0;i<n;i++)
#define ren(i,n)    for( i=n-1;i>=0;i--)
#define forn(i,a,b) for( i=a;i>=b;i--)
#define on cout<<endl
#define all(v) v.begin(),v.end()
#define mem(n,m) memset(n,m,sizeof(n))
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int>
#define vll vector<long long>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++)

#define boost ios_base::sync_with_stdio(0)
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100001
#define SIZE 200001

typedef long long  ll;
typedef long double  ldo;
typedef double  db ;
using namespace std;

ll bintodec(ll n)
{
    ll output = 0;

    for(ll i=0; n > 0; i++) {

        if(n % 10 == 1) {
            output += (1 << i);
        }
        n /= 10;
    }

    return output;
}

ll func(ll a)
{
    ll k=a,i;
    ll m=0,rem;
    string l;
    while(a!=0)
    {
        rem=a%10;
        if(rem%2!=0)
        {
            l+='1';
        }
        else
        l+='0';

        a/=10;
    }
    //cout<<k<<":"<<m;on;
    //reverse(all(l));
    m=0;
    rep(i,(ll)len(l))
    {
        if(l[i]=='1')
        {
            m+=(1<<i);
        }
    }

    //m = stoi(l);

    //m = bintodec(m);
    return m;
}

int main()
{
    boost;

    ll q,a,ctr,tp,i,tp4;
    char ty;
    mll m,m2,m3;
    m.clear();
    m2.clear();
    m3.clear();
    cin>>q;
    getchar();
    while(q--)
    {
        cin>>ty>>a;

        ctr=0;
        if(ty == '?')
        {
            tp4 = bintodec(a);
            cout<<m3[tp4];on;

        }

        else if(ty == '+')
        {
            m2[a]++;
            if(m[a]==0)
            {
                m[a] = func(a);
                //cout<<m[a];on;
            }
            m3[m[a]]++;
        }

        else if(ty == '-')
        {
            m2[a]--;
            m3[m[a]]--;
        }
    }

    return 0;
}


#include<bits/stdc++.h>

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define len(s) s.length()
#define forp(i,a,b) for( i=a;i<=b;i++)
#define rep(i,n)    for( i=0;i<n;i++)
#define ren(i,n)    for( i=n-1;i>=0;i--)
#define forn(i,a,b) for( i=a;i>=b;i--)
#define on cout<<endl
#define all(v) v.begin(),v.end()
#define mem(n,m) memset(n,m,sizeof(n))
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int>
#define vll vector<long long>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++)

#define boost ios_base::sync_with_stdio(0)
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100001
#define SIZE 200001

typedef long long  ll;
typedef long double  ldo;
typedef double  db ;
using namespace std;

ll func2(string p)
{
    ll m=0,i;
    reverse(all(p));
    rep(i,(ll)len(p))
    {
        if(p[i]=='1')
        {
            m+=(1<<i);
        }
    }

    return m;
}

ll func(ll a)
{
    ll k=a,i;
    ll m=0,rem;
    string l;
    while(a!=0)
    {
        rem=a%10;
        if(rem%2!=0)
        {
            l+='1';
        }
        else
        l+='0';

        a/=10;
    }
    m=0;
    rep(i,(ll)len(l))
    {
        if(l[i]=='1')
        {
            m+=(1<<i);
        }
    }
    return m;
}

int main()
{

    ll q,ctr,tp,i,tp4;
    unsigned long long a;
    string p;
    char ty;
    mll m,m2,m3;
    m.clear();
    m2.clear();
    m3.clear();
    cin>>q;
    while(q--)
    {
        cin>>ty;
        getchar();
        ctr=0;

        if(ty == '?')
        {
            cin>>p;
            tp4 = func2(p);
            cout<<m3[tp4];on;

        }

        else if(ty == '+')
        {
            cin>>a;
            m2[a]++;
            if(m[a]==0)
            {
                m[a] = func(a);
            }
            m3[m[a]]++;
        }

        else
        {
            cin>>a;
            m2[a]--;
            m3[m[a]]--;
        }

    }

    return 0;
}


#include<bits/stdc++.h>

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define len(s) s.length()
#define forp(i,a,b) for( i=a;i<=b;i++)
#define rep(i,n)    for( i=0;i<n;i++)
#define ren(i,n)    for( i=n-1;i>=0;i--)
#define forn(i,a,b) for( i=a;i>=b;i--)
#define on cout<<endl
#define all(v) v.begin(),v.end()
#define mem(n,m) memset(n,m,sizeof(n))
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int>
#define vll vector<long long>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++)

#define boost ios_base::sync_with_stdio(0)
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100001
#define SIZE 200001

typedef long long  ll;
typedef long double  ldo;
typedef double  db ;
using namespace std;

ll func2(string p)
{
    ll m=0,i;
    reverse(all(p));
    rep(i,(ll)len(p))
    {
        if(p[i]=='1')
        {
            m+=(1<<i);
        }
    }

    return m;
}

ll func(ll a)
{
    ll k=a,i;
    ll m=0,rem;
    string l;
    while(a!=0)
    {
        rem=a%10;
        if(rem%2!=0)
        {
            l+='1';
        }
        else
        l+='0';

        a/=10;
    }
    //cout<<k<<":"<<m;on;
    //reverse(all(l));
    m=0;
    rep(i,(ll)len(l))
    {
        if(l[i]=='1')
        {
            m+=(1<<i);
        }
    }

    //m = stoi(l);

    //m = bintodec(m);
    return m;
}

int main()
{

    ll q,ctr,tp,i,tp4;
    unsigned long long a;
    string p;
    char ty;
    mll m,m2,m3;
    m.clear();
    m2.clear();
    m3.clear();
    cin>>q;
    while(q--)
    {
        cin>>ty;
        getchar();
        ctr=0;

        if(ty == '?')
        {
            cin>>p;
            tp4 = func2(p);
            cout<<m3[tp4];on;

        }

        if(ty == '+')
        {
            cin>>a;
            m2[a]++;
            if(m[a]==0)
            {
                m[a] = func(a);
                //cout<<m[a];on;
            }
            m3[m[a]]++;
        }

        else
        {
            cin>>a;
            m2[a]--;
            m3[m[a]]--;
        }

    }

    return 0;
}


#include<bits/stdc++.h>

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define len(s) s.length()
#define forp(i,a,b) for( i=a;i<=b;i++)
#define rep(i,n)    for( i=0;i<n;i++)
#define ren(i,n)    for( i=n-1;i>=0;i--)
#define forn(i,a,b) for( i=a;i>=b;i--)
#define on cout<<endl
#define all(v) v.begin(),v.end()
#define mem(n,m) memset(n,m,sizeof(n))
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int>
#define vll vector<long long>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++)

#define boost ios_base::sync_with_stdio(0)
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100001
#define SIZE 200001

typedef long long  ll;
typedef long double  ldo;
typedef double  db ;
using namespace std;

ll func2(string p)
{
    ll m=0,i;
    reverse(all(p));
    rep(i,(ll)len(p))
    {
        if(p[i]=='1')
        {
            m+=(1<<i);
        }
    }

    return m;
}

ll func(ll a)
{
    ll k=a,i;
    ll m=0,rem;
    string l;
    while(a!=0)
    {
        rem=a%10;
        if(rem%2!=0)
        {
            l+='1';
        }
        else
        l+='0';

        a/=10;
    }
    //cout<<k<<":"<<m;on;
    //reverse(all(l));
    m=0;
    rep(i,(ll)len(l))
    {
        if(l[i]=='1')
        {
            m+=(1<<i);
        }
    }

    //m = stoi(l);

    //m = bintodec(m);
    return m;
}

int main()
{
    boost;

    ll q,ctr,tp,i,tp4;
    unsigned long long a;
    string p;
    char ty;
    mll m,m2,m3;
    m.clear();
    m2.clear();
    m3.clear();
    cin>>q;
    while(q--)
    {
        cin>>ty;
        getchar();
        ctr=0;

        if(ty == '+')
        {
            cin>>a;
            m2[a]++;
            if(m[a]==0)
            {
                m[a] = func(a);
                //cout<<m[a];on;
            }
            m3[m[a]]++;
        }

        else if(ty == '-')
        {
            cin>>a;
            m2[a]--;
            m3[m[a]]--;
        }

        else
        {
            cin>>p;
            tp4 = func2(p);
            cout<<m3[tp4];on;

        }
    }

    return 0;
}


#include<bits/stdc++.h>

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define len(s) s.length()
#define forp(i,a,b) for( i=a;i<=b;i++)
#define rep(i,n)    for( i=0;i<n;i++)
#define ren(i,n)    for( i=n-1;i>=0;i--)
#define forn(i,a,b) for( i=a;i>=b;i--)
#define on cout<<endl
#define all(v) v.begin(),v.end()
#define mem(n,m) memset(n,m,sizeof(n))
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int>
#define vll vector<long long>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++)

#define boost ios_base::sync_with_stdio(0)
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100001
#define SIZE 200001

typedef long long  ll;
typedef long double  ldo;
typedef double  db ;
using namespace std;

ll func2(string p)
{
    ll m=0,i;
    reverse(all(p));
    rep(i,(ll)len(p))
    {
        if(p[i]=='1')
        {
            m+=(1<<i);
        }
    }

    return m;
}

ll func(ll a)
{
    ll k=a,i;
    ll m=0,rem;
    string l;
    while(a!=0)
    {
        rem=a%10;
        if(rem%2!=0)
        {
            l+='1';
        }
        else
        l+='0';

        a/=10;
    }
    //cout<<k<<":"<<m;on;
    //reverse(all(l));
    m=0;
    rep(i,(ll)len(l))
    {
        if(l[i]=='1')
        {
            m+=(1<<i);
        }
    }

    //m = stoi(l);

    //m = bintodec(m);
    return m;
}

int main()
{
    //boost;

    ll q,ctr,tp,i,tp4;
    unsigned long long a;
    string p;
    char ty;
    mll m,m2,m3;
    m.clear();
    m2.clear();
    m3.clear();
    cin>>q;
    while(q--)
    {
        cin>>ty;
        getchar();
        ctr=0;

        if(ty == '+')
        {
            cin>>a;
            m2[a]++;
            if(m[a]==0)
            {
                m[a] = func(a);
                //cout<<m[a];on;
            }
            m3[m[a]]++;
        }

        else if(ty == '-')
        {
            cin>>a;
            m2[a]--;
            m3[m[a]]--;
        }

        else
        {
            cin>>p;
            tp4 = func2(p);
            cout<<m3[tp4];on;

        }
    }

    return 0;
}


#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define int long long
#define st first
#define nd second
#define rd third
#define FOR(i, a, b) for(int i =(a); i <=(b); ++i)
#define RE(i, n) FOR(i, 1, n)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define REP(i, n) for(int i = 0;i <(n); ++i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
template<typename TH> void _dbg(const char* sdbg, TH h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename TH, typename... TA> void _dbg(const char* sdbg, TH h, TA... t) {
  while(*sdbg != ',')cerr<<*sdbg++; cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<"\n"; }}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define cerr if(0)cout
#endif
#define next ____next
#define prev ____prev
#define left ____left
#define hash ____hash
typedef long long ll;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<pair<int, int> > VPII;
typedef vector<pair<ll, ll> > VPLL;

template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
template<class T1, class T2>
ostream& operator<< (ostream &out, pair<T1, T2> pair) { return out << "(" << pair.first << ", " << pair.second << ")";}
template<class A, class B, class C> struct Triple { A first; B second; C third;
  bool operator<(const Triple& t) const { if (st != t.st) return st < t.st; if (nd != t.nd) return nd < t.nd; return rd < t.rd; } };
template<class T> void ResizeVec(T&, vector<int>) {}
template<class T> void ResizeVec(vector<T>& vec, vector<int> sz) {
  vec.resize(sz[0]); sz.erase(sz.begin()); if (sz.empty()) { return; }
  for (T& v : vec) { ResizeVec(v, sz); }
}
typedef Triple<int, int, int> TIII;
template<class A, class B, class C>
ostream& operator<< (ostream &out, Triple<A, B, C> t) { return out << "(" << t.st << ", " << t.nd << ", " << t.rd << ")"; }
template<class T> ostream& operator<<(ostream& out, vector<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }

map<string, int> mapka;

void Add(int x, int sign) {
  string s;
//   if (x == 0) {
//     mapka["0"] += sign;
//     return;
//   }
  REP (it, 18) {
    s += (char)((int)'0' + (x % 2));
    mapka[s] += sign;
    x /= 10;
  }
  return;
}

int32_t main() {

  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(10);
  cerr << fixed << setprecision(10);
  cin.tie(0);
  //double beg_clock = 1.0 * clock() / CLOCKS_PER_SEC;

  int t;
  cin>>t;
  RE (tt, t) {
    char c;
    cin>>c;
    if (c == '?') {
      string s;
      cin>>s;
      reverse(ALL(s));
      while (SZ(s) < 18) {
        s += '0';
      }
      cout<<mapka[s]<<endl;
    } else {
      int x;
      cin>>x;
      if (c == '+') {
        Add(x, 1);
      } else {
        Add(x, -1);
      }
    }
  }

  return 0;
}