#include<bits/stdc++.h>
using namespace std;
const int maxx = 1e7+1;
bool ck[maxx];
int ans[maxx];
vector<int> nt;
int n, m;
int a[maxx];

void sang(){
    int x = sqrt(maxx);
    for(int i=2;i<=x;i++){
        if(ck[i]==false){
            for(int j=i*i;j<=maxx;j+=i){
                ck[j]=true;
            }
        }
    }
    for(int i=2;i<=maxx;i++){
        if(ck[i]==false){
            nt.push_back(i);
        }
    }
}

void phantich(int n){
    int i=0;
    set<int> b;
    while(n!=1){
        if(n%nt[i]==0){
            b.insert(nt[i]);
            n/=nt[i];
            if(ck[n]==false){
                b.insert(n);
                break;
            }
        }
        else{
            i++;
        }
    }
    set<int> :: iterator j = b.begin();
    for(;j!=b.end();j++){
        ans[(*j)]++;
    }
}

int main()
{
//    freopen("in.inp", "r", stdin);
   // freopen("ou.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    sang();
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(ck[a[i]])
            phantich(a[i]);
        else
            ans[a[i]]++;
    }
    for(int i=1;i<maxx;i++){
        ans[i]+=ans[i-1];
    }
    cin>>m;
    int l ,r;
    for(int i=0;i<m;i++){
        cin>>l>>r;
        l = min(l, 10000000);
        r = min(r, 10000000);
        cout<<ans[r]-ans[l-1]<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5;
const int maxx = 1e7;
bool ck[maxx];
int ans[maxn];
vector<int> nt;
int n, m;
int a[maxn];

void sang(){
    int x = sqrt(maxx);
    for(int i=2;i<=x;i++){
        if(ck[i]==false){
            nt.push_back(i);
            for(int j=i*2;j<maxx;j+=i){
                ck[j]=true;
            }
        }
    }
}

void phantich(int n){
    int i=0;
    set<int> b;
    while(n!=1){
        if(n%nt[i]==0){
            b.insert(nt[i]);
            n/=nt[i];
        }
        else{
            i++;
        }
    }
    set<int> :: iterator j = b.begin();
    for(;j!=b.end();j++){
        ans[(*j)]++;
    }
}

int main()
{
 //   freopen("in.inp", "r", stdin);
   // freopen("ou.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    sang();
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        phantich(a[i]);
    }
    for(int i=1;i<maxn;i++){
        ans[i]+=ans[i-1];
    }
    cin>>m;
    int l ,r;
    for(int i=0;i<m;i++){
        cin>>l>>r;
        if(l>10000000&&r>10000000){
            cout<<0<<endl;
        }
        else{
            l = min(l, 10000000);
            r = min(r, 10000000);
            cout<<ans[r]-ans[l-1]<<endl;
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e6+1;
const int maxx = 1e7;
bool ck[maxx];
int ans[maxn];
vector<int> nt;
int n, m;
int a[maxn];

void sang(){
    int x = sqrt(maxx);
    for(int i=2;i<=x;i++){
        if(ck[i]==false){
            nt.push_back(i);
            for(int j=i*2;j<maxx;j+=i){
                ck[j]=true;
            }
        }
    }
}

void phantich(int n){
    int i=0;
    set<int> b;
    while(n!=1){
        if(n%nt[i]==0){
            b.insert(nt[i]);
            n/=nt[i];
        }
        else{
            i++;
        }
    }
    set<int> :: iterator j = b.begin();
    for(;j!=b.end();j++){
        ans[(*j)]++;
    }
}

int main()
{
   // freopen("in.inp", "r", stdin);
//    freopen("ou.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    sang();
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        phantich(a[i]);
    }
    for(int i=1;i<maxn;i++){
        ans[i]+=ans[i-1];
    }
    cin>>m;
    int l ,r;
    for(int i=0;i<m;i++){
        cin>>l>>r;
        if(l>10000000&&r>10000000){
            cout<<0<<endl;
        }
        else{
            l = min(l, 10000000);
            r = min(r, 10000000);
            cout<<ans[r]-ans[l-1]<<endl;
        }
    }
}


#include <bits/stdc++.h>
#define all(v) v.begin(),v.end()
#define REP(i, a, b) \
for(int i = int(a); i < int(b); i++)
#define pb(v,e) v.push_back(e)
#define N 1000000
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
int primes[N+1];
void xd(){
	for(int i=2;i<=N;i++)primes[i]=1;
    primes[0]=primes[1]=0;
    for(int i=2;i*i<=N;i++){
		if(primes[i]==1){
			for(int j=i*i;j<=N;j+=i)primes[j]=0;
		}
	}

}
int main(){
	int n,q;
	int num;
	cin>>n;
	xd();
	int j;
	REP(i,0,n){
		scanf("%d",&num);
		j=2;
		if(num==1)continue;
		while(j<=num){
			if(primes[j]){
				if(num%j==0){
					primes[j]++;
				}
			}
			j++;
		}
	}

	REP(i,1,N){
		if(primes[i]>0)primes[i]--;
		primes[i]+=primes[i-1];
	}
	cin>>q;
	int x,y;
	REP(i,0,q){
		scanf("%d %d",&x,&y);
		printf("%d\n",primes[y]-primes[x-1]);
	}

}


#include <bits/stdc++.h>
#define all(v) v.begin(),v.end()
#define REP(i, a, b) \
for(int i = int(a); i < int(b); i++)
#define pb(v,e) v.push_back(e)
#define N 10000000
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
long long primes[N+5];
void xd(){
	for(int i=2;i<=N;i++)primes[i]=1;
    primes[0]=primes[1]=0;
    for(int i=2;i*i<=N;i++){
		if(primes[i]==1){
			for(int j=i*i;j<=N;j+=i)primes[j]=0;
		}
	}

}
int main(){
	int n,q;
	int num;
	xd();
	cin>>n;
	int j;
	REP(i,0,n){
		scanf("%d",&num);
		j=2;
		while(j<=num){
			if(primes[j]){
				if(num%j==0){
					num/=j;
					primes[j]++;
				}
			}
			j++;
		}
	}
	REP(i,2,N+1){
		if(primes[i]>0)primes[i]--;
		primes[i]+=primes[i-1];
	}
	cin>>q;
	int x,y;
	REP(i,0,q){
		scanf("%d %d",&x,&y);
		if(x>N)x=N+1;
		if(y>N)y=N+1;
		printf("%lld\n",primes[y]-primes[x-1]);
	}

}


#include <bits/stdc++.h>
#define all(v) v.begin(),v.end()
#define REP(i, a, b) \
for(int i = int(a); i < int(b); i++)
#define pb(v,e) v.push_back(e)
#define N 2000000000
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
long long primes[N+5];
void xd(){
	for(int i=2;i<=N;i++)primes[i]=1;
    primes[0]=primes[1]=0;
    for(int i=2;i*i<=N;i++){
		if(primes[i]==1){
			for(int j=i*i;j<=N;j+=i)primes[j]=0;
		}
	}

}
int main(){
	int n,q;
	int num;
	xd();
	cin>>n;
	int j;
	REP(i,0,n){
		scanf("%d",&num);
		j=2;
		while(j<=num){
			if(primes[j]){
				if(num%j==0){
					num/=j;
					primes[j]++;
				}
			}
			j++;
		}
	}
	REP(i,2,N){
		if(primes[i]>0)primes[i]--;
		primes[i]+=primes[i-1];
	}
	cin>>q;
	int x,y;
	REP(i,0,q){
		scanf("%d %d",&x,&y);
		printf("%lld\n",primes[y]-primes[x-1]);
	}

}


#include <bits/stdc++.h>
#define all(v) v.begin(),v.end()
#define REP(i, a, b) \
for(int i = int(a); i < int(b); i++)
#define pb(v,e) v.push_back(e)
#define N 10000000
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
long long primes[N+5];
void xd(){
	for(int i=2;i<=N;i++)primes[i]=1;
    primes[0]=primes[1]=0;
    for(int i=2;i*i<=N;i++){
		if(primes[i]==1){
			for(int j=i*i;j<=N;j+=i)primes[j]=0;
		}
	}

}
int main(){
	int n,q;
	int num;
	xd();
	cin>>n;
	int j;
	REP(i,0,n){
		scanf("%d",&num);
		j=2;
		while(j<=num){
			if(primes[j]){
				if(num%j==0){
					num/=j;
					primes[j]++;
				}
			}
			j++;
		}
	}
	REP(i,2,N){
		if(primes[i]>0)primes[i]--;
		primes[i]+=primes[i-1];
	}
	cin>>q;
	int x,y;
	REP(i,0,q){
		scanf("%d %d",&x,&y);
		if(x>N)x=N;
		if(y>N)y=N;
		printf("%lld\n",primes[y]-primes[x-1]);
	}

}


#include <bits/stdc++.h>
#define all(v) v.begin(),v.end()
#define REP(i, a, b) \
for(int i = int(a); i < int(b); i++)
#define pb(v,e) v.push_back(e)
#define N 1000000
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
long long primes[N+5];
void xd(){
	for(int i=2;i<=N;i++)primes[i]=1;
    primes[0]=primes[1]=0;
    for(int i=2;i*i<=N;i++){
		if(primes[i]==1){
			for(int j=i*i;j<=N;j+=i)primes[j]=0;
		}
	}

}
int main(){
	int n,q;
	int num;
	xd();
	cin>>n;
	int j;
	REP(i,0,n){
		scanf("%d",&num);
		j=2;
		while(j<=num){
			if(primes[j]){
				if(num%j==0){
					num/=j;
					primes[j]++;
				}
			}
			j++;
		}
	}
	REP(i,2,N){
		if(primes[i]>0)primes[i]--;
		primes[i]+=primes[i-1];
	}
	cin>>q;
	int x,y;
	REP(i,0,q){
		scanf("%d %d",&x,&y);
		printf("%lld\n",primes[y]-primes[x-1]);
	}

}


#include <bits/stdc++.h>
#define all(v) v.begin(),v.end()
#define REP(i, a, b) \
for(int i = int(a); i < int(b); i++)
#define pb(v,e) v.push_back(e)
#define N 1000000
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
long long primes[N+5];
void xd(){
	for(int i=2;i<=N;i++)primes[i]=1;
    primes[0]=primes[1]=0;
    for(int i=2;i*i<=N;i++){
		if(primes[i]==1){
			for(int j=i*i;j<=N;j+=i)primes[j]=0;
		}
	}

}
int main(){
	int n,q;
	int num;
	xd();
	cin>>n;
	int j;
	REP(i,0,n){
		scanf("%d",&num);
		j=2;
		while(j<=num){
			if(primes[j]){
				if(num%j==0){
					primes[j]++;
				}
			}
			j++;
		}
	}

	REP(i,2,N){
		if(primes[i]>0)primes[i]--;
		primes[i]+=primes[i-1];
	}
	cin>>q;
	int x,y;
	REP(i,0,q){
		scanf("%d %d",&x,&y);
		printf("%lld\n",primes[y]-primes[x-1]);
	}

}


#include <bits/stdc++.h>
#define all(v) v.begin(),v.end()
#define REP(i, a, b) \
for(int i = int(a); i < int(b); i++)
#define pb(v,e) v.push_back(e)
#define N 1000000
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
long long primes[N+5];
void xd(){
	for(int i=2;i<=N;i++)primes[i]=1;
    primes[0]=primes[1]=0;
    for(int i=2;i*i<=N;i++){
		if(primes[i]==1){
			for(int j=i*i;j<=N;j+=i)primes[j]=0;
		}
	}

}
int main(){
	int n,q;
	int num;
	xd();
	cin>>n;
	int j;
	REP(i,0,n){
		scanf("%d",&num);
		j=2;
		while(j<=num){
			if(primes[j]){
				if(num%j==0){
					num/=j;
					primes[j]++;
				}
			}
			j++;
		}
	}
	REP(i,2,N){
		if(primes[i]>0)primes[i]--;
		primes[i]+=primes[i-1];
	}
	cin>>q;
	int x,y;
	REP(i,0,q){
		scanf("%d %d",&x,&y);
		if(x>N)x=N;
		if(y>N)y=N;
		printf("%lld\n",primes[y]-primes[x-1]);
	}

}


#include <bits/stdc++.h>
#define all(v) v.begin(),v.end()
#define REP(i, a, b) \
for(int i = int(a); i < int(b); i++)
#define pb(v,e) v.push_back(e)
#define N 10000000
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
long long primes[N+5];
void xd(){
	for(int i=2;i<=N;i++)primes[i]=1;
    primes[0]=primes[1]=0;
    for(int i=2;i*i<=N;i++){
		if(primes[i]==1){
			for(int j=i*i;j<=N;j+=i)primes[j]=0;
		}
	}

}
int main(){
	int n,q;
	int num;
	xd();
	cin>>n;
	int j;
	REP(i,0,n){
		scanf("%d",&num);
		j=2;
		while(j<=num){
			if(primes[j]){
				if(num%j==0){
					num/=j;
					primes[j]++;
				}
			}
			j++;
		}
	}
	REP(i,2,N+1){
		if(primes[i]>0)primes[i]--;
		primes[i]+=primes[i-1];
	}
	cin>>q;
	int x,y;
	REP(i,0,q){
		scanf("%d %d",&x,&y);
		if(x>N)x=N;
		if(y>N)y=N;
		printf("%lld\n",primes[y]-primes[x-1]);
	}

}


#include <bits/stdc++.h>
#define all(v) v.begin(),v.end()
#define REP(i, a, b) \
for(int i = int(a); i < int(b); i++)
#define pb(v,e) v.push_back(e)
#define N 1000000
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
int primes[N+5];
void xd(){
	for(int i=2;i<=N;i++)primes[i]=1;
    primes[0]=primes[1]=0;
    for(int i=2;i*i<=N;i++){
		if(primes[i]==1){
			for(int j=i*i;j<=N;j+=i)primes[j]=0;
		}
	}

}
int main(){
	int n,q;
	int num;
	xd();
	cin>>n;
	int j;
	REP(i,0,n){
		scanf("%d",&num);
		j=2;
		while(j<=num){
			if(primes[j]){
				if(num%j==0){
					primes[j]++;
				}
			}
			j++;
		}
	}

	REP(i,2,N){
		if(primes[i]>0)primes[i]--;
		primes[i]+=primes[i-1];
	}
	cin>>q;
	int x,y;
	REP(i,0,q){
		scanf("%d %d",&x,&y);
		printf("%d\n",primes[y]-primes[x-1]);
	}

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = (int)1e7 + 5;
int n, q, r, l, x;
int ar[N];
int vis[N];
int prime[N];
void seive() {
	vis[1] = vis[0] = 1;
	for (int i = 2; i * i < N; i++) {
		if (vis[i])continue;
		for (int j = i; j < N; j += i) {
			vis[j]++;
			prime[i] += ar[j];
		}
	}
}

int main() {
	cin.sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x; ar[x]++;
	}
	seive();
	for (int i = 1; i < N; i++) {
		prime[i] += prime[i - 1];
	}
	cin >> q;
	while (q--) {
		cin >> l >> r;
		r = min(r, (int)1e7);
		l = min(l, (int)1e7);
		printf("%d\n", prime[r] - prime[l - 1]);
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
using namespace std;
#define ll long long
const int N = (int)1e7 + 5;
const int NN = (int)1e6 + 5;
int n, q, r, l, st, en, cnt;
int ar[NN];

int f[N];
vector <int> p;
void prime() {
	f[1] = f[0] = 1;
	for (int i = 2; i * i < N; i++) {
		if (f[i])continue;
		p.push_back(i);
		for (int j = i + i; j < N; j += i)
			f[j]++;
	}
}

set<int> P_fac[N];
void factors(int n) {
	int t = n;
	for (int i = 0; i < p.size() && n>1; i++) {
		while (n % p[i] == 0) {
			n /= p[i];
			P_fac[t].insert(p[i]);
		}
	}
}

int main() {
	cin.sync_with_stdio(false);
	// primes
	prime();
	sort(p.begin(), p.end());

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> ar[i];
		factors(ar[i]);
	}

	cin >> q;
	while (q--) {
		cnt = 0;
		cin >> l >> r;
		st = lower_bound(p.begin(), p.end(), l) - p.begin();
		en = lower_bound(p.begin(), p.end(), r) - p.begin();
		if (r != p[en])en--;
		for (int i = st; i <= en; i++) {
			for (int j = 0; j < n; j++) {
				if (P_fac[ar[j]].find(p[i]) != P_fac[ar[j]].end())cnt++;
			}
		}
		printf("%d\n", cnt);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = (int)1e7 + 5;
int n, q, r, l, x;
int ar[N];
int vis[N];
int prime[N];
void seive() {
	for (int i = 2; i < N; i++)
		if (!vis[i]) {
			for (int j = i; j < N; j += i)
				prime[i] += ar[j], vis[j] = 1;
		}
}

int main() {
	cin.sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x; ar[x]++;
	}
	seive();
	for (int i = 1; i < N; i++) {
		prime[i] += prime[i - 1];
	}
	cin >> q;
	while (q--) {
		cin >> l >> r;
		if (r > N) r = N - 1;
		if (l > N) l = N - 1;
		printf("%d\n", prime[r] - prime[l - 1]);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = (int)1e7 + 5;
int n, q, r, l, x;
int ar[N];
int vis[N];
int prime[N];
void seive() {
	for (int i = 2; i * i < N; i++) {
		if (vis[i])continue;
		for (int j = i; j < N; j += i) {
			prime[i] += ar[j];
		}
		for (int j = i*2; j < N; j += i) {
			vis[j]++;
		}
	}
}

int main() {
	cin.sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x; ar[x]++;
	}
	seive();
	for (int i = 1; i < N; i++) {
		prime[i] += prime[i - 1];
	}
	cin >> q;
	while (q--) {
		cin >> l >> r;
		if (r > N) r = N - 1;
		if (l > N) l = N - 1;
		printf("%d\n", prime[r] - prime[l - 1]);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = (int)1e7 + 5;
const int NN = (int)1e6 + 5;
int n, q, r, l, st, en, cnt;
int ar[NN];

int f[N];
vector <int> p;
void prime() {
	f[1] = f[0] = 1;
	for (int i = 2; i * i < N; i++) {
		if (f[i])continue;
		p.push_back(i);
		for (int j = i + i; j < N; j += i)
			f[j]++;
	}
}

set<int> P_fac[N];
void factors(int n) {
	int t = n;
	for (int i = 0; i < p.size() && n>1; i++) {
		while (n % p[i] == 0) {
			n /= p[i];
			P_fac[t].insert(p[i]);
		}
	}
}

int main() {
	cin.sync_with_stdio(false);
	// primes
	prime();
	sort(p.begin(), p.end());

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> ar[i];
		factors(ar[i]);
	}

	cin >> q;
	while (q--) {
		cnt = 0;
		cin >> l >> r;
		if(r > N) r = N;
		st = lower_bound(p.begin(), p.end(), l) - p.begin();
		en = lower_bound(p.begin(), p.end(), r) - p.begin();
		if (r != p[en])en--;
		for (int i = st; i <= en; i++) {
			for (int j = 0; j < n; j++) {
				if (P_fac[ar[j]].find(p[i]) != P_fac[ar[j]].end())cnt++;
			}
		}
		printf("%d\n", cnt);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = (int)1e7 + 5;
int n, q, r, l, x;
int ar[N];
int vis[N];
int prime[N];
void seive() {
	vis[1] = vis[0] = 1;
	for (int i = 2; i * i < N; i++) {
		if (vis[i])continue;
		prime[i] += ar[i];
		for (int j = i*2; j < N; j += i) {
			vis[j]++;
			prime[i] += ar[j];
		}
	}
}

int main() {
	cin.sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x; ar[x]++;
	}
	seive();
	for (int i = 1; i < N; i++) {
		prime[i] += prime[i - 1];
	}
	cin >> q;
	while (q--) {
		cin >> l >> r;
		r = min(r, (int)1e7);
		l = min(l, (int)1e7);
		printf("%d\n", prime[r] - prime[l - 1]);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = (int)1e7 + 5;
int n, q, r, l, x;
int ar[N];
int vis[N];
int prime[N];
void seive() {
	vis[1] = vis[0] = 1;
	for (int i = 2; i * i < N; i++) {
		if (vis[i])continue;
		for (int j = i; j < N; j += i) {
			vis[j]++;
			prime[i] += ar[j];
		}
	}
}

int main() {
	cin.sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x; ar[x]++;
	}
	seive();
	for (int i = 1; i < N; i++) {
		prime[i] += prime[i - 1];
	}
	cin >> q;
	while (q--) {
		cin >> l >> r;
		printf("%d\n", prime[r] - prime[l - 1]);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = (int)1e7 + 5;
int n, q, r, l, x;
int ar[N];
int vis[N];
ll prime[N];
void seive() {
	for (int i = 2; i * i < N; i++) {
		if (vis[i])continue;
		for (int j = i; j < N; j += i) {
			vis[j]++;
			prime[i] += ar[j];
		}
	}
}

int main() {
	cin.sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x; ar[x]++;
	}
	seive();
	for (int i = 1; i < N; i++) {
		prime[i] += prime[i - 1];
	}
	cin >> q;
	while (q--) {
		cin >> l >> r;
		if (r > N) r = N - 1;
		if (l > N) l = N - 1;
		printf("%lld\n", prime[r] - prime[l - 1]);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = (int)1e7 + 5;
int n, q, r, l, x;
int ar[N];
int vis[N];
int prime[N];
void seive() {
	for (int i = 2; i * i < N; i++) {
		if (vis[i])continue;
		for (int j = i*2; j < N; j += i) {
			vis[j]++;
			prime[i] += ar[j];
		}
	}
}

int main() {
	cin.sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x; ar[x]++;
	}
	seive();
	for (int i = 1; i < N; i++) {
		prime[i] += prime[i - 1];
	}
	cin >> q;
	while (q--) {
		cin >> l >> r;
		if (r > N) r = N - 1;
		if (l > N) l = N - 1;
		printf("%d\n", prime[r] - prime[l - 1]);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = (int)1e7 + 5;
int n, q, r, l, x;
int ar[N];
int vis[N];
int prime[N];
void seive() {
	for (int i = 2; i < N; i++)
		if (!vis[i]) {
			for (int j = i; j < N; j += i)
				prime[i] += ar[j];
			for (int j = i + i; j < N; j += i) vis[j] = 1;
		}

}

int main() {
	cin.sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x; ar[x]++;
	}
	seive();
	for (int i = 1; i < N; i++) {
		prime[i] += prime[i - 1];
	}
	cin >> q;
	while (q--) {
		cin >> l >> r;
		if (r > N) r = N - 1;
		if (l > N) l = N - 1;
		printf("%d\n", prime[r] - prime[l - 1]);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = (int)1e7 + 5;
int n, q, r, l, x;
int ar[N];
int vis[N];
int prime[N];
void seive() {
	vis[1] = vis[0] = 1;
	for (int i = 2; i * i < N; i++) {
		if (vis[i])continue;
		for (int j = i; j < N; j += i) {
			vis[j]++;
			prime[i] += ar[j];
		}
	}
}

int main() {
	cin.sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x; ar[x]++;
	}
	seive();
	for (int i = 1; i < N; i++) {
		prime[i] += prime[i - 1];
	}
	cin >> q;
	while (q--) {
		cin >> l >> r;
		if (r > N) r = N - 1;
		if (l > N) l = N - 1;
		printf("%d\n", prime[r] - prime[l - 1]);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = (int)1e7 + 5;
const int NN = (int)1e6 + 5;
int n, q, r, l, st, en, cnt;
int ar[NN];

int f[N];
vector <int> p;
void prime() {
	f[1] = f[0] = 1;
	for (int i = 2; i * i < N; i++) {
		if (f[i])continue;
		p.push_back(i);
		for (int j = i + i; j < N; j += i)
			f[j]++;
	}
}

set<int> P_fac[N];
void factors(int n) {
	int t = n;
	for (int i = 0; i < p.size() && n>1; i++) {
		while (n % p[i] == 0) {
			n /= p[i];
			P_fac[t].insert(p[i]);
		}
	}
}

int main() {
	cin.sync_with_stdio(false);
	// primes
	prime();
	sort(p.begin(), p.end());

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> ar[i];
		factors(ar[i]);
	}

	cin >> q;
	while (q--) {
		cnt = 0;
		cin >> l >> r;
		if(r > N) r = N;
		if(l > N) l = N;
		st = lower_bound(p.begin(), p.end(), l) - p.begin();
		en = lower_bound(p.begin(), p.end(), r) - p.begin();
		if (r != p[en])en--;
		for (int i = st; i <= en; i++) {
			for (int j = 0; j < n; j++) {
				if (P_fac[ar[j]].find(p[i]) != P_fac[ar[j]].end())cnt++;
			}
		}
		printf("%d\n", cnt);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = (int)1e7 + 5;
int n, q, r, l, x;
int ar[N];
int vis[N];
int prime[N];
void seive() {
	for (int i = 2; i * i < N; i++) {
		if (vis[i])continue;
		for (int j = i+i; j < N; j += i) {
			vis[j]++;
			prime[i] += ar[j];
		}
	}
}

int main() {
	cin.sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x; ar[x]++;
	}
	seive();
	for (int i = 1; i < N; i++) {
		prime[i] += prime[i - 1];
	}
	cin >> q;
	while (q--) {
		cin >> l >> r;
		if (r > N) r = N - 1;
		if (l > N) l = N - 1;
		printf("%d\n", prime[r] - prime[l - 1]);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = (int)1e7 + 5;
int n, q, r, l, x;
int ar[N];
int vis[N];
ll prime[N];
void seive() {
	vis[1] = vis[0] = 1;
	for (int i = 2; i * i < N; i++) {
		if (vis[i])continue;
		for (int j = i; j < N; j += i) {
			vis[j]++;
			prime[i] += ar[j];
		}
	}
}

int main() {
	cin.sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x; ar[x]++;
	}
	seive();
	for (int i = 1; i < N; i++) {
		prime[i] += prime[i - 1];
	}
	cin >> q;
	while (q--) {
		cin >> l >> r;
		printf("%lld\n", prime[r] - prime[l - 1]);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = (int)1e7 + 5;
int n, q, r, l, x;
int ar[N];
int vis[N];
int prime[N];
void seive() {
	vis[1] = vis[0] = 1;
	for (int i = 2; i * i < N; i++) {
		if (vis[i])continue;
		for (int j = i; j < N; j += i) {
			vis[j]++;
			prime[i] += ar[j];
		}
	}
}

int main() {
	cin.sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x; ar[x]++;
	}
	seive();
	for (int i = 1; i < N; i++) {
		prime[i] += prime[i - 1];
	}
	cin >> q;
	while (q--) {
		cin >> l >> r;
		if (r > N) r = N;
		if (l > N) l = N;
		printf("%d\n", prime[r] - prime[l - 1]);
	}
	return 0;
}


#include <iostream>
#include <cstring>
using namespace std;

const int size = 1e7;
bool prime[size+10];
int num[size+10];

void init( ) {
    prime[1] = false;
    for ( int i = 2 ; i<=size ; ++i ) {
        if ( prime[i] ) {
            for ( int j = i+i ; j<=size ; j+=i ) {
                prime[j] = false;
            }
        }
    }
}

void check( int x ) {
    for ( int i = 1 ; i<=x/i ; ++i ) {
        if ( x%i == 0 ) {
            ++ num[i];
            if ( i*i!=x ) {
                ++ num[x/i];
            }
        }
    }
}

int main( ) {
	cin.sync_with_stdio(false);
    long long res;
    int n , m , L , R , x;
    memset( prime , true , sizeof(prime) );
    init( );
    while ( cin >> n ) {
        memset( num , 0 ,sizeof(num) );
        for ( int i = 0 ; i<n ; ++i ) {
            cin >> x;
            check( x );
        }
        cin >> m;
        for ( int i = 0 ; i<m ; ++i ) {
            res = 0;
            cin >> L >> R;
            for ( int i = L ; i<=R&&i<=size ; ++i ) {
                if ( prime[i] ) {
                    res += 1LL * num[i];
                }
            }
            cout << res << endl;
        }
    }
    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;

typedef __int64 LL;
const int size = 1e7;
int temp;
map<int,int>mp;
bool prime[size+10];
LL num[size+10];
LL sum[size+10];
LL tree[size+10];

void init( ) {
    prime[1] = false;
    for ( int i = 2 ; i<=size ; ++i ) {
        if ( prime[i] ) {
            for ( int j = i+i ; j<=size ; j+=i ) {
                prime[j] = false;
            }
        }
    }
}

void check( int x , int y ) {
    for ( int i = 1 ; i<=x/i ; ++i ) {
        if ( x%i == 0 ) {
            if ( prime[i] ) {
                num[i] += y;
            }
            if ( i*i!=x ) {
                if ( prime[x/i] ) {
                    num[x/i] += y;
                }
            }
        }
    }
}

int lowBit( int x ) {
	return x & -x;
}
void update( int x , int y ) {
	while ( x<=temp ) {
		tree[x] += 1LL * y;
		x += lowBit(x);
	}
}

LL query( int x ) {
	LL res = 0;
	while ( x ) {
		res += tree[x];
		x -= lowBit( x );
	}
	return res;
}

int main( ) {
    int n , m , L , R , x;
    memset( prime , true , sizeof(prime) );
    init( );
    while ( ~scanf("%d",&n) ) {
        mp.clear();
        memset( tree , 0 , sizeof(tree) );
        memset( num , 0 ,sizeof(num) );
        memset( sum , 0 , sizeof(sum) );
        temp = 0;
        for ( int i = 0 ; i<n ; ++i ) {
            scanf("%d",&x);
            temp = max( temp , x );
            ++ mp[x];
        }
        for ( auto x : mp ) {
            check( x.first , x.second );
        }
		for ( int i = 2 ; i<=temp ; ++i ) {
			if ( prime[i] && num[i] ) {
				update( i , num[i] );
			}
		}
        scanf("%d",&m);
        for ( int i = 0 ; i<m ; ++i ) {
            scanf("%d %d",&L,&R);
			if ( L>temp ) {
				printf("0\n");
			}
			else if ( L==temp ) {
				printf("%I64d\n",num[temp]);
			}
			else {
				R = min( R , temp );
				printf("%I64d\n",query(R)-query(L-1));
			}
        }
    }
    return 0;
}


#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;

typedef long long LL;
const int size = 1e7;
map<int,int>mp;
bool prime[size+10];
LL num[size+10];
LL sum[size+10];

void init( ) {
    prime[1] = false;
    for ( int i = 2 ; i<=size ; ++i ) {
        if ( prime[i] ) {
            for ( int j = i+i ; j<=size ; j+=i ) {
                prime[j] = false;
            }
        }
    }
}

void check( int x , int y ) {
    for ( int i = 1 ; i<=x/i ; ++i ) {
        if ( x%i == 0 ) {
            if ( prime[i] ) {
                num[i] += y;
            }
            if ( i*i!=x ) {
                if ( prime[x/i] ) {
                    num[x/i] += y;
                }
            }
        }
    }
}

int main( ) {
    cin.sync_with_stdio(false);
    int n , m , L , R , x , temp;
    memset( prime , true , sizeof(prime) );
    init( );
    while ( cin >> n ) {
        mp.clear();
        memset( num , 0 ,sizeof(num) );
        memset( sum , 0 , sizeof(sum) );
        temp = 0;
        for ( int i = 0 ; i<n ; ++i ) {
            cin >> x;
            temp = max( temp , x );
            ++ mp[x];
        }
        for ( auto x : mp ) {
            check( x.first , x.second );
        }
        for ( int i = 2 ; i<=temp ; ++i ) {
            sum[i] = sum[i-1] + num[i];
        }
        cin >> m;
        for ( int i = 0 ; i<m ; ++i ) {
            cin >> L >> R;
            L = min( L , temp );
            R = min( R , temp );
            cout << sum[R] - sum[L-1] << endl;
        }
    }
    return 0;
}


#include <iostream>
#include <cstring>
using namespace std;

const int size = 1e7;
bool prime[size+10];
int num[size+10];

void init( ) {
    prime[1] = false;
    for ( int i = 2 ; i<=size ; ++i ) {
        if ( prime[i] ) {
            for ( int j = i+i ; j<=size ; j+=i ) {
                prime[j] = false;
            }
        }
    }
}

void check( int x ) {
    for ( int i = 1 ; i<=x/i ; ++i ) {
        if ( x%i == 0 ) {
            ++ num[i];
            if ( i*i!=x ) {
                ++ num[x/i];
            }
        }
    }
}

int main( ) {
	cin.sync_with_stdio(false);
    long long res;
    int n , m , L , R , x;
    memset( prime , true , sizeof(prime) );
    init( );
    while ( cin >> n ) {
        memset( num , 0 ,sizeof(num) );
        for ( int i = 0 ; i<n ; ++i ) {
            cin >> x;
            check( x );
        }
        cin >> m;
        for ( int i = 0 ; i<m ; ++i ) {
            res = 0;
            cin >> L >> R;
            for ( int i = L ; i<=R ; ++i ) {
                if ( prime[i] ) {
                    res += 1LL * num[i];
                }
            }
            cout << res << endl;
        }
    }
    return 0;
}


#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;

typedef long long LL;
const int size = 1e7;
map<int,int>mp;
bool prime[size+10];
LL num[size+10];
LL sum[size+10];

void init( ) {
    prime[1] = false;
    for ( int i = 2 ; i<=size ; ++i ) {
        if ( prime[i] ) {
            for ( int j = i+i ; j<=size ; j+=i ) {
                prime[j] = false;
            }
        }
    }
}

void check( int x , int y ) {
    for ( int i = 1 ; i<=x/i ; ++i ) {
        if ( x%i == 0 ) {
            if ( prime[i] ) {
                num[i] += y;
            }
            if ( i*i!=x ) {
                if ( prime[x/i] ) {
                    num[x/i] += y;
                }
            }
        }
    }
}

int main( ) {
    cin.sync_with_stdio(false);
    int n , m , L , R , x , temp;
    memset( prime , true , sizeof(prime) );
    init( );
    while ( cin >> n ) {
        mp.clear();
        memset( num , 0 ,sizeof(num) );
        memset( sum , 0 , sizeof(sum) );
        temp = 0;
        for ( int i = 0 ; i<n ; ++i ) {
            cin >> x;
            temp = max( temp , x );
            ++ mp[x];
        }
        for ( auto x : mp ) {
            check( x.first , x.second );
        }
        for ( int i = 2 ; i<=temp ; ++i ) {
            sum[i] = sum[i-1] + num[i];
        }
        cin >> m;
        for ( int i = 0 ; i<m ; ++i ) {
            cin >> L >> R;
			if ( L>temp ) {
				cout << 0 << endl;
			}
			else if ( L==temp ) {
				cout << num[temp] << endl;
			}
			else {
				R = min( R , temp );
				cout << sum[R] - sum[L-1] << endl;
			}
        }
    }
    return 0;
}


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

typedef long long LL;
const int size = 1e7;
bool prime[size+10];
LL num[size+10];
LL sum[size+10];

void init( ) {
    prime[1] = false;
    for ( int i = 2 ; i<=size ; ++i ) {
        if ( prime[i] ) {
            for ( int j = i+i ; j<=size ; j+=i ) {
                prime[j] = false;
            }
        }
    }
}

void check( int x ) {
    for ( int i = 1 ; i<=x/i ; ++i ) {
        if ( x%i == 0 ) {
            if ( prime[i] ) {
            	++ num[i];
			}
            if ( i*i!=x ) {
                if ( prime[x/i] ) {
                	++ num[x/i];
				}
            }
        }
    }
}

int main( ) {
	cin.sync_with_stdio(false);
    long long res;
    int n , m , L , R , x;
    memset( prime , true , sizeof(prime) );
    init( );
    while ( cin >> n ) {
        memset( num , 0 ,sizeof(num) );
        memset( sum , 0 , sizeof(sum) );
        for ( int i = 0 ; i<n ; ++i ) {
            cin >> x;
            check( x );
        }
        for ( int i = 2 ; i<=size ; ++i ) {
        	sum[i] = sum[i-1] + num[i];
		}
        cin >> m;
        for ( int i = 0 ; i<m ; ++i ) {
            cin >> L >> R;
            L = min( L , size );
            R = min( R , size );
            cout << sum[R] - sum[L-1] << endl;
        }
    }
    return 0;
}


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

typedef long long LL;
const int size = 1e7;
int temp;
bool prime[size+10];
LL num[size+10];
LL sum[size+10];

void init( ) {
    prime[1] = false;
    for ( int i = 2 ; i<=size ; ++i ) {
        if ( prime[i] ) {
        	sum[i] += num[i];
            for ( int j = i+i ; j<=size ; j+=i ) {
                prime[j] = false;
				sum[i] += num[j];
            }
        }
        sum[i] += sum[i-1];
    }
}

int main( ) {
    cin.sync_with_stdio(false);
    int n , m , L , R , x;
    while ( cin >> n ) {
   	 	memset( prime , true , sizeof(prime) );
        memset( num , 0 ,sizeof(num) );
        memset( sum , 0 , sizeof(sum) );
        temp = 0;
        for ( int i = 0 ; i<n ; ++i ) {
            cin >> x;
            temp = max( temp , x );
            ++ num[x];
        }
        init( );
        cin >> m;
        for ( int i = 0 ; i<m ; ++i ) {
            cin >> L >> R;
			if ( L>temp ) {
				cout << 0 << endl;
			}
			else if ( L==temp ) {
				cout << ( prime[temp] ? num[temp] : 0 ) << endl;
			}
			else {
				R = min( R , temp );
				cout << sum[R] - sum[L-1] << endl;
			}
        }
    }
    return 0;
}


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

typedef long long LL;
const int size = 1e7;
int temp;
bool prime[size+10];
LL num[size+10];
LL sum[size+10];

void init( ) {
    prime[1] = false;
    for ( int i = 2 ; i<=size ; ++i ) {
        if ( prime[i] ) {
        	sum[i] += num[i];
            for ( int j = i+i ; j<=size ; j+=i ) {
                prime[j] = false;
				sum[i] += num[j];
            }
        }
        sum[i] += sum[i-1];
    }
}

int main( ) {
    cin.sync_with_stdio(false);
    int n , m , L , R , x;
    while ( cin >> n ) {
   	 	memset( prime , true , sizeof(prime) );
        memset( num , 0 ,sizeof(num) );
        memset( sum , 0 , sizeof(sum) );
        temp = 0;
        for ( int i = 0 ; i<n ; ++i ) {
            cin >> x;
            temp = max( temp , x );
            ++ num[x];
        }
        init( );
        cin >> m;
        for ( int i = 0 ; i<m ; ++i ) {
            cin >> L >> R;
			if ( L>temp ) {
				cout << 0 << endl;
			}
			else if ( L==temp ) {
				cout << num[temp] << endl;
			}
			else {
				R = min( R , temp );
				cout << sum[R] - sum[L-1] << endl;
			}
        }
    }
    return 0;
}


#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;

typedef __int64 LL;
const int size = 1e7;
int temp;
map<int,int>mp;
bool prime[size+10];
LL num[size+10];
LL sum[size+10];
LL tree[size+10];

void init( ) {
    prime[1] = false;
    for ( int i = 2 ; i<=size ; ++i ) {
        if ( prime[i] ) {
            for ( int j = i+i ; j<=size ; j+=i ) {
                prime[j] = false;
            }
        }
    }
}

void check( int x , int y ) {
    for ( int i = 1 ; i<=x/i ; ++i ) {
        if ( x%i == 0 ) {
            if ( prime[i] ) {
                num[i] += y;
            }
            if ( i*i!=x ) {
                if ( prime[x/i] ) {
                    num[x/i] += y;
                }
            }
        }
    }
}

int lowBit( int x ) {
	return x & -x;
}
void update( int x , int y ) {
	while ( x<=temp ) {
		tree[x] += 1LL * y;
		x += lowBit(x);
	}
}

LL query( int x ) {
	LL res = 0;
	while ( x ) {
		res += tree[x];
		x -= lowBit( x );
	}
	return res;
}

int main( ) {
    int n , m , L , R , x;
    memset( prime , true , sizeof(prime) );
    init( );
    while ( ~scanf("%d",&n) ) {
        mp.clear();
        memset( tree , 0 , sizeof(tree) );
        memset( num , 0 ,sizeof(num) );
        memset( sum , 0 , sizeof(sum) );
        temp = 0;
        for ( int i = 0 ; i<n ; ++i ) {
            scanf("%d",&x);
            temp = max( temp , x );
            ++ mp[x];
        }
        for ( auto x : mp ) {
            check( x.first , x.second );
        }
		for ( int i = 2 ; i<=temp ; ++i ) {
			if ( prime[i] && num[i] ) {
				update( i , num[i] );
			}
		}
        scanf("%d",&m);
        for ( int i = 0 ; i<m ; ++i ) {
            scanf("%d %d",&L,&R);
			if ( L>temp ) {
				printf("0\n");
			}
			else if ( L==temp ) {
				printf("%I64d\n",num[temp]);
			}
			else {
				R = min( R , temp );
				printf("%I64d\n",query(R)-query(L-1));
			}
        }
    }
    return 0;
}


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

typedef long long LL;
const int size = 1e7;
bool prime[size+10];
LL num[size+10];
LL sum[size+10];

void init( ) {
    prime[1] = false;
    for ( int i = 2 ; i<=size ; ++i ) {
        if ( prime[i] ) {
            for ( int j = i+i ; j<=size ; j+=i ) {
                prime[j] = false;
            }
        }
    }
}

void check( int x ) {
    for ( int i = 1 ; i<=x/i ; ++i ) {
        if ( x%i == 0 ) {
            if ( prime[i] ) {
            	++ num[i];
			}
            if ( i*i!=x ) {
                if ( prime[x/i] ) {
                	++ num[x/i];
				}
            }
        }
    }
}

int main( ) {
	cin.sync_with_stdio(false);
    int n , m , L , R , x , temp;
    memset( prime , true , sizeof(prime) );
    init( );
    while ( cin >> n ) {
        memset( num , 0 ,sizeof(num) );
        memset( sum , 0 , sizeof(sum) );
        temp = 0;
        for ( int i = 0 ; i<n ; ++i ) {
            cin >> x;
            check( x );
            temp = max( temp , x );
        }
        for ( int i = 2 ; i<=temp ; ++i ) {
        	sum[i] = sum[i-1] + num[i];
		}
        cin >> m;
        for ( int i = 0 ; i<m ; ++i ) {
            cin >> L >> R;
            L = min( L , temp );
            R = min( R , temp );
            cout << sum[R] - sum[L-1] << endl;
        }
    }
    return 0;
}


#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;

typedef long long LL;
const int size = 1e7;
int temp;
map<int,int>mp;
bool prime[size+10];
LL num[size+10];
LL sum[size+10];
LL tree[size+10];

void init( ) {
    prime[1] = false;
    for ( int i = 2 ; i<=size ; ++i ) {
        if ( prime[i] ) {
            for ( int j = i+i ; j<=size ; j+=i ) {
                prime[j] = false;
            }
        }
    }
}

void check( int x , int y ) {
    for ( int i = 1 ; i<=x/i ; ++i ) {
        if ( x%i == 0 ) {
            if ( prime[i] ) {
                num[i] += y;
            }
            if ( i*i!=x ) {
                if ( prime[x/i] ) {
                    num[x/i] += y;
                }
            }
        }
    }
}

int lowBit( int x ) {
	return x & -x;
}
void update( int x , int y ) {
	while ( x<=temp ) {
		tree[x] += 1LL * y;
		x += lowBit(x);
	}
}

LL query( int x ) {
	LL res = 0;
	while ( x ) {
		res += tree[x];
		x -= lowBit( x );
	}
	return res;
}

int main( ) {
    cin.sync_with_stdio(false);
    int n , m , L , R , x;
    memset( prime , true , sizeof(prime) );
    init( );
    while ( cin >> n ) {
        mp.clear();
        memset( tree , 0 , sizeof(tree) );
        memset( num , 0 ,sizeof(num) );
        memset( sum , 0 , sizeof(sum) );
        temp = 0;
        for ( int i = 0 ; i<n ; ++i ) {
            cin >> x;
            temp = max( temp , x );
            ++ mp[x];
        }
        for ( auto x : mp ) {
            check( x.first , x.second );
        }
		for ( int i = 2 ; i<=temp ; ++i ) {
			if ( prime[i] && num[i] ) {
				update( i , num[i] );
			}
		}
        cin >> m;
        for ( int i = 0 ; i<m ; ++i ) {
            cin >> L >> R;
			if ( L>temp ) {
				cout << 0 << endl;
			}
			else if ( L==temp ) {
				cout << num[temp] << endl;
			}
			else {
				R = min( R , temp );
				cout << query(R) - query(L-1) << endl;
			}
        }
    }
    return 0;
}


#include <iostream>
#include <cstring>
using namespace std;

typedef long long LL;
const int size = 1e7;
bool prime[size+10];
LL num[size+10];
LL sum[size+10];

void init( ) {
    prime[1] = false;
    for ( int i = 2 ; i<=size ; ++i ) {
        if ( prime[i] ) {
            for ( int j = i+i ; j<=size ; j+=i ) {
                prime[j] = false;
            }
        }
    }
}

void check( int x ) {
    for ( int i = 1 ; i<=x/i ; ++i ) {
        if ( x%i == 0 ) {
            if ( prime[i] ) {
            	++ num[i];
			}
            if ( i*i!=x ) {
                if ( prime[x/i] ) {
                	++ num[x/i];
				}
            }
        }
    }
}

int main( ) {
	cin.sync_with_stdio(false);
    long long res;
    int n , m , L , R , x;
    memset( prime , true , sizeof(prime) );
    init( );
    while ( cin >> n ) {
        memset( num , 0 ,sizeof(num) );
        memset( sum , 0 , sizeof(sum) );
        for ( int i = 0 ; i<n ; ++i ) {
            cin >> x;
            check( x );
        }
        for ( int i = 2 ; i<=size ; ++i ) {
        	sum[i] = sum[i-1] + num[i];
		}
        cin >> m;
        for ( int i = 0 ; i<m ; ++i ) {
            cin >> L >> R;
            cout << sum[R] - sum[L-1] << endl;
        }
    }
    return 0;
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.HashSet;
import java.util.Queue;

public class F {

	public F(IO io) {
		int n = io.getInt();
		HashSet<String> names = new HashSet<>();
		for (int i = 0; i < n; i++) {
			String name = io.getWord();
			for (int j = name.length()-1; j >= 0; j--) {
				if (name.charAt(j) == 'u') {
					name = name.substring(0, j) + "oo" + name.substring(j+1, name.length());
				}
				else if (name.charAt(j) == 'h') {
					int k = j-1;
					while (k >= 0 && name.charAt(k) == 'k') {
						k--;
					}
					if (k < j-1) {
						name = name.substring(0, k+1) + name.substring(j, name.length());
					}
				}
				if (j >= name.length())
					j = name.length()-1;
			}
			names.add(name);
		}
		System.out.println(names.size());
	}

	public static void main(String[] args) {
		new F(new IO());
	}

	private static class IO {

		private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		private Queue<String> queue = new ArrayDeque<>();

		public String getWord() {
			refill();
			return queue.poll();
		}

		public int getInt() {
			return Integer.parseInt(getWord());
		}

		public double getDouble() {
			return Double.parseDouble(getWord());
		}

		public void refill() {
			try {
				if (queue.isEmpty()) {
					String[] line = reader.readLine().trim().split("\\s+");
					for (String string : line) {
						queue.offer(string);
					}
				}
			} catch (IOException e) {
			}
		}
	}

}


import java.util.Scanner;

/**
 * Created by HP on 09/11/2017.
 */
public class Main {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
      //  int n=in.nextInt();
        String s=in.nextLine();
        int n=Integer.valueOf(s);
        int co=n;
        String[] str=new String[n];
        for (int i = 0; i <n ; i++) {
            str[i]=in.nextLine();
        }
        int indexi=0,indexj=0;
   //     boolean z=true;
        for (int i = 0; i <n ; i++) {
            if(str[i]==null){
                continue;
            }
            for (int j = i+1; j <n ; j++) {
                if(str[j]==null){
                    continue;
                }

      //          if(str[i].length()>str[j].length()){
              //      int indexk=0;
                    indexi=0;
                    indexj=0;
                 //   for (int k = 0; k <str.length ; k++) {
                boolean demarkhoz=true;
                    while (true){
                        boolean markhoz=true;
                        if(indexi>=str[i].length()&&indexj>=str[j].length()){
                            break;
                        }
                        else if(indexi>=str[i].length()&&!(indexj>=str[j].length())){
                            demarkhoz=false;
                            break;
                        }
                        else if(!(indexi>=str[i].length())&&indexj>=str[j].length()){
                            demarkhoz=false;
                            break;
                        }
                        if(str[i].charAt(indexi)==str[j].charAt(indexj)){
                            indexi++;
                            indexj++;
                            continue;
                        }
//                        else if(str[i].charAt(indexi)=='u'&&str[j].charAt(indexj)=='o'&&str[j].charAt(indexj+1)=='o'){
//                            indexj+=2;
//                            indexi++;
//                            continue;
//                        }
                        else if(str[i].charAt(indexi)=='u'&&str[j].charAt(indexj)=='o'){
                            int coi=2;
                            int coj=1;

                            indexj++;
                            indexi++;

                            while (true){
                                if(indexj>=str[j].length()){
                                 //   markhoz=false;
                                    break;
                                }
                                if(str[j].charAt(indexj)=='u'){
                                    coj+=2;
                                    indexj++;
                                }else if(str[j].charAt(indexj)=='o'){
                                    coj++;
                                    indexj++;
                                }else{
                                    break;
                                }
                            }
                            while (true){
                                if(indexi>=str[i].length()){
                                 //   markhoz=false;
                                    break;
                                }
                                if(str[i].charAt(indexi)=='u'){
                                    coi+=2;
                                    indexi++;
                                }else if(str[i].charAt(indexi)=='o'){
                                    coi++;
                                    indexi++;
                                }else{
                                    break;
                                }
                            }
                            if(coi==coj){
                                continue;
                            }else{
                                demarkhoz=false;
                                break;
                            }

                        }

                        else if(str[j].charAt(indexj)=='u'&&str[i].charAt(indexi)=='o'){
                            int coj=2;
                            int coi=1;

                            indexj++;
                            indexi++;

                            while (true){
                                if(indexj>=str[j].length()){
                                    //   markhoz=false;
                                    break;
                                }
                                if(str[j].charAt(indexj)=='u'){
                                    coj+=2;
                                    indexj++;
                                }else if(str[j].charAt(indexj)=='o'){
                                    coj++;
                                    indexj++;
                                }else{
                                    break;
                                }
                            }
                            while (true){
                                if(indexi>=str[i].length()){
                                    //   markhoz=false;
                                    break;
                                }
                                if(str[i].charAt(indexi)=='u'){
                                    coi+=2;
                                    indexi++;
                                }else if(str[i].charAt(indexi)=='o'){
                                    coi++;
                                    indexi++;
                                }else{
                                    break;
                                }
                            }
                            if(coi==coj){
                                continue;
                            }else{
                                demarkhoz=false;
                                break;
                            }

                        }
//                        else if(str[i].charAt(indexi)=='o'&&str[i].charAt(indexi+1)=='o'&&str[j].charAt(indexj)=='u'){
//                            indexi+=2;
//                            indexj++;
//                            continue;
//                        }
                        else if(str[i].charAt(indexi)=='h'&&str[j].charAt(indexj)=='k'){
                            indexi++;
                            indexj++;
                            while (true){
                                if(indexj>=str[j].length()){
                                    markhoz=false;
                                    break;
                                }
                                if(str[j].charAt(indexj)=='k'){
                                    indexj++;
                                    continue;
                                }else if(str[j].charAt(indexj)=='h'){
                                    indexj++;
                                    break;
                                }else{
                                    markhoz=false;
                                    break;
                                }
                            }
                            if(markhoz){
                                continue;
                            }else{
                                demarkhoz=false;
                                break;
                            }
                        }
                        else if(str[j].charAt(indexj)=='h'&&str[i].charAt(indexi)=='k'){
                            indexi++;
                            indexj++;
                            while (true){
                                if(indexi>=str[i].length()){
                                    markhoz=false;
                                    break;
                                }
                                if(str[i].charAt(indexi)=='k'){
                                    indexi++;
                                    continue;
                                }else if(str[i].charAt(indexi)=='h'){
                                    indexi++;
                                    break;
                                }else{
                                    markhoz=false;
                                    break;
                                }
                            }
                            if(markhoz){
                                continue;
                            }else{
                                demarkhoz=false;
                                break;
                            }
                        }
                        else{
                            demarkhoz=false;
                            break;
                        }
                    }
                    if(demarkhoz){
                  //      System.out.println(str[i]+str[j]);
                        str[j]=null;
                        co--;
                    }
              //  }
            }
        }
        System.out.println(co);
    }
}


function kek(s)
{
    s=s.replace("u","oo")
    for (var i=0;i<=20;i++)
    {
        s=s.replace("kh","h");
    }
    return s;
}

var n=+readline()
var x=[]
while(n--)
{
    x.push(kek(readline()))
}
x.sort()
var res=1
for (var i=1;i<x.length;i++)
{
    if (x[i]!=x[i-1]){res++;}
}
print(res)


function kek(s)
{
    for (var i=0;i<=20;i++)
    {
        s=s.replace("u","oo")
        s=s.replace("kh","h");
    }
    return s;
}

var n=+readline()
var x=[]
while(n--)
{
    x.push(kek(readline()))
}
x.sort()
var res=1
for (var i=1;i<x.length;i++)
{
    if (x[i]!=x[i-1]){res++;}
}
print(res)//


function kek(s)
{
    for (var i=0;i<=20;i++)
    {
        s=s.replace("u","oo")
        s=s.replace("kh","h");
    }
    return s;
}

var n=+readline()
var x=[]
while(n--)
{
    x.push(kek(readline()))
}
x.sort()
var res=1
for (var i=1;i<x.length;i++)
{
    if (x[i]!=x[i-1]){res++;}
}
print(res)


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

#define mp make_pair
#define pb push_back

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pp;
typedef pair<pp,pp> ppi;
typedef vector<string> vv;

const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}

map<string,int> mpp,mpp1;

string compressKH(string s1)
{
	string s2="";
	s2=s1;
	int len=1;
	for(int j=1;j<s1.length();j++)
	{
		if(s2[len-1]=='k' && s1[j]=='h')
		{
			while(len>0 && s2[len-1]=='k' && s1[j]=='h')
				len--;
			s2[len]='h',len++;
		}
		else
			s2[len]=s1[j],len++;
	}
	string s="";
	for(int i=0;i<len;i++)
		s+=s2[i];
	return s;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin>>n;

	vv v(n+1);

	for(int i=0;i<n;i++)
	{
		string s,s2="",s3="";
		cin>>s;

		s3=s[0];
		if(s[0]=='u')
			s3="oo";
		for(int j=1;j<s.length();j++)
		{
			if(s[j]=='u')
				s3+='o',s3+='o';
			else
				s3+=s[j];
		}

		if(mpp1.find(s3)==mpp1.end())
			mpp1.insert(mp(s3,1));
		else
			mpp1[s3]++;

		s2=compressKH(s3);

		if(mpp.find(s2)==mpp.end())
			mpp.insert(mp(s2,1));
		else
			mpp[s2]++;
	}
	int cnt=0;
	for(map<string,int>::iterator it=mpp.begin();it!=mpp.end();it++)
		cnt++;
	cout<<cnt<<"\n";
	return 0;
}


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

#define mp make_pair
#define pb push_back

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pp;
typedef pair<pp,pp> ppi;
typedef vector<string> vv;

const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}

map<string,int> mpp;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin>>n;

	vv v(n+1);

	for(int i=0;i<n;i++)
	{
		string s,s1="",s2="";
		cin>>s;

		int len=1;
		for(int j=0;j<s.length();j++)
		{
			if(s[j]=='u')
				s2+='o',s2+='o';
			else if(s[j]=='h')
				s2+='k',s2+='h';
			else
				s2+=s[j];
		}
		s1+=s2[0];
		for(int j=1;j<s2.length();j++)
		{
			if(s1[len-1]!=s2[j] || s2[j]=='o')
				len++,s1+=s2[j];
		}
		//cout<<i<<" "<<s2<<" "<<s1<<"\n";
		if(mpp.find(s1)==mpp.end())
			mpp.insert(mp(s1,1));
		else
			mpp[s1]++;
	}
	int cnt=0;
	for(map<string,int>::iterator it=mpp.begin();it!=mpp.end();it++)
		cnt++;
	cout<<cnt;
	return 0;
}


#include <cstring>
#include <algorithm>
#include <cstdio>
#include <set>
#include <string>

using namespace std;
const int MAXL = 25;
int _w;

int n;
char str[MAXL];
set<string> s;

string solve( char *s, int n ) {
	string str;
	int cntk = 0;
	for( int i = 0; i < n; ++i ) {
		if( s[i] == 'u' ) {
			for( int t = 0; t < cntk; ++t )
				str += 'k';
			cntk = 0;
			str += "oo";
		} else if( s[i] == 'k' ) {
			++cntk;
		} else if( s[i] == 'h' ) {
			str += 'h', cntk = 0;
		} else {
			for( int t = 0; t < cntk; ++t )
				str += 'k';
			cntk = 0;
			str += s[i];
		}
	}
	for( int t = 0; t < cntk; ++t )
		str += 'k';
	return str;
}

int main() {
	_w = scanf( "%d", &n );
	for( int i = 0; i < n; ++i ) {
		_w = scanf( "%s", str );
		int len = (int)strlen(str);
		s.insert( solve(str, len) );
	}
	printf( "%d\n", (int)s.size() );
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
set<string>satr;
string s, a[500];
int n, i, j, k, b[500];
int main()
{
	cin >> n;
	for(i=1; i<=n; i++)
	{
		cin >> s;
		j = 0;
		while(j < s.size())
		{
			if(s[j] == 'k' && s[j+1] == 'h')
			{
				s.erase(j, 1);
				j -= 2;
			}
			j++;
		}
		j = 0;
		while(j < s.size())
		{
			if(s[j] == 'u')
			{
				s.erase(j, 1);
				s.insert(j, "oo");
			}
			j++;
		}
		satr.insert(s);
	}
	cout << satr.size();
}


#include<bits/stdc++.h>
using namespace std;
map<string, int>mp;
string s, a[500];
int n, i, j, k, b[500];
int main()
{
	cin >> n;
	for(i=1; i<=n; i++)
	{
		cin >> s;
		j = 0;
		while(j < s.size())
		{
			if(s[j] == 'k' && s[j+1] == 'h')
			{
				s.erase(j, 1);
				j -= 2;
			}
			j++;
		}
		j = 0;
		while(j < s.size())
		{
			if(s[j] == 'u')
			{
				s.erase(j, 1);
				s.insert(j, "oo");
				j--;
			}
			j++;
		}
		a[i] = s;
	}
	for(i=1; i<=n; i++)
	{
		if(!mp[a[i]])
		{
			mp[a[i]]++;
			k++;
		}
	}
	cout << k;
}


#include<bits/stdc++.h>
using namespace std;
map<string, int>mp;
string s, a[500];
int n, i, j, k, b[500];
int main()
{
	cin >> n;
	for(i=1; i<=n; i++)
	{
		cin >> s;
		j = 0;
		while(j < s.size())
		{
			if(s[j] == 'k' && s[j+1] == 'h')
			{
				s.erase(j, 1);
				j -= 2;
			}
			j++;
		}
		j = 0;
		while(j < s.size())
		{
			if(s[j] == 'u')
			{
				s.erase(j, 1);
				s.insert(j, "oo");
			}
			j++;
		}
		a[i] = s;
	}
	for(i=1; i<=n; i++)
	{
		if(!mp[a[i]])
		{
			mp[a[i]]++;
			k++;
		}
	}
	cout << k;
}


#include<bits/stdc++.h>
using namespace std;
string s;
set<string>satr;
int i, k, n;
int main()
{
	cin >> n;
	for(i=1; i<=n; i++)
	{
		cin >> s;
		k = 0;
		while(k < s.size())
		{
			if(s[k] == 'u')
			{
				s[k] = 'o';
				s.insert(k, "o");
				if(k - 1 >= 0)
					k--;
			}
			else
				if(s[k] == 'k' && s[k+1] == 'h')
				{
					s.erase(k, 1);
					if(k - 1 >= 0)
						k--;
				}
				else
					k++;
		}
		satr.insert(s);
	}
	cout << satr.size();
}


#include<bits/stdc++.h>
using namespace std;
string s;
set<string>satr;
int i, k, n;
int main()
{
	cin >> n;
	for(i=1; i<=n; i++)
	{
		cin >> s;
		k = 0;
		while(k < s.size())
		{
			if(s[k] == 'u')
			{
				s[k] = 'o';
				s.insert(k, "o");
				if(k - 1 >= 0)
					k--;
			}
			k++;
		}
		k = 0;
		while(k < s.size())
		{
			if(s[k] == 'k' && s[k+1] == 'h')
			{
				s.erase(k, 1);
//				if(k - 2 >= 0)
					k-=2;
			}
			k++;
		}
		satr.insert(s);
	}
	cout << satr.size();
}


#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#include<vector>
#include<set>
#define il inline
#define re register
using namespace std;
typedef long long ll;
ll ans;
int n,m,T;
char a[1001],b[1001];
map<ll,bool> p;
il void init(){
	scanf("%s",a+1);
	n=strlen(a+1);
	m=0;
	for(int i=1;i<=n;i++){
		while(m>0&&b[m]=='k'&&a[i]=='h') m--;
		if(a[i]=='u'){
			b[++m]='o';
			b[++m]='o';
		}
		else{
			b[++m]=a[i];
		}
	}
	ans=0;
	for(int i=1;i<=m;i++)
		ans=ans*1000000007+b[i];
	p[ans]=1;
}
int main(){
	scanf("%d",&T);
	for(int i=1;i<=T;i++)
		init();
	printf("%d\n",p.size());
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#include<vector>
#include<set>
#define il inline
#define re register
using namespace std;
int a,b,c,d,x,y;
int main(){
	cin>>a>>b>>c>>d;
	x=abs(a-c);
	y=abs(b-d);
	if(x>y) swap(x,y);
	if(x==0){
		cout<<(y*2+6);
	}
	else{
		cout<<(2*(x+1+y+1))<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, ans = 0;
	unsigned int k;
	cin >> n;
	string a;
	string s[n];
	for (int i = 0; i < n; i++)
		cin >> s[i];
	for (int i = 0; i < n; i++) {
		for (unsigned int j = 0; j < s[i].size(); j++) {
			if (s[i][j] == 'u') {
				s[i][j] = 'o';
				s[i].insert(j,"o");
				j++;
			}
			if (s[i][j] == 'h'&& j != 0 && s[i][j-1] == 'k') {
				ans = 1;
				for (k = j - 2; k >= 0; k--) {
					if (s[i][k] == 'k')
						ans++;
					else
						break;
				}

				for (k = j - ans; k < s[i].size(); k++)
					s[i][k] = s[i][k + ans];
				s[i] = s[i].substr(0,s[i].size()-ans);
			    j = j-ans;
			}

		}

	}
	k = n;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (s[i] == s[j])
				k--;
			break;
		}
	}
	cout << k << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, ans = 0;
	unsigned int k;
	cin >> n;
	string a;
	string s[n];
	for (int i = 0; i < n; i++)
		cin >> s[i];
	for (int i = 0; i < n; i++) {
		for (unsigned int j = 0; j < s[i].size(); j++) {
			if (s[i][j] == 'u') {
				s[i][j] = 'o';
				s[i].insert(j,"o");
				j++;
			}
			if (s[i][j] == 'h'&& j != 0 && s[i][j-1] == 'k') {
				ans = 1;
				for (k = j - 2; k >= 0; k--) {
					if (s[i][k] == 'k')
						ans++;
					else
						break;
				}

				for (k = j - ans; k < s[i].size(); k++)
					s[i][k] = s[i][k + ans];
				s[i] = s[i].substr(0,s[i].size()-ans);
			    j = j-ans;
			}

		}

	}
	k = n;
	for (int i = 0; i < n; i++) {
		cout << s[i] << endl;
		for (int j = i + 1; j < n; j++) {
			if (s[i] == s[j])
				k--;
			break;
		}
	}
	cout << k << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, ans = 0;
	unsigned int k;
	cin >> n;
	string a;
	string s[n];
	for (int i = 0; i < n; i++)
		cin >> s[i];
	for (int i = 0; i < n; i++) {
		for (unsigned int j = 0; j < s[i].size(); j++) {
			if (s[i][j] == 'u') {
				s[i][j] = 'o';
				s[i].insert(j,"o");
				j++;
			}
			if (s[i][j] == 'h'&& j != 0 && s[i][j-1] == 'k') {
				ans = 1;
				for (k = j - 2; k >= 0; k--) {
					if (s[i][k] == 'k')
						ans++;
					else
						break;
				}

				for (k = j - ans; k < s[i].size(); k++)
					s[i][k] = s[i][k + ans];
				s[i] = s[i].substr(0,s[i].size()-ans);
			    j = j-ans;
			}

		}

	}
	k = n;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (s[i] == s[j]) { k--; break; }
		}
	}
	cout << k << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, ans = 0;
	unsigned int k;
	cin >> n;
	string a;
	string s[n];
	for (int i = 0; i < n; i++)
		cin >> s[i];
	for (int i = 0; i < n; i++) {
		for (unsigned int j = 0; j < s[i].size(); j++) {
			if (s[i][j] == 'o' && s[i][j+1] == 'o') {
				s[i][j] = 'u';
				for (k = j + 1; k < s[i].size() - 1; k++)
					s[i][k] = s[i][k+1];
				s[i] = s[i].substr(0,s[i].size()-1);
				j--;
			}
			if (s[i][j] == 'h'&& j != 0 && s[i][j-1] == 'k') {
				ans = 1;
				for (k = j - 2; k >= 0; k--) {
					if (s[i][k] == 'k')
						ans++;
					else
						break;
				}
				for (k = j - ans; k < s[i].size(); k++)
					s[i][k] = s[i][k + ans];
				s[i] = s[i].substr(0,s[i].size()-ans);
			    j = j-1;
			}
		}
	}
	k = n;
	for (int i = 0; i < n; i++)
		for (int j = i + 1; j < n; j++)
			if (s[i] == s[j])
				k--;
	cout << k << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, ans = 0;
	unsigned int k;
	cin >> n;
	string a;
	string s[n];
	for (int i = 0; i < n; i++)
		cin >> s[i];
	for (int i = 0; i < n; i++) {
		for (unsigned int j = 0; j < s[i].size(); j++) {
			if (s[i][j] == 'u') {
				s[i][j] = 'o';
				s[i].insert(j,"o");
				j++;
			}
			if (s[i][j] == 'h'&& j != 0 && s[i][j-1] == 'k') {
				ans = 1;
				for (k = j - 2; k >= 0; k--) {
					if (s[i][k] == 'k')
						ans++;
					else
						break;
				}

				for (k = j - ans; k < s[i].size(); k++)
					s[i][k] = s[i][k + ans];
				s[i] = s[i].substr(0,s[i].size()-ans);
			    j = j-ans;
			}

		}

	}
	k = n;
	for (int i = 0; i < n; i++) {
		cout << s[i] << endl;
		for (int j = i + 1; j < n; j++) {
			if (s[i] == s[j]) { k--; break; }
		}
	}
	cout << k << endl;
	return 0;
}


#include <bits/stdc++.h>
//#include <unordered_map>

#define f(i, num) for(int i=0; i<num; i++)
#define F(i, lower, upper, step) for(int i=lower; i<upper; i+=step)
#define F_(i, upper, lower, step) for(int i=upper; i>lower; i-=step)

#define read(num) scanf("%d", &num)
#define read2(numa, num2) scanf("%d%d", &numa, &num2)
#define read3(numa, num2, num3) scanf("%d%d%d", &numa, &num2, &num3)
#define reads(str) scanf("%s", str)
#define readc(ch) scanf("%c", &ch)

#define M 1000000007
#define pb push_back
#define mp make_pair

#define pii pair<int, int>
#define vi vector<int>
#define ll long long

using namespace std;

int main()
{
	int n, l, flag, p;
	string s, s2;
	map<string, int> siz;

	read(n);
	f(z, n)
	{
		cin>>s;

		flag=1;
		while(flag)
		{
			flag = 0;
			s2 = "";
			p = 0;
			l = s.length();

			f(i, l)
			{
				if(i==l-1)
					s2 += s[i];
				else if(s[i] == 'k' && s[i+1] == 'h')
				{
					flag = 1;
					s2 += 'h';
					i++;
				}
				else
					s2 += s[i];
			}

			s = s2;
		}
		//cout<<"--"<<s;

		flag=1;
		while(flag)
		{
			flag = 0;
			s2 = "";
			p = 0;
			l = s.length();

			f(i, l)
			{
				if(s[i] == 'u')
				{
					flag = 1;
					s2 += "oo";
				}
				else
					s2 += s[i];
			}

			s = s2;
		}
		//cout<<"--"<<s;
		//siz.insert(s);
		siz[s]++;
		//cout<<"--"<<s;
	}

	printf("%d\n", (int)siz.size());
}


#include <bits/stdc++.h>
//#include <unordered_map>

#define f(i, num) for(int i=0; i<num; i++)
#define F(i, lower, upper, step) for(int i=lower; i<upper; i+=step)
#define F_(i, upper, lower, step) for(int i=upper; i>lower; i-=step)

#define read(num) scanf("%d", &num)
#define read2(numa, num2) scanf("%d%d", &numa, &num2)
#define read3(numa, num2, num3) scanf("%d%d%d", &numa, &num2, &num3)
#define reads(str) scanf("%s", str)
#define readc(ch) scanf("%c", &ch)

#define M 1000000007
#define pb push_back
#define mp make_pair

#define pii pair<int, int>
#define vi vector<int>
#define ll long long

using namespace std;

int main()
{
	int n, l, flag, p;
	string s, s2;
	map<string, int> siz;

	read(n);
	f(z, n)
	{
		cin>>s;

		flag=1;
		while(flag)
		{
			flag = 0;
			s2 = "";
			p = 0;
			l = s.length();

			f(i, l-1)
			{
				if(s[i] == 'k' && s[i+1] == 'h')
				{
					flag = 1;
					s2 += 'h';
					i++;
				}
				else if(i==l-2)
				{
					s2 += s[i];
					s2 += s[i+1];
				}
				else
					s2 += s[i];
			}

			s = s2;
		}

		flag=1;
		while(flag)
		{
			flag = 0;
			s2 = "";
			p = 0;
			l = s.length();

			f(i, l)
			{
				if(s[i] == 'u')
				{
					flag = 1;
					s2 += "oo";
				}
				else
					s2 += s[i];
			}

			s = s2;
		}
		//cout<<"--"<<s;
		//siz.insert(s);
		siz[s]++;
	}

	printf("%d\n", (int)siz.size());
}


#include<stdio.h>
#include<algorithm>
#include<map>
#include<cstring>
using namespace std;
map<int,int>ma;
char c[405][25],b[405][55];
int i,j,k,l,s,n,m,r,ans;
inline int Hash(char c[],int x) {
    int l=x;
    int s=0;
    for (int i=0;i<l;i++) s=s*26+c[i]-97;
    return s;
}
int main() {
    scanf("%d",&n);
    for (i=1;i<=n;i++) scanf("%s",c[i]);
    for (i=1;i<=n;i++) {
        ans++;
        l=strlen(c[i]);
        int L=0;
        for (j=0;j<l;j++) {
            b[i][L++]=c[i][j];
            if (b[i][L-1]=='h') {
                int j=L-2;
                while (j>=0&&b[i][j]=='k') j--;
                for (k=j+1;k<L;k++) b[i][k]='0';
                L=j+1;
                b[i][L++]='h';
            }
            else if (b[i][L-1]=='u') b[i][L-1]='o',b[i][L++]='o';
        }
        if (ma[Hash(b[i],L)]==1) ans--;
        else ma[Hash(b[i],L)]=1;
    }
    printf("%d\n",ans);
}


#include<stdio.h>
#include<algorithm>
#include<map>
#include<cstring>
using namespace std;
///map<int,int>ma;
char c[405][25],b[405][55];
int i,j,k,l,s,n,m,r,ans,len[405];
inline int Hash(char c[],int x) {
    int l=x;
    int s=0;
    for (int i=0;i<l;i++) s=s*26+c[i]-97;
    return s;
}
inline bool check(int x,int y) {
    if (len[x]!=len[y]) return 0;
    for (int i=0;i<len[x];i++) if (b[x][i]!=b[y][i]) return 0;
    return 1;
}
int main() {
    scanf("%d",&n);
    for (i=1;i<=n;i++) scanf("%s",c[i]);
    for (i=1;i<=n;i++) {
        ans++;
        l=strlen(c[i]);
        int L=0;
        for (j=0;j<l;j++) {
            b[i][L++]=c[i][j];
            if (b[i][L-1]=='h') {
                int j=L-2;
                while (j>=0&&b[i][j]=='k') j--;
                for (k=j+1;k<L;k++) b[i][k]='0';
                L=j+1;
                b[i][L++]='h';
            }
            else if (b[i][L-1]=='u') b[i][L-1]='o',b[i][L++]='o';
        }
        len[i]=L;
   ///     if (ma[Hash(b[i],L)]==1) ans--;
      ///  else ma[Hash(b[i],L)]=1;
      for (j=1;j<i;j++) if (check(j,i)) {
        ans--; break;
        }
    }
    printf("%d\n",ans);
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	set<string> mp;
	int n, count=0;
	cin >> n;
	string str;
	for(int i=1; i<=n; i++)
	{

		cin >> str;

		for(int i=str.length();i>=0;i--){
			if(str[i]=='u')
			str.replace(i,1,"oo");
			else if(str[i]=='k'&&str[i+1]=='h')
			str.replace(i,2,"h");
		}
		 mp.insert(str);

		}
	cout <<mp.size()<<endl;
}


#include <cstdio>
#include <cstring>
static const int MAXN = 404;
static const int MAXL = 42;

static int n;
static char s[MAXL];
static char t[MAXN][MAXL];

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

    for (int i = 0; i < n; ++i) {
        scanf("%s", s);
        int len = strlen(s), ptr = 0;
        for (int j = 0; j < len; ++j) {
            if (s[j] == 'u') {
                t[i][ptr++] = 'o';
                t[i][ptr++] = 'o';
            } else if (j < len - 1 && s[j] == 'k' && s[j + 1] == 'h') {
                while (ptr > 0 && t[i][ptr - 1] == 'k') --ptr;
                t[i][ptr++] = 'h'; ++j;
            } else {
                t[i][ptr++] = s[j];
            }
        }
        t[i][ptr] = '\0';
    }

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        bool valid = true;
        for (int j = 0; j < i; ++j)
            if (strcmp(t[i], t[j]) == 0) { valid = false; break; }
        if (valid) ++ans;
    }
    printf("%d\n", ans);

    return 0;
}


#include <cstdio>
#include <cstring>
static const int MAXN = 404;
static const int MAXL = 22;

static int n;
static char s[MAXL];
static char t[MAXN][MAXL];

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

    for (int i = 0; i < n; ++i) {
        scanf("%s", s);
        int len = strlen(s), ptr = 0;
        for (int j = 0; j < len; ++j) {
            if (s[j] == 'u') {
                t[i][ptr++] = 'o';
                t[i][ptr++] = 'o';
            } else if (j < len - 1 && s[j] == 'k' && s[j + 1] == 'h') {
                while (ptr > 0 && t[i][ptr - 1] == 'k') --ptr;
                t[i][ptr++] = 'h'; ++j;
            } else {
                t[i][ptr++] = s[j];
            }
        }
        t[i][ptr] = '\0';
    }

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        bool valid = true;
        for (int j = 0; j < i; ++j)
            if (strcmp(t[i], t[j]) == 0) { valid = false; break; }
        if (valid) ++ans;
    }
    printf("%d\n", ans);

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
void transformii(vector <string> &vec, int n)
{

    // cout<<endl<<endl;
    for(int i=0;i<n;i++)
    {
        string s = vec[i];
        // s.replace('u','oo');
        string ss;
        for(int d=0;d<s.size();d++)
        {
            if(s[d]!='u')
            {
                ss.push_back(s[d]);

            }
            else
            {
                ss+= "oo";
            }
        }

        s=ss;
        // cout<<s<<endl;

        string val;

        for(int j=0;j<s.size();j++)
        {
            if(s[j] != 'k')
            {
                val.push_back(s[j]);
            }

            else
            {
                int countk = 0;
                while(j<s.size() && s[j] == 'k')
                {
                    j++;
                    countk++;
                }

                if(j == s.size() || (j<s.size() && s[j] != 'h'))
                {
                    for(int r=0;r<countk;r++)
                    {
                        val+="k";
                    }
                    j--;
                }

                else
                {
                    val += "h";
                    // cout<<"heya"<<endl;
                }
            }

            }

            vec[i] = val;
            // cout<<vec[i]<<endl;
    }

}

int main()
{
    int n;
    cin>>n;
    vector <string> vec (n);
    for(int i=0;i<n;i++)
    {
        cin>>vec[i];
    }

    transformii(vec,n);

    set <string> s;
    for(int i=0;i<vec.size();i++)
    {
        s.insert(vec[i]);
    }

    //     cout<<"..."<<endl;
    // for(int j=0;j<vec.size();j++)
    // {
    //     cout<<vec[j]<<endl;
    // }

    cout<<s.size()<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
void transformii(vector <string> &vec, int n)
{

    // cout<<endl<<endl;
    for(int i=0;i<n;i++)
    {
        string s = vec[i];
        // s.replace('u','oo');
        string ss;
        for(int d=0;d<s.size();d++)
        {
            if(s[d]!='u')
            {
                ss+=s[d];

            }
            else
            {
                ss+= "oo";
            }
        }

        s=ss;
        // cout<<s<<endl;

        string val;

        for(int j=0;j<s.size();j++)
        {
            if(s[j] != 'k')
            {
                val+=s[j];
            }

            else{
            int countk = 0;
            while(j<s.size() && s[j] == 'k')
            {
                j++;
                countk++;
            }

            if(j == s.size() || (j<s.size() && s[j] != 'h'))
            {
                for(int r=0;r<countk;r++)
                {
                    val+="k";
                }
            }

            else
            {
                val += "h";
                // cout<<"heya"<<endl;
            }}

        }

        vec[i] = val;
        // cout<<vec[i]<</endl;
    }

}

int main()
{
    int n;
    cin>>n;
    vector <string> vec (n);
    for(int i=0;i<n;i++)
    {
        cin>>vec[i];
    }

    transformii(vec,n);

    set <string> s;
    for(int i=0;i<vec.size();i++)
    {
        s.insert(vec[i]);
    }

    //     cout<<"..."<<endl;
    // for(int j=0;j<vec.size();j++)
    // {
    //     cout<<vec[j]<<endl;
    // }

    cout<<s.size()<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

map <string,bool> m;

int main()
{
    int n;
    cin >> n;
    while(n--)
    {
        string x;
        cin >> x;
        int ndx = x.find("u");
        while(ndx != -1)
        {
            x.replace(ndx , 1 , "oo");
            //cout << x << endl;
            ndx = x.find("u");
        }
        //cout << ndx << endl;
        ndx = x.find("kh");
        while(ndx != -1)
        {
            x.replace(ndx , 2 , "h");
            ndx = x.find("kh");
        }
        m[x] = true;
    }
    cout << m.size();
    return 0;
}


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

map<string,int>mp;

int main()
{
	int n;
	while(cin>>n)
	{
		mp.clear();
		for(int i=1;i<=n;i++)
		{
			string s; cin>>s;
			while(s.find("u")!=string::npos) s=s.replace(s.find("u"),1,"oo");
			while(s.find("kh")!=string::npos) s=s.replace(s.find("kh"),2,"h");
 			if(!mp[s]) mp[s]=1;
	 	}
 		cout<<mp.size()<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define cout2(x, y) cout << x << " " << y << endl
#define N 100005

using namespace std;

int main(){

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

	string s, norm;

	int ans = 0;
	set<vector<char> >st;

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

		cin >> s;
		vector<char>norm;

		for(int j = s.size() - 1; j >= 0; j--){

			if(norm.size() == 0){

				if(s[j] == 'u')norm.pb('o'), norm.pb('o');
				else norm.pb(s[j]);
			}
			else{

				if(s[j] == 'u')norm.pb('o'), norm.pb('o');
				else if(norm.back() == 'h' && s[j] == 'k')continue;
				else norm.pb(s[j]);
			}
		}

		//reverse(all(norm));
		//for(int j = 0; j < norm.size(); j++)putchar(norm[j]);
		//puts("");
		st.insert(norm);
	}

	cout << st.size() << endl;
}


#include<bits/stdc++.h>
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define cout2(x, y) cout << x << " " << y << endl
#define N 100005

using namespace std;

int main(){

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

	string s, norm;

	int ans = 0;
	set<vector<char> >st;

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

		cin >> s;
		vector<char>norm;

		for(int j = s.size() - 1; j >= 0; j--){

			if(norm.size() == 0)norm.pb(s[j]);
			else{

				if(s[j] == 'u')norm.pb('o'), norm.pb('o');
				else if(norm.back() == 'h' && s[j] == 'k')norm.pop_back(), norm.pb('h');
				else norm.pb(s[j]);
			}
		}

		//reverse(all(norm));
		//for(int j = 0; j < norm.size(); j++)putchar(norm[j]);
		//puts("");
		st.insert(norm);
	}

	cout << st.size() << endl;
}


#include<iostream>
#include<map>
using namespace std;
int n,ans;
string s[100000];
map<string,int>mp;
main()
{
      cin>>n;
      for(int i=0;i<n;i++)
      cin>>s[i];

      for(int i=0;i<n;i++)
      {
              string s1="";
              int j=0;
              while(j<s[i].size())
              if(s[i][j]=='u')
              s1+='o',s1+='o',j++;
              else
              if(s[i][j]=='k')
              {
                    string s2="";
                    while(s[i][j]=='k' && j<s[i].size())
                    j++,s2+='k';

                    if(s[i][j]=='h')
                    s1+='h',j++;
                    else
                    s1+=s2;
              }
              else
              s1+=s[i][j],j++;

              s[i]=s1;
              mp[s[i]]=1;
              //cout<<s1<<endl;

      }

      for(int i=0;i<n;i++)
      if(mp[s[i]]==1)
      ans++,mp[s[i]]++;

      cout<<ans<<endl;

}


#include<bits/stdc++.h>
using namespace std;
int n;
string t;
set < string > S;
string Normalize(string s)
{
    string p = "";
    s += '_';
    for (int i = 0; i < (int)s.size() - 1; i++)
    {
        if (s[i] == 'u')
        {
            p += "oo";
            continue;
        }
        p += s[i];
    }
    s = "";
    p += '_';
    for (int i = 0; i < (int)p.size() - 1; i++)
    {
        if (p[i] == 'k' && p[i + 1] == 'h')
        {
            if (s.size() == 0)
            {
                i ++;
                s += 'h';
                continue;
            }
            while (s[(int)s.size() - 1] == 'k')
            {
                s = s.substr(0, (int)s.size() - 1);
                if (s.size() == 0)
                    break;
            }
            s += 'h';
            i ++;
            continue;
        }
        s += p[i];
    }
    return (s);
}
int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> t;
        S.insert(Normalize(t));
    }
    cout << (int)S.size();
    return (0);
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll base = 77773, mod = 99999941;
ll b[700];
ll Hash(char *c){
	int flag = 0;
	ll hash = 73;
	for (int i = strlen(c) - 1; ~i; i--){
		if (c[i] == 'k' && flag) continue;
		flag = 0;
		if (c[i] == 'u'){
			hash = (hash * base + (ll)'o') % mod;
			hash = (hash * base + (ll)'o') % mod;
			continue;
		}
		hash = (hash * base + c[i]) % mod;
		if (c[i] == 'h') flag = 1;
	}
	return hash;
}
int main(){
	int n; scanf("%d", &n);
	for (int i = 1; i <= n; i++){
		char c[40];
		scanf("%s", c);
		b[i] = Hash(c);
	}
	sort(b + 1, b + 1 + n);
	printf("%d\n", (int)(unique(b + 1, b + 1 + n) - b - 1));
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<math.h>
#include<string.h>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<cctype>
#include<cstring>
#include<bits/stdc++.h>

#define pb push_back
#define sf(x) scanf("%d",&x)
#define p_f(x) printf("%d ",x)
#define pf(x) printf("%d\n",x)

using namespace std;

typedef long long ll;
typedef double dl;
ll mod=1e9+7;
typedef pair<int,int> pa;
int maxn=1e9,minn=-1e9;

ll modpow(ll base,ll exp,int modulus) {
  base %= modulus;
  ll result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}

/*array globally declared. and size of array in n.
void convert(int n)
{
    int temp[n];
    memcpy(temp, arr, n*sizeof(int));
    sort(temp, temp + n);
    map<int, int> umap;

    int val = 0;
    for (int i = 0; i < n; i++)
        umap[temp[i]] = val++;

    // Convert array by taking positions from
    // umap
    for (int i = 0; i < n; i++)
        arr[i] = umap[arr[i]];
}*/

int sqr(int x){
    return x*x;
}

bool is_prime(int x){
    for(int i=2;i*i<=x;++i){
        if(x%i==0)
            return false;
    }
    return true;
}

string w;

void func(string x){
	int n=x.size();
	string str1="oo",str2="h";
    string y;
    y.clear();
    int a=0;
	for(int j=0;j<n;++j){
		if(j+1<n && x[j]=='k' && x[j+1]=='h'){
   			y.insert(a,str2);
   			++a; ++j;
    	}
    	else if(x[j]=='u'){
    		y.insert(a,str1);
    		a+=2;
   		}
    	else{
   			char z=x[j];
    		stringstream s;
   			string c;
   			c.clear();
   			s<<z;
   			s>>c;
   			y.insert(a,c);
   			++a;
   		}
	}
	n=y.size();
	int k=0;
	for(int j=0;j<n;++j){
		if(j+1<n && y[j]=='k' && y[j+1]=='h'){
   			k=1;
    	}
    	if(y[j]=='u'){
    		k=1;
    	}
	}
	if(k==1)
	    func(y);
	else
		w=y;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n; cin>>n;
    set<string>lol;
    lol.clear();
    int ans=0;
    for(int i=0;i<n;++i){
    	string x;
    	cin>>x;
    	w.clear();
    	func(x);
    	if(lol.find(w)==lol.end()){
    		lol.insert(w);
    		ans++;
    	}
    }
    cout<<ans;
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<math.h>
#include<string.h>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<cctype>
#include<cstring>
#include<bits/stdc++.h>

#define pb push_back
#define sf(x) scanf("%d",&x)
#define p_f(x) printf("%d ",x)
#define pf(x) printf("%d\n",x)

using namespace std;

typedef long long ll;
typedef double dl;
ll mod=1e9+7;
typedef pair<int,int> pa;
int maxn=1e9,minn=-1e9;

ll modpow(ll base,ll exp,int modulus) {
  base %= modulus;
  ll result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}

/*array globally declared. and size of array in n.
void convert(int n)
{
    int temp[n];
    memcpy(temp, arr, n*sizeof(int));
    sort(temp, temp + n);
    map<int, int> umap;

    int val = 0;
    for (int i = 0; i < n; i++)
        umap[temp[i]] = val++;

    // Convert array by taking positions from
    // umap
    for (int i = 0; i < n; i++)
        arr[i] = umap[arr[i]];
}*/

int sqr(int x){
    return x*x;
}

bool is_prime(int x){
    for(int i=2;i*i<=x;++i){
        if(x%i==0)
            return false;
    }
    return true;
}

string w;

void func(string x){
	int n=x.size();
	string str1="u",str2="h";
    string y;
    y.clear();
    int a=0;
	for(int j=0;j<n;++j){
		if(j+1<n && x[j]=='k' && x[j+1]=='h'){
   			y.insert(a,str2);
   			++a; ++j;
    	}
    	else if(j+1<n && x[j]=='o' && x[j+1]=='o'){
    		y.insert(a,str1);
    		++a; ++j;
   		}
    	else{
   			char z=x[j];
    		stringstream s;
   			string c;
   			c.clear();
   			s<<z;
   			s>>c;
   			y.insert(a,c);
   			++a;
   		}
	}
	n=y.size();
	int k=0;
	for(int j=0;j<n;++j){
		if(j+1<n && x[j]=='k' && x[j+1]=='h'){
   			k=1;
    	}
    	if(j+1<n && x[j]=='o' && x[j+1]=='o'){
    		k=1;
    	}
	}
	if(k==1)
	    func(y);
	else
		w=y;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n; cin>>n;
    set<string>lol;
    lol.clear();
    int ans=0;
    //set<string>ss;
    //ss.clear();
    for(int i=0;i<n;++i){
    	string x;
    	cin>>x;
    	w.clear();
    	func(x);
    	if(lol.find(w)==lol.end()){
    		lol.insert(w);
    		ans++;
    	}
    }
    cout<<ans;
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<math.h>
#include<string.h>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<cctype>
#include<cstring>
#include<bits/stdc++.h>

#define pb push_back
#define sf(x) scanf("%d",&x)
#define p_f(x) printf("%d ",x)
#define pf(x) printf("%d\n",x)

using namespace std;

typedef long long ll;
typedef double dl;
ll mod=1e9+7;
typedef pair<int,int> pa;
int maxn=1e9,minn=-1e9;

ll modpow(ll base,ll exp,int modulus) {
  base %= modulus;
  ll result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}

/*array globally declared. and size of array in n.
void convert(int n)
{
    int temp[n];
    memcpy(temp, arr, n*sizeof(int));
    sort(temp, temp + n);
    map<int, int> umap;

    int val = 0;
    for (int i = 0; i < n; i++)
        umap[temp[i]] = val++;

    // Convert array by taking positions from
    // umap
    for (int i = 0; i < n; i++)
        arr[i] = umap[arr[i]];
}*/

int sqr(int x){
    return x*x;
}

bool is_prime(int x){
    for(int i=2;i*i<=x;++i){
        if(x%i==0)
            return false;
    }
    return true;
}

string w;

void func(string x){
	int n=x.size();
	string str1="oo",str2="h";
    string y;
    y.clear();
    int a=0;
	for(int j=0;j<n;++j){
		if(j+1<n && x[j]=='k' && x[j+1]=='h'){
   			y.insert(a,str2);
   			++a; ++j;
    	}
    	else if(x[j]=='u'){
    		y.insert(a,str1);
    		a+=2;
   		}
    	else{
   			char z=x[j];
    		stringstream s;
   			string c;
   			c.clear();
   			s<<z;
   			s>>c;
   			y.insert(a,c);
   			++a;
   		}
	}
	n=y.size();
	int k=0;
	for(int j=0;j<n;++j){
		if(j+1<n && x[j]=='k' && x[j+1]=='h'){
   			k=1;
    	}
    	if(x[j]=='u'){
    		k=1;
    	}
	}
	if(k==1)
	    func(y);
	else
		w=y;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n; cin>>n;
    set<string>lol;
    lol.clear();
    int ans=0;
    //set<string>ss;
    //ss.clear();
    for(int i=0;i<n;++i){
    	string x;
    	cin>>x;
    	w.clear();
    	func(x);
    	if(lol.find(w)==lol.end()){
    		lol.insert(w);
    		ans++;
    	}
    }
    cout<<ans;
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<math.h>
#include<string.h>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<cctype>
#include<cstring>
#include<bits/stdc++.h>

#define pb push_back
#define sf(x) scanf("%d",&x)
#define p_f(x) printf("%d ",x)
#define pf(x) printf("%d\n",x)

using namespace std;

typedef long long ll;
typedef double dl;
ll mod=1e9+7;
typedef pair<int,int> pa;
int maxn=1e9,minn=-1e9;

ll modpow(ll base,ll exp,int modulus) {
  base %= modulus;
  ll result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}

/*array globally declared. and size of array in n.
void convert(int n)
{
    int temp[n];
    memcpy(temp, arr, n*sizeof(int));
    sort(temp, temp + n);
    map<int, int> umap;

    int val = 0;
    for (int i = 0; i < n; i++)
        umap[temp[i]] = val++;

    // Convert array by taking positions from
    // umap
    for (int i = 0; i < n; i++)
        arr[i] = umap[arr[i]];
}*/

int sqr(int x){
    return x*x;
}

bool is_prime(int x){
    for(int i=2;i*i<=x;++i){
        if(x%i==0)
            return false;
    }
    return true;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n; cin>>n;
    set<string>lol;
    lol.clear();
    int ans=0;
    set<string>ss;
    ss.clear();
    for(int i=0;i<n;++i){
    	string x;
    	cin>>x;
    	int siz=x.size();
    	int a=0;
    	string str1="u",str2="h";
    	string y;
    	y.clear();
    	for(int j=0;j<siz;++j){
    		if(j+1<siz && x[j]=='k' && x[j+1]=='h'){
    			y.insert(a,str2);
    			++a; ++j;
    		}
    		else if(j+1<siz && x[j]=='o' && x[j+1]=='o'){
    			y.insert(a,str1);
    			++a; ++j;
    			continue;
    		}
    		else{
    			char z=x[j];
    			stringstream s;
    			string c;
    			s<<z;
    			s>>c;
    			y.insert(a,c);
    			++a;
    		}
    	}
    	if(lol.find(y)!=lol.end()){
    		if(ss.find(y)==ss.end()){
    		    ss.insert(y);
    		    ++ans;
    		}
    	}
    	else{
    		lol.insert(y);
    	}
    }
    cout<<ans;
    return 0;
}


#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <set>
#include <vector>
#include <math.h>

using namespace std;

int main(){

	int n;
	cin >> n;

	vector<string> vec;

	for(int i = 0; i < n ; i++){
		string t; cin >> t;
		string cad;
		for(int j = 0; j < t.size(); j++){
			if(t[j] == 'u'){
				cad.push_back('o');	cad.push_back('o');
			}
			else cad.push_back(t[j]);
		}
		string res;
		for(int j = cad.size()-1 ; j >= 0; j--){
			res.push_back(cad[j]);
			if(cad[j] == 'h'){
				j--;
				while(j >= 0 && cad[j] == 'k')
					j--;
				j++;
			}
		}
		vec.push_back(res);
	}

	sort(vec.begin(), vec.end());

	int c = 0;
	for(int i = 0; i < n ; i++){
		while(i < n-1 && vec[i] == vec[i+1]) i++;
		c++;
	}

	cout << c;

return 0;
}


#include <iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<set>
#include<time.h>

#define ll long long
#define MAXN 2000100

using namespace std;

set<string>s1;
bool vis[30];

int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        s1.clear();
        for(int i=1;i<=n;i++)
        {
            string a;
            cin>>a;
            int  len=a.size();
            memset(vis,0,sizeof(vis));
            for(int i=0;i<len;i++)
            {
                if(a[i]=='h')
                {
                    for(int j=i-1;j>=0;j--)
                    {
                        if(a[j]!='k')
                            break;
                        else
                            vis[j]=1;
                    }
                }
            }
            string b="";
            for(int i=0;i<len;i++)
                if(!vis[i])
                {
                    if(a[i]=='u')
                        b+="oo";
                    else
                        b+=a[i];
                }
            s1.insert(b);
        }
        cout<<s1.size()<<endl;
    }
    return 0;
}


#include <algorithm>
#include <iostream>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define foreach(i,x) for(type(x)i=x.begin();i!=x.end();i++)
#define FOR(ii,aa,bb) for(int ii=aa;ii<=bb;ii++)
#define ROF(ii,aa,bb) for(int ii=aa;ii>=bb;ii--)

#define dbgs(x) cerr << (#x) << " --> " << (x) << ' '
#define dbg(x) cerr << (#x) << " --> " << (x) << endl

#define type(x) __typeof(x.begin())

#define mid (bas + son >> 1)
#define right (k + k + 1)
#define left (k + k)

#define pb push_back
#define mp make_pair

#define nd second
#define st first

#define SET(A,b) memset(A,b,sizeof (A) )

#define mod 1000000007
#define inf mod

#define endl '\n'
#define endll puts("")

#define N 1000005

typedef pair < int , int > pii;

typedef long long ll;

int n, ans;
string s[N];
map < string , int > h;

void ekle (string t){
	int u = t.length();
	FOR(i, 0, u - 2){
		if(t[i] < 'a' or t[i] > 'z')
			continue;
		if(t[i] == 'k' and t[i + 1] == 'h'){
			t[i] = 'h';
			t[i + 1] = '*';
			i = i - 2;
		}
	}
	char yeni[100];
	int ind = 0;
	FOR(i, 0, u - 1){
		if(t[i] == '*')
			continue;
		if(t[i] == 'u'){
			yeni[ind++] = 'o';
			yeni[ind++] = 'o';
			continue;
		}
		yeni[ind++] = t[i];
	}
	yeni[ind] = '\0';
	if(!h[yeni]){
		ans++;
		h[yeni]++;
	}
}

int main () {
	cin >> n;
	FOR(i, 1, n){
		cin >> s[i];
		ekle(s[i]);
	}
	cout << ans;
	return 0;
}


#include <algorithm>
#include <iostream>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define foreach(i,x) for(type(x)i=x.begin();i!=x.end();i++)
#define FOR(ii,aa,bb) for(int ii=aa;ii<=bb;ii++)
#define ROF(ii,aa,bb) for(int ii=aa;ii>=bb;ii--)

#define dbgs(x) cerr << (#x) << " --> " << (x) << ' '
#define dbg(x) cerr << (#x) << " --> " << (x) << endl

#define type(x) __typeof(x.begin())

#define mid (bas + son >> 1)
#define right (k + k + 1)
#define left (k + k)

#define pb push_back
#define mp make_pair

#define nd second
#define st first

#define SET(A,b) memset(A,b,sizeof (A) )

#define mod 1000000007
#define inf mod

#define endl '\n'
#define endll puts("")

#define N 1000005

typedef pair < int , int > pii;

typedef long long ll;

int n, ans;
string s[N];
map < string , int > h;

void ekle (string t){
	int u = t.length();
	FOR(i, 0, u - 2){
		if(t[i] < 'a' or t[i] > 'z')
			continue;
		if(t[i] == 'k' and t[i + 1] == 'h'){
			t[i] = 'h';
			t[i + 1] = '*';
			i = i - 2;
		}
	}
	char yeni[25];
	int ind = 0;
	FOR(i, 0, u - 1){
		if(t[i] == '*')
			continue;
		if(t[i] == 'u'){
			yeni[ind++] = 'o';
			yeni[ind++] = 'o';
			continue;
		}
		yeni[ind++] = t[i];
	}
	yeni[ind] = '\0';
	if(!h[yeni]){
		ans++;
		h[yeni]++;
	}
}

int main () {
	cin >> n;
	FOR(i, 1, n){
		cin >> s[i];
		ekle(s[i]);
	}
	cout << ans;
	return 0;
}


#include<cstdio>
#include<cstring>
#include<set>
typedef unsigned long long ull;
using std::set;
int n;
char s[1000];
ull num;
set<ull>hash;
signed main()
{
	scanf("%d",&n);
	while(n--)
	{
		scanf("%s",s+1);
		num=0;
		int len=strlen(s+1);
		for(register int i=1;i<=len;i++)
		{
			if(s[i]!='k'&&s[i]!='u')
				num=num*27+s[i]-'a'+1;
			else if(s[i]=='u')
			{
				num=num*27+'o'-'a'+1;
				num=num*27+'o'-'a'+1;
			}
			else
			{
				int j=i+1;
				while(s[j]=='k')
					j++;
				if(s[j]=='h')
					num=num*27+'h'-'a'+1,i=j;
				else
					num=num*27+'k'-'a'+1;
			}
		}
		hash.insert(num);
	}
	printf("%d\n",hash.size());
	return 0;
}


#include<cstdio>
#include<cstring>
#include<set>
typedef unsigned long long ull;
const int mod(1e9+7);
using std::set;
int n;
char s[1000];
ull num;
set<ull>hash;
signed main()
{
	scanf("%d",&n);
	while(n--)
	{
		scanf("%s",s+1);
		num=0;
		int len=strlen(s+1);
		for(register int i=1;i<=len;i++)
		{
			if(s[i]!='k'&&s[i]!='u')
				num=(num*26+s[i]-'a')%mod;
			else if(s[i]=='u')
			{
				num=(num*26+'o'-'a')%mod;
				num=(num*26+'o'-'a')%mod;
			}
			else
			{
				int j=i+1;
				while(s[j]=='k')
					j++;
				if(s[j]=='h')
					num=(num*26+'h'-'a')%mod,i=j;
				else
					num=(num*26+'k'-'a')%mod;
			}
		}
		hash.insert(num);
	}
	printf("%d\n",hash.size());
	return 0;
}


#include<cstdio>
#include<cstring>
#include<set>
typedef unsigned long long ull;
using std::set;
int n;
char s[1000];
ull num;
set<ull>hash;
signed main()
{
	scanf("%d",&n);
	while(n--)
	{
		memset(s,0,sizeof(s));
		scanf("%s",s+1);
		num=0;
		int len=strlen(s+1);
		for(register int i=1;i<=len;i++)
		{
			if(s[i]!='k'&&s[i]!='u')
				num=num*26+s[i]-'a';
			else if(s[i]=='u')
			{
				num=num*26+'o'-'a';
				num=num*26+'o'-'a';
			}
			else
			{
				int j=i+1;
				while(s[j]=='k')
					j++;
				if(s[j]=='h')
					num=num*26+'h'-'a',i=j;
				else
					num=num*26+'k'-'a';
			}
		}
		hash.insert(num);
	}
	printf("%d\n",hash.size());
	return 0;
}


#include<cstdio>
#include<cstring>
#include<set>
typedef unsigned long long ull;
using std::set;
int n;
char s[1000];
ull num;
set<ull>hash;
signed main()
{
	scanf("%d",&n);
	while(n--)
	{
		scanf("%s",s+1);
		num=0;
		int len=strlen(s+1);
		for(register int i=1;i<=len;i++)
		{
			if(s[i]!='k'&&s[i]!='u')
				num=num*26+s[i]-'a';
			else if(s[i]=='u')
			{
				num=num*26+'o'-'a';
				num=num*26+'o'-'a';
			}
			else
			{
				int j=i+1;
				while(s[j]=='k')
					j++;
				if(s[j]=='h')
					num=num*26+'h'-'a',i=j;
				else
					num=num*26+'k'-'a';
			}
		}
		hash.insert(num);
	}
	printf("%d\n",hash.size());
	return 0;
}


#include<cstdio>
#include<cstring>
#include<set>
#define __int128 ull
using std::set;
int n;
char s[1000];
ull num;
set<ull>hash;
signed main()
{
	scanf("%d",&n);
	while(n--)
	{
		scanf("%s",s+1);
		num=0;
		int len=strlen(s+1);
		for(register int i=1;i<=len;i++)
		{
			if(s[i]!='k'&&s[i]!='u')
				num=num*26+s[i]-'a';
			else if(s[i]=='u')
			{
				num=num*26+'o'-'a';
				num=num*26+'o'-'a';
			}
			else
			{
				int j=i+1;
				while(s[j]=='k')
					j++;
				if(s[j]=='h')
					num=num*26+'h'-'a',i=j;
				else
					num=num*26+'k'-'a';
			}
		}
		hash.insert(num);
	}
	printf("%d\n",hash.size());
	return 0;
}


#include<cstdio>
#include<cstring>
#include<set>
typedef unsigned long long ull;
using std::set;
int n;
char s[1000];
ull num;
set<ull>hash;
signed main()
{
	scanf("%d",&n);
	while(n--)
	{
		scanf("%s",s+1);
		num=0;
		int len=strlen(s+1);
		for(register int i=1;i<=len;i++)
		{
			if(s[i]!='k'&&s[i]!='u')
				num=num*26+s[i]-'a';
			else if(s[i]=='u')
			{
				num=num*26+'o'-'a';
				num=num*26+'o'-'a';
			}
			else
			{
				int j=i+1;
				while(s[j]=='k')
					j++;
				if(s[j]=='h')
					num=num*26+'h'-'a',i=j;
				else
					num=num*26+'k'-'a';
			}
		}
		hash.insert(num);
	}
	printf("%I64d\n",hash.size());
	return 0;
}


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

int n;
struct node
{
	string s;
/*	bool operator < (const node &x) const
	{
		int lena=s.size(),lenb=x.s.size();
		if (lena!=lenb)
		{
			for (int i=0;i<lena;i++)
				if (s[i]!=x.s[i])
					return s[i]<x.s[i];
			return 0;
		}
		else return lena<lenb;
	}*/
	bool operator < (const node &x) const
	{
		return s<x.s;
	}
}a[411];

long long read()
{
	long long x=0,f=1;char c=getchar();
	while (!isdigit(c)) {if (c=='-')f=-1;c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0';c=getchar();}
	return x*f;
}

void write(long long x)
{
	if (x<0) putchar('-'),x=-x;if (x>=10) write(x/10);
	putchar(x%10+'0');
}

void writern(long long x)
{
	write(x),putchar(' ');
}

void writeln(long long x)
{
	 write(x),puts("");
}

int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n=read();
	for (int i=1;i<=n;i++)
		cin >> a[i].s;
	for (int i=1;i<=n;i++)
	{
		for (int j=a[i].s.size()-1;j>=0;j--)
		{
			if (a[i].s[j]=='h')
			{
				int r=j;
				while (j>0&&a[i].s[j-1]=='k')
				{
					j--;
				}
				a[i].s.erase(j,r-j);
			}
			if (a[i].s[j]=='u')
			{
				a[i].s.erase(j,1);a[i].s.insert(j,2,'o');
			}
		}
	}
//	cout <<"=======================================\n";
//	for (int i=1;i<=n;i++)
//	{
//		cout << a[i].s << "\n";
//	}
	sort(a+1,a+n+1);
//	cout <<"=======================================\n";
//	for (int i=1;i<=n;i++)
//	{
//		cout << a[i].s << "\n";
//	}
	int cnt=0;
	for (int i=1;i<=n;i++)
	{
		if (i==1 || a[i].s!=a[i-1].s)
			cnt++;
	}
	writeln(cnt);
	return 0;
}