#include <stdio.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>
#include <map>
#include <iomanip>
#include <set>
#include <stack>
#define ll long long int
#define endln "\n"
#define goodluck_code() main()
#define _Open_Minded_Short_Code_ return 0;
using namespace std;

int goodluck_code(){
	ll n , k;
	cin >> n >> k;
	vector <ll> ve(n);
	vector <ll> vec;
	vector <ll> vet;
	set <ll> se;
	set <ll> :: iterator si;
	map <ll,ll> mp;
	map <ll,ll> mp2;
	map <ll,ll> ::iterator mi;
	for(int i=0;i<n;i++){
		cin >> ve[i];
		se.insert(ve[i]);
	}
	sort(ve.begin(),ve.end());
//	for(int i=0;i<n;i++){
//		cout<<ve[i]<<" ";
//	}
//	cout<<endln;
	ll x = ve.back();
	if(k == 1){
		cout<<se.size()<<endln;
		return 0;
	}
	if(se.size() == 1){
		cout<<"1"<<endln;
		return 0;
	}else{
		ll re = 0 , tamp = 0 , vt;
		for(si = se.begin();si != se.end();si++){
			vec.push_back(*si);
			mp[*si]++;
		}
		for(int i=0;i<vec.size();i++){

			if(vec[i] != -1){
				re = vec[i] * k;
				mp[re]++;
				if(mp[re] == 2){
					mp[re] = -1;
				}
			}
		}
		int dem = 0;
		for(mi = mp.begin();mi != mp.end();mi++){
			if(mi->first > x){
				dem++;
			}
		}
		if(dem + 1 > n){
			cout<<dem<<endln;
		}else{
			cout<<dem+1<<endln;
		}

	}
	_Open_Minded_Short_Code_
}


#include <stdio.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>
#include <map>
#include <iomanip>
#include <set>
#include <stack>
#define ll long long int
#define endln "\n"
#define goodluck_code() main()
#define _Open_Minded_Short_Code_ return 0;
using namespace std;

int goodluck_code(){
	ll n , k;
	cin >> n >> k;
	vector <ll> ve(n);
	map <ll,ll> mp;
	for(int i=0;i<n;i++){
		cin >> ve[i];
	}
	sort(ve.begin(),ve.end());
	int p = 0 , dem = 0 , dem1 = 0;
	for(int i=0;i<n;i++){
		if(ve[i] != -1){
			p = ve[i] * k;
			mp[p]++;
			for(int j=0;j<n;j++){
				if(ve[j] != -1){
					mp[ve[j]]++;
					if(p == ve[j]){
						dem++;
						dem1 = 1;
						ve[j] = -1;
						ve[i] = -1;
					}
				}
			}
			if(dem1 == 0){
				dem++;
			}
		}
		mp.clear();
	}
	if(dem == n){
		cout<<dem<<endln;
		return 0;
	}
	for(int i=0;i<n;i++){
		if(ve[i] != -1){
			dem++;
		}
	}
	cout<<dem<<endln;

	_Open_Minded_Short_Code_
}


#include <stdio.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>
#include <map>
#include <iomanip>
#include <set>
#include <stack>
#define ll long long int
#define endln "\n"
#define goodluck_code() main()
#define _Open_Minded_Short_Code_ return 0;
using namespace std;

int goodluck_code(){
	ll n , k;
	cin >> n >> k;
	vector <ll> ve(n);
	map <ll,ll> mp;
	for(int i=0;i<n;i++){
		cin >> ve[i];
	}
	sort(ve.begin(),ve.end());
//	for(int i=0;i<n;i++){
//		cout<<ve[i]<<" ";
//	}
//	cout<<endln;
	int p = 0 , dem = 0 , dem1 = 0;
	for(int i=0;i<n;i++){
		if(ve[i] != -1){
			p = ve[i] * k;
			mp[p]++;
			for(int j=0;j<n;j++){
				if(ve[j] != -1){
					mp[ve[j]]++;
					if(p == ve[j]){
						dem++;
						dem1 = 1;
						ve[j] = -1;
						ve[i] = -1;
					}
				}
			}
			if(dem1 == 0){
				dem++;
			}
//			for(int k=0;k<n;k++){
//				cout<<ve[k]<<" ";
//			}
//			cout<<endln;
//			cout<<dem<<endln;
//			cout<<endln;
		}
		mp.clear();
	}
	for(int i=0;i<n;i++){
		if(ve[i] != -1){
			dem++;
		}
	}
	cout<<dem<<endln;

	_Open_Minded_Short_Code_
}


#include <stdio.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>
#include <map>
#include <iomanip>
#include <set>
#include <stack>
#define ll long long int
#define endln "\n"
#define goodluck_code() main()
#define _Open_Minded_Short_Code_ return 0;
using namespace std;

int goodluck_code(){
	ll n , k;
	cin >> n >> k;
	vector <ll> ve(n);
	vector <ll> ves;
	vector <ll> vet;
	set <ll> se;
	set <ll> :: iterator si;
	for(int i=0;i<n;i++){
		cin >> ve[i];
		se.insert(ve[i]);
	}
	sort(ve.begin(),ve.end());
	if(se.size() == 1){
		cout<<"1"<<endln;
		return 0;
	}
	ll maxv = ve.back();
//	for(int i=0;i<n;i++){
//		cout<<ve[i]<<" ";
//	}
//	cout<<endln;
	ll q = 0 , vitri = 0 ,tamp = 0;
	for(si = se.begin() ; si != se.end();si++){
		ves.push_back(*si);
		q = *si *k;
		tamp++;
		if(q >= maxv){
			vitri = n - tamp;
			break;
		}
	}
	if(vitri == 0){
		cout<<n<<endln;
	}else{
		ll muti = 0 , dem = 0 , dem1 = 0;
		sort(ves.begin(),ves.end());
		for(int i=0;i<ves.size();i++){
			if(ves[i] != -1){
				dem1 = 0;
				muti = ves[i] * k;
				for(int j=0;j<ves.size();j++){
					if(muti == ves[j]){
				     	vet.push_back(ves[i]);
						ves[j] = -1;
						ves[i] = -1;
						break;
					}
				}
			}
		}
		cout<<vitri + vet.size()<<endln;
	}
	_Open_Minded_Short_Code_
}


#include <stdio.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>
#include <map>
#include <iomanip>
#include <set>
#include <stack>
#define ll long long int
#define endln "\n"
#define goodluck_code() main()
#define _Open_Minded_Short_Code_ return 0;
using namespace std;

int goodluck_code(){
	ll n , k;
	cin >> n >> k;
	vector <ll> ve(n);
	vector <ll> ves;
	set <ll> se;
	map <ll,ll> mp;
	map <ll,ll> :: iterator im;
	for(int i=0;i<n;i++){
		cin >> ve[i];
		se.insert(ve[i]);
	}
	if(k == 1){
		cout<<se.size()<<endln;
		return 0;
	}
	set <ll> :: iterator is;
	for(is = se.begin() ; is != se.end() ; is++){
		ves.push_back(*is);
	}
	int dem = 0;
	for(int i=0;i<ves.size();i++){
		int j = 1;
		while(j-->0){
			if(ves[i] != -1){
				mp[ves[i]]++;
				if(mp[ve[i]] == 2){
					ves[i] = -1;
					break;
				}
				mp[ves[i] * k]++;
			}
			if(mp[ve[i]*k] == 1){
				dem++;
			}
//			cout<<ves[i]<<" "<<mp[ves[i]]<<endln;
//			cout<<ves[i]*k<<" "<<mp[ves[i]*k]<<endln;
//			cout<<endln;
		}
	}
	cout<<dem<<endln;
//	for(im = mp.begin() ; im != mp.end();im++){
//		cout<<im->first<<" "<<im->second<<endln;
//	}
	_Open_Minded_Short_Code_
}


#include <stdio.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>
#include <map>
#include <iomanip>
#include <set>
#include <stack>
#define ll long long int
#define endln "\n"
#define goodluck_code() main()
#define _Open_Minded_Short_Code_ return 0;
using namespace std;

int goodluck_code(){
	ll n , k;
	cin >> n >> k;
	vector <ll> ve(n);
	vector <ll> vem;
	set <ll> se;
	map <ll,ll> mp;
	for(int i=0;i<n;i++){
		cin >> ve[i];
		se.insert(ve[i]);
	}
	sort(ve.begin(),ve.end());
	ll x = ve.back();
	set <ll> :: iterator it;
	map <ll,ll> :: iterator fi;
	ll d = 0 , tamp = 0 , res = 0;
	for(it = se.begin();it != se.end();it++){
		d = *it *k;
		tamp++;
		if(d > x){
			res = n-(tamp - 1);
			break;
		}
	}
	int sum = 0;
	int ki = 0;
	for(it = se.begin();it != se.end() ;it++){
		vem.push_back(*it);
	}
	for(int i=0;i<vem.size()-res;i++){
		sum = vem[i] * k;
		ki = 0;
		for(int j=i+1;j<vem.size()-res;j++){
			if(sum != vem[j]){
				ki = 1;
			}else{
				ki = 0;
				break;
			}
		}
		res+=ki;
	}
	cout<<res<<endln;

	_Open_Minded_Short_Code_
}


#include <stdio.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>
#include <map>
#include <iomanip>
#include <set>
#include <stack>
#define ll long long int
#define endln "\n"
#define goodluck_code() main()
#define _Open_Minded_Short_Code_ return 0;
using namespace std;

int goodluck_code(){
	ll n , k ;
	cin >> n >> k;
	vector <ll> ve(n);
	set <ll> se;
	map <ll,ll> mp;
	for(int i=0;i<n;i++){
		cin >> ve[i];
		se.insert(ve[i]);
	}
	set <ll> :: iterator it;
	map <ll,ll> ::iterator ti;
	ll d = 0;
	for(it = se.begin();it!=se.end();it++){
		d = *it * k;
		mp[d]++;
	}
	int dem = 0;
	for(ti = mp.begin();ti!=mp.end();ti++){
		for(it = se.begin();it!=se.end();it++){
			if(ti->first == *it){
				dem++;
			}
		}
	}
	cout<<n-dem<<endln;
	_Open_Minded_Short_Code_
}


#include <stdio.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>
#include <map>
#include <iomanip>
#include <set>
#include <stack>
#define ll long long int
#define endln "\n"
#define goodluck_code() main()
#define _Open_Minded_Short_Code_ return 0;
using namespace std;

int goodluck_code(){
	ll n , k;
	cin >> n >> k;
	vector <ll> ve(n);
	vector <ll> ves;
	vector <ll> vet;
	set <ll> se;
	map <ll,ll> mp;
	map <ll,ll> :: iterator im;
	for(int i=0;i<n;i++){
		cin >> ve[i];
		se.insert(ve[i]);
	}
	if(k == 1){
		cout<<se.size()<<endln;
		return 0;
	}
	set <ll> :: iterator is;
	for(is = se.begin() ; is != se.end() ; is++){
		ves.push_back(*is);
	}
	int dem = 0;
	for(int i=0;i<ves.size();i++){
		int j = 1;
		while(j-->0){
			if(ves[i] != -1){
				mp[ves[i]]++;
				if(mp[ves[i]] == 2){
					ves[i] = -1;
					break;
				}
				mp[ves[i] * k]++;
				vet.push_back(ves[i]);
//				cout<<ves[i]<<" "<<mp[ves[i]]<<endln;
//				cout<<ves[i]*k<<" "<<mp[ves[i]*k]<<endln;
//				cout<<endln;
			}
		}
	}
	cout<<vet.size()<<endln;
//	for(im = mp.begin() ; im != mp.end();im++){
//		cout<<im->first<<" "<<im->second<<endln;
//	}
	_Open_Minded_Short_Code_
}


#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#define lli long long int
#define loop(i,x,n) for(int i=x;i<n;i++)
#define loopr(i,x,n) for(int i=n-1;i>=x;i--)
#define st set<lli>
#define v vector<lli>
#define um unordered_map<lli,lli>
#define vpl vector<pair<lli,lli>>
#define llu long long unsigned
#define ms muliset<int,greater<int>>
#define ums unordered_map<string,lli>
#define pb push_back
#define time ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define test lli t; cin>>t; while(t--)
using namespace std;
int gcd(int a,int b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
v adj[100001];
lli vist[10001];

void dfs(lli node)
{
    vist[node]=1;
    for(lli child : adj[node]) if(!vist[child]) dfs(child);
}

int main()
{
    time
    // lli t;
    // cin>>t;
    // while(t--)
    {
        lli n,k,ans=0;
        cin>>n>>k;
        um a;
        loop(i,0,n)
        {
            lli x;
            cin>>x;
            if(!a[x/k] || x%k) ans++;
            a[x]++;
        }
        cout<<ans<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#define lli long long int
#define loop(i,x,n) for(int i=x;i<n;i++)
#define loopr(i,x,n) for(int i=n-1;i>=x;i--)
#define st set<lli>
#define v vector<lli>
#define um unordered_map<lli,lli>
#define vpl vector<pair<lli,lli>>
#define llu long long unsigned
#define ms muliset<int,greater<int>>
#define ums unordered_map<string,lli>
#define pb push_back
#define time ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define test lli t; cin>>t; while(t--)
using namespace std;
int gcd(int a,int b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
v adj[100001];
lli vist[10001];

void dfs(lli node)
{
    vist[node]=1;
    for(lli child : adj[node]) if(!vist[child]) dfs(child);
}

int main()
{
    time
    // lli t;
    // cin>>t;
    // while(t--)
    {
        lli n,k,ans=0;
        cin>>n>>k;
        um a;
        lli b[n];
        loop(i,0,n) cin>>b[i];
        sort(b,b+n);
        loop(i,0,n) if(!a[b[i]]) ans++,a[k*b[i]]++;
        cout<<ans<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#define lli long long int
#define loop(i,x,n) for(int i=x;i<n;i++)
#define loopr(i,x,n) for(int i=n-1;i>=x;i--)
#define st set<lli>
#define v vector<lli>
#define um unordered_map<lli,lli>
#define vpl vector<pair<lli,lli>>
#define llu long long unsigned
#define ms muliset<int,greater<int>>
#define ums unordered_map<string,lli>
#define pb push_back
#define time ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define test lli t; cin>>t; while(t--)
using namespace std;
int gcd(int a,int b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
v adj[100001];
lli vist[10001];

void dfs(lli node)
{
    vist[node]=1;
    for(lli child : adj[node]) if(!vist[child]) dfs(child);
}

int main()
{
    time
    // lli t;
    // cin>>t;
    // while(t--)
    {
        lli n,k,ans=0;
        cin>>n>>k;
        um a;
        loop(i,0,n)
        {
            lli x;
            cin>>x;
            if(!a[x])
            {
                ans++;
                a[k*x]++;
                if(!(x%k)) a[x/k]++;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#define lli long long int
#define loop(i,x,n) for(int i=x;i<n;i++)
#define loopr(i,x,n) for(int i=n-1;i>=x;i--)
#define st set<lli>
#define v vector<lli>
#define um unordered_map<lli,lli>
#define vpl vector<pair<lli,lli>>
#define llu long long unsigned
#define ms muliset<int,greater<int>>
#define ums unordered_map<string,lli>
#define pb push_back
#define time ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define test lli t; cin>>t; while(t--)
using namespace std;
int gcd(int a,int b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
v adj[100001];
lli vist[10001];

void dfs(lli node)
{
    vist[node]=1;
    for(lli child : adj[node]) if(!vist[child]) dfs(child);
}

int main()
{
    time
    // lli t;
    // cin>>t;
    // while(t--)
    {
        lli n,k,ans=0;
        cin>>n>>k;
        um a;
        loop(i,0,n)
        {
            lli x;
            cin>>x;
            if(!a[x/k] || x%k) ans++,a[x]++;
        }
        cout<<ans<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define N 200005
#define ll long long
#define inf 0x3f3f3f3f

#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))

#define intq() int Qq;cin>>Qq;while(Qq--)
#define fo(i,n) for(int i=0;i<n;i++)

#define pr(x) cout<<x
#define prk() cout<<" "
#define prln() cout<<"\n"
#define sc(a) scanf("%lld",&a)
int m[N],a[N],p[N],s[N];
ll st=pow(10,9),n,k;
map<ll,ll>mp;
int xx(ll a){
	int s=0;
	for(ll i=a;i<st;){
		if(mp[i]>0){
			s++;mp[i]--;
		}
		else break;
		i*=k;
	}
	return (s+1)/2;
}
int main()
{
	cin>>n>>k;
	fo(i,n){
		cin>>a[i];
		mp[a[i]]++;
	}
	ll sum=0;
	fo(i,n)
		if(mp[a[i]]>0)sum+=xx(a[i]);
	cout<<sum;
}


#include<bits/stdc++.h>
using namespace std;
#define N 200005
#define ll long long
#define inf 0x3f3f3f3f

#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))

#define intq() int Qq;cin>>Qq;while(Qq--)
#define fo(i,n) for(int i=0;i<n;i++)

#define pr(x) cout<<x
#define prk() cout<<" "
#define prln() cout<<"\n"
#define sc(a) scanf("%lld",&a)
ll a[N];
ll st=pow(10,9),n,k;
map<ll,ll>mp;
int xx(ll a){
	ll dp=mp[a],dp2=mp[a*k];
	mp[a]=mp[a*k]=0;
	for(ll i=a*k*k;i<st;i*=k){
		dp=max(dp+mp[i],dp2);
		mp[i]=0;
		swap(dp,dp2);
	}
	return max(dp,dp2);
}
int main()
{
	cin>>n>>k;
	fo(i,n){
		cin>>a[i];
		mp[a[i]]++;
	}
	ll sum=0;
	if(k==1){
		fo(i,n)
			if(mp[a[i]]>0){
				sum++;mp[a[i]]=1;
			}
	}
	else
	fo(i,n)
		if(mp[a[i]]>0)sum+=xx(a[i]);
	cout<<sum;
}


#include<bits/stdc++.h>
using namespace std;
#define N 200005
#define ll long long
#define inf 0x3f3f3f3f

#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))

#define intq() int Qq;cin>>Qq;while(Qq--)
#define fo(i,n) for(int i=0;i<n;i++)

#define pr(x) cout<<x
#define prk() cout<<" "
#define prln() cout<<"\n"
#define sc(a) scanf("%lld",&a)
int m[N],a[N],p[N],s[N];
ll st=pow(10,9),n,k;
map<ll,ll>mp;
int xx(ll a){
	int s=1;
	for(ll i=a;i<st;){
		i*=k;
		if(mp[i]==1){
			s++;mp[i]=0;
		}
		else break;
	}
	return (s+1)/2;
}
int main()
{
	cin>>n>>k;
	fo(i,n){
		cin>>a[i];
		mp[a[i]]=1;
	}
	ll sum=0;
	fo(i,n)
		if(mp[a[i]]==1)sum+=xx(a[i]);
	cout<<sum;
}


#include<bits/stdc++.h>
using namespace std;
#define N 200005
#define ll long long
#define inf 0x3f3f3f3f

#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))

#define intq() int Qq;cin>>Qq;while(Qq--)
#define fo(i,n) for(int i=0;i<n;i++)

#define pr(x) cout<<x
#define prk() cout<<" "
#define prln() cout<<"\n"
#define sc(a) scanf("%lld",&a)
int m[N],a[N],p[N],s[N];
ll st=pow(10,9)+1,n,k;
map<ll,ll>mp;
int xx(ll a){
	ll s=0;
	for(ll i=a;i<st;i*=k){
		if(mp[i]>0){
			s++;mp[i]=0;
		}
		else break;
	}
	return (s+1)/2;
}
int main()
{
	cin>>n>>k;
	fo(i,n){
		cin>>a[i];
		mp[a[i]]=1;
	}
	ll sum=0;
	fo(i,n)
		if(mp[a[i]]>0)sum+=xx(a[i]);
	cout<<sum;
}


#include<bits/stdc++.h>
using namespace std;
#define N 200005
#define ll long long
#define inf 0x3f3f3f3f

#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))

#define intq() int Qq;cin>>Qq;while(Qq--)
#define fo(i,n) for(int i=0;i<n;i++)

#define pr(x) cout<<x
#define prk() cout<<" "
#define prln() cout<<"\n"
#define sc(a) scanf("%lld",&a)
ll a[N];
ll st=pow(10,9),n,k;
map<ll,ll>mp;
int xx(ll a){
	ll dp=mp[a],dp2=mp[a*k];
	mp[a]=mp[a*k]=0;
	for(ll i=a*k*k;i<st;i*=k){
		dp=max(dp+mp[i],dp2);
		mp[i]=0;
		swap(dp,dp2);
	}
	return max(dp,dp2);
}
int main()
{
	cin>>n>>k;
	fo(i,n){
		cin>>a[i];
		mp[a[i]]++;
	}
	ll sum=0;
	fo(i,n)
		if(mp[a[i]]>0)sum+=xx(a[i]);
	cout<<sum;
}


#include<bits/stdc++.h>
using namespace std;
#define N 200005
#define ll long long
#define inf 0x3f3f3f3f

#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))

#define intq() int Qq;cin>>Qq;while(Qq--)
#define fo(i,n) for(int i=0;i<n;i++)

#define pr(x) cout<<x
#define prk() cout<<" "
#define prln() cout<<"\n"
#define sc(a) scanf("%lld",&a)
int m[N],a[N],p[N],s[N];
ll st=pow(10,9)+1,n,k;
map<ll,ll>mp;
int xx(ll a){
	ll s=0;
	for(ll i=a;i<st;i*=k){
		if(mp[i]>0){
			s++;mp[i]=0;
		}
		else break;
	}
	return (s+1)/2;
}
int main()
{
	cin>>n>>k;
	fo(i,n){
		cin>>a[i];
		mp[a[i]]=1;
	}
	sort(a,a+n);
	ll sum=0;
	fo(i,n)
		if(mp[a[i]]>0)sum+=xx(a[i]);
	cout<<sum;
}


#include <bits/stdc++.h>
#define fin freopen("/home/imtiaz/Desktop/in.txt", "r", stdin)
#define fout freopen("/home/imtiaz/Desktop/out.txt","w", stdout)
#define dbg(x) cerr << #x << ": " << x << endl
#define fastio ios::sync_with_stdio (false); cin.tie (0);

#define ll long long
#define US unsigned short int
#define MP make_pair
#define FF first
#define SS second
#define MOD (1000000000+7)
#define M_PI 3.14159265358979323846
#define PLL pair<ll,ll>

#define PB push_back
#define LN cout<<"\n"
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define IN(x) cin>>x
#define INN(x,y) cin>>x>>y
#define INNN(x,y,z) cin>>x>>y>>z
#define INNNN(x,y,z,zz) cin>>x>>y>>z>>zz
#define OU(y) cout<<y<<" "
#define OUT(x) cout<<x<<"\n"
#define OUTT(x,y) cout<<x<<" "<<y<<"\n"
#define OUTTT(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define OUTTTT(x,y,z,zz) cout<<x<<" "<<y<<" "<<z<<" "<<zz<<"\n"

#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))

#define FOR(i,a,b)      for(auto i=a;i<=b;i++)
#define ROF(i,a,b)      for(auto i=a;i>=b;i--)
#define REP(i,b)        for(auto i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))
#define SORT(v)         sort(v.begin(),v.end())
#define RSORT(v)         sort(v.rbegin(),v.rend())
#define REV(v)          reverse(v.begin(),v.end())
#define AI(v,n)           for(ll i=0;i<n;i++) cin>>v[i]
#define AO(v,n)           for(ll i=0;i<n;i++) cout<<v[i]<<" "

using namespace std;

ll dr[]={-1, 1, 0, 0, -1, 1, -1, 1};
ll dc[]={0, 0, -1, 1, -1, -1, 1, 1};

int main(){
    ll n,k;
    INN(n,k);
    map<ll,ll> mp;
    ll a[n];
    for (ll i = 0; i < n; i++)
    {
        IN(a[i]);
        mp[a[i]]++;
    }
    ll ans=0;
    sort(a,a+n);
    for (ll i = 0; i < n; i++)
    {
        if(mp[a[i]]) {
            ans++;
            mp[a[i]*k]=0;
        }

    }
    OUT(ans);

    return 0;
}


#include <bits/stdc++.h>
#define fin freopen("/home/imtiaz/Desktop/in.txt", "r", stdin)
#define fout freopen("/home/imtiaz/Desktop/out.txt","w", stdout)
#define dbg(x) cerr << #x << ": " << x << endl
#define fastio ios::sync_with_stdio (false); cin.tie (0);

#define ll long long
#define US unsigned short int
#define MP make_pair
#define FF first
#define SS second
#define MOD (1000000000+7)
#define M_PI 3.14159265358979323846
#define PLL pair<ll,ll>

#define PB push_back
#define LN cout<<"\n"
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define IN(x) cin>>x
#define INN(x,y) cin>>x>>y
#define INNN(x,y,z) cin>>x>>y>>z
#define INNNN(x,y,z,zz) cin>>x>>y>>z>>zz
#define OU(y) cout<<y<<" "
#define OUT(x) cout<<x<<"\n"
#define OUTT(x,y) cout<<x<<" "<<y<<"\n"
#define OUTTT(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define OUTTTT(x,y,z,zz) cout<<x<<" "<<y<<" "<<z<<" "<<zz<<"\n"

#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))

#define FOR(i,a,b)      for(auto i=a;i<=b;i++)
#define ROF(i,a,b)      for(auto i=a;i>=b;i--)
#define REP(i,b)        for(auto i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))
#define SORT(v)         sort(v.begin(),v.end())
#define RSORT(v)         sort(v.rbegin(),v.rend())
#define REV(v)          reverse(v.begin(),v.end())
#define AI(v,n)           for(ll i=0;i<n;i++) cin>>v[i]
#define AO(v,n)           for(ll i=0;i<n;i++) cout<<v[i]<<" "

using namespace std;

ll dr[]={-1, 1, 0, 0, -1, 1, -1, 1};
ll dc[]={0, 0, -1, 1, -1, -1, 1, 1};

int main(){
    ll n,k;
    INN(n,k);
    map<ll,ll> mp;
    ll a[n];
    for (ll i = 0; i < n; i++)
    {
        IN(a[i]);
        mp[a[i]]++;
    }
    ll ans=0;
    for (ll i = 0; i < n; i++)
    {
        if(mp[a[i]]) ans++;
        mp[a[i]*k]=0;
    }
    OUT(ans);

    return 0;
}


#include <bits/stdc++.h>
#define fin freopen("/home/imtiaz/Desktop/in.txt", "r", stdin)
#define fout freopen("/home/imtiaz/Desktop/out.txt","w", stdout)
#define dbg(x) cerr << #x << ": " << x << endl
#define fastio ios::sync_with_stdio (false); cin.tie (0);

#define ll long long
#define US unsigned short int
#define MP make_pair
#define FF first
#define SS second
#define MOD (1000000000+7)
#define M_PI 3.14159265358979323846
#define PLL pair<ll,ll>

#define PB push_back
#define LN cout<<"\n"
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define IN(x) cin>>x
#define INN(x,y) cin>>x>>y
#define INNN(x,y,z) cin>>x>>y>>z
#define INNNN(x,y,z,zz) cin>>x>>y>>z>>zz
#define OU(y) cout<<y<<" "
#define OUT(x) cout<<x<<"\n"
#define OUTT(x,y) cout<<x<<" "<<y<<"\n"
#define OUTTT(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define OUTTTT(x,y,z,zz) cout<<x<<" "<<y<<" "<<z<<" "<<zz<<"\n"

#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))

#define FOR(i,a,b)      for(auto i=a;i<=b;i++)
#define ROF(i,a,b)      for(auto i=a;i>=b;i--)
#define REP(i,b)        for(auto i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))
#define SORT(v)         sort(v.begin(),v.end())
#define RSORT(v)         sort(v.rbegin(),v.rend())
#define REV(v)          reverse(v.begin(),v.end())
#define AI(v,n)           for(ll i=0;i<n;i++) cin>>v[i]
#define AO(v,n)           for(ll i=0;i<n;i++) cout<<v[i]<<" "

using namespace std;

ll dr[]={-1, 1, 0, 0, -1, 1, -1, 1};
ll dc[]={0, 0, -1, 1, -1, -1, 1, 1};

int main(){
    ll n,k;
    INN(n,k);
    map<ll,ll> mp;
    ll a[n];
    for (ll i = 0; i < n; i++)
    {
        IN(a[i]);
        mp[a[i]]++;
    }
    ll ans=0;
    SORT(a);
    for (ll i = 0; i < n; i++)
    {
        if(mp[a[i]]) ans++;
        mp[a[i]*k]=0;
    }
    OUT(ans);

    return 0;
}


#include <bits/stdc++.h>
#define fin freopen("/home/imtiaz/Desktop/in.txt", "r", stdin)
#define fout freopen("/home/imtiaz/Desktop/out.txt","w", stdout)
#define dbg(x) cerr << #x << ": " << x << endl
#define fastio ios::sync_with_stdio (false); cin.tie (0);

#define ll long long
#define US unsigned short int
#define MP make_pair
#define FF first
#define SS second
#define MOD (1000000000+7)
#define M_PI 3.14159265358979323846
#define PLL pair<ll,ll>

#define PB push_back
#define LN cout<<"\n"
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define IN(x) cin>>x
#define INN(x,y) cin>>x>>y
#define INNN(x,y,z) cin>>x>>y>>z
#define INNNN(x,y,z,zz) cin>>x>>y>>z>>zz
#define OU(y) cout<<y<<" "
#define OUT(x) cout<<x<<"\n"
#define OUTT(x,y) cout<<x<<" "<<y<<"\n"
#define OUTTT(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define OUTTTT(x,y,z,zz) cout<<x<<" "<<y<<" "<<z<<" "<<zz<<"\n"

#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))

#define FOR(i,a,b)      for(auto i=a;i<=b;i++)
#define ROF(i,a,b)      for(auto i=a;i>=b;i--)
#define REP(i,b)        for(auto i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))
#define SORT(v)         sort(v.begin(),v.end())
#define RSORT(v)         sort(v.rbegin(),v.rend())
#define REV(v)          reverse(v.begin(),v.end())
#define AI(v,n)           for(ll i=0;i<n;i++) cin>>v[i]
#define AO(v,n)           for(ll i=0;i<n;i++) cout<<v[i]<<" "

using namespace std;

ll dr[]={-1, 1, 0, 0, -1, 1, -1, 1};
ll dc[]={0, 0, -1, 1, -1, -1, 1, 1};

int main(){
    ll n,k;
    INN(n,k);
    map<ll,ll> mp;
    ll a[n];
    for (ll i = 0; i < n; i++)
    {
        IN(a[i]);
        mp[a[i]]++;
    }
    ll ans=0;
    sort(a,a+n);
    for (ll i = 0; i < n; i++)
    {
        if(mp[a[i]]) ans++;
        mp[a[i]*k]=0;
    }
    OUT(ans);

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define tk printf("Case %d:\n",q++)
#define READ freopen("input.txt","r",stdin);
#define WRITE freopen("output.txt","w",stdout);
#define sf(x) scanf("%lld",&x)
#define sff(x,y) scanf("%lld %lld",&x,&y)
#define sfff(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define fori(x,y) for(ll i=x;i<y;i++)
#define forj(x,y) for(ll j=x;j<y;j++)
#define eachs(y) for(auto &x:y)cin>>x
#define each(y) for(auto x:y)
#define eachp(y) for(auto x:y)cout<<x<<" ";cout<<endl;
#define fs(y) for(auto &x:y)cin>>x
#define fp(y) for(auto x:y)cout<<x<<" "
#define pb push_back
#define pf push_front
#define ff first
#define ss second
#define pi acos(-1.0)
#define inf  LLONG_MAX
#define testcase ll t;sf(t);
#define flash fflush(stdout)
#define all(x) x.begin(),x.end()
#define debug(a) cout<<#a<<": ";for(auto i:a)cout<<i<<" ";cout<<'\n';

typedef long long ll;
typedef unsigned long long llu;
typedef pair<ll,ll> pii;
typedef vector<ll> vl;
typedef vector<int> vi;
int xx[4]={0,0,1,-1};
int yy[4]={-1,1,0,0};

int main()
{

       #ifndef ONLINE_JUDGE
		READ
		WRITE
       #endif
		ll n,m;
		sff(n,m);
		map<ll,ll>mp;
		vector<ll>vec(n);
		fori(0,n)cin>>vec[i];
		fori(0,n)mp[vec[i]]=1;
		ll res=0;
		sort(all(vec),greater<ll>());
		fori(0,n){
			if(vec[i]%m!=0 &&mp[vec[i]]==1 )res++;
			else if(mp[vec[i]]==1 && mp[vec[i]/m]==1){

			if((vec[i]/m)%m==0 && mp[(vec[i]/m)/m]==1){mp[vec[i]/m]=2;res++;}

		}
		}
		cout<<res<<endl;
 	return 0;
 }


#include<bits/stdc++.h>
using namespace std;
#define tk printf("Case %d:\n",q++)
#define READ freopen("input.txt","r",stdin);
#define WRITE freopen("output.txt","w",stdout);
#define sf(x) scanf("%lld",&x)
#define sff(x,y) scanf("%lld %lld",&x,&y)
#define sfff(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define fori(x,y) for(ll i=x;i<y;i++)
#define forj(x,y) for(ll j=x;j<y;j++)
#define eachs(y) for(auto &x:y)cin>>x
#define each(y) for(auto x:y)
#define eachp(y) for(auto x:y)cout<<x<<" ";cout<<endl;
#define fs(y) for(auto &x:y)cin>>x
#define fp(y) for(auto x:y)cout<<x<<" "
#define pb push_back
#define pf push_front
#define ff first
#define ss second
#define pi acos(-1.0)
#define inf  LLONG_MAX
#define testcase ll t;sf(t);
#define flash fflush(stdout)
#define all(x) x.begin(),x.end()
#define debug(a) cout<<#a<<": ";for(auto i:a)cout<<i<<" ";cout<<'\n';

typedef long long ll;
typedef unsigned long long llu;
typedef pair<ll,ll> pii;
typedef vector<ll> vl;
typedef vector<int> vi;
int xx[4]={0,0,1,-1};
int yy[4]={-1,1,0,0};

int main()
{

       #ifndef ONLINE_JUDGE
		READ
		WRITE
       #endif
		ll n,m;
		sff(n,m);
		map<ll,ll>mp;
		vector<ll>vec(n);
		fori(0,n)cin>>vec[i];
		fori(0,n)mp[vec[i]*m]=1;
		ll res=0;
		fori(0,n)if(mp[vec[i]]==1 && vec[i]/m <vec[i])res++;
		cout<<n-res<<endl;
 	return 0;
 }


#include<bits/stdc++.h>
using namespace std;
#define tk printf("Case %d:\n",q++)
#define READ freopen("input.txt","r",stdin);
#define WRITE freopen("output.txt","w",stdout);
#define sf(x) scanf("%lld",&x)
#define sff(x,y) scanf("%lld %lld",&x,&y)
#define sfff(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define fori(x,y) for(ll i=x;i<y;i++)
#define forj(x,y) for(ll j=x;j<y;j++)
#define eachs(y) for(auto &x:y)cin>>x
#define each(y) for(auto x:y)
#define eachp(y) for(auto x:y)cout<<x<<" ";cout<<endl;
#define fs(y) for(auto &x:y)cin>>x
#define fp(y) for(auto x:y)cout<<x<<" "
#define pb push_back
#define pf push_front
#define ff first
#define ss second
#define pi acos(-1.0)
#define inf  LLONG_MAX
#define testcase ll t;sf(t);
#define flash fflush(stdout)
#define all(x) x.begin(),x.end()
#define debug(a) cout<<#a<<": ";for(auto i:a)cout<<i<<" ";cout<<'\n';

typedef long long ll;
typedef unsigned long long llu;
typedef pair<ll,ll> pii;
typedef vector<ll> vl;
typedef vector<int> vi;
int xx[4]={0,0,1,-1};
int yy[4]={-1,1,0,0};

int main()
{

       #ifndef ONLINE_JUDGE
		READ
		WRITE
       #endif
		ll n,m;
		sff(n,m);
		map<ll,ll>mp;
		vector<ll>vec(n);
		fori(0,n)cin>>vec[i];
		fori(0,n)mp[vec[i]]=1;
		ll res=0;
		sort(all(vec),greater<ll>());
		fori(0,n){
			if(vec[i]%m!=0 &&mp[vec[i]]==1 )res++;
			else if(mp[vec[i]]==1){

			  if(vec[i]%m==0 && mp[vec[i]/m]==1){
			  	if((vec[i]/m)%m==0 && mp[(vec[i]/m)/m]==1){
			  		mp[vec[i]/m]=2;
			  		res++;
			  	}

			  }
			  else res++;

		}
		}
		cout<<res<<endl;
 	return 0;
 }


#include<bits/stdc++.h>
using namespace std;
#define tk printf("Case %d:\n",q++)
#define READ freopen("input.txt","r",stdin);
#define WRITE freopen("output.txt","w",stdout);
#define sf(x) scanf("%lld",&x)
#define sff(x,y) scanf("%lld %lld",&x,&y)
#define sfff(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define fori(x,y) for(ll i=x;i<y;i++)
#define forj(x,y) for(ll j=x;j<y;j++)
#define eachs(y) for(auto &x:y)cin>>x
#define each(y) for(auto x:y)
#define eachp(y) for(auto x:y)cout<<x<<" ";cout<<endl;
#define fs(y) for(auto &x:y)cin>>x
#define fp(y) for(auto x:y)cout<<x<<" "
#define pb push_back
#define pf push_front
#define ff first
#define ss second
#define pi acos(-1.0)
#define inf  LLONG_MAX
#define testcase ll t;sf(t);
#define flash fflush(stdout)
#define all(x) x.begin(),x.end()
#define debug(a) cout<<#a<<": ";for(auto i:a)cout<<i<<" ";cout<<'\n';

typedef long long ll;
typedef unsigned long long llu;
typedef pair<ll,ll> pii;
typedef vector<ll> vl;
typedef vector<int> vi;
int xx[4]={0,0,1,-1};
int yy[4]={-1,1,0,0};

int main()
{

       #ifndef ONLINE_JUDGE
		READ
		WRITE
       #endif
		ll n,m;
		sff(n,m);
		map<ll,ll>mp;
		vector<ll>vec(n);
		fori(0,n)cin>>vec[i];
		fori(0,n)mp[vec[i]*m]=1;
		ll res=0;
		fori(0,n)if(mp[vec[i]]==1)res++;
		cout<<res<<endl;
 	return 0;
 }


#include<bits/stdc++.h>
using namespace std;
#define tk printf("Case %d:\n",q++)
#define READ freopen("input.txt","r",stdin);
#define WRITE freopen("output.txt","w",stdout);
#define sf(x) scanf("%lld",&x)
#define sff(x,y) scanf("%lld %lld",&x,&y)
#define sfff(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define fori(x,y) for(ll i=x;i<y;i++)
#define forj(x,y) for(ll j=x;j<y;j++)
#define eachs(y) for(auto &x:y)cin>>x
#define each(y) for(auto x:y)
#define eachp(y) for(auto x:y)cout<<x<<" ";cout<<endl;
#define fs(y) for(auto &x:y)cin>>x
#define fp(y) for(auto x:y)cout<<x<<" "
#define pb push_back
#define pf push_front
#define ff first
#define ss second
#define pi acos(-1.0)
#define inf  LLONG_MAX
#define testcase ll t;sf(t);
#define flash fflush(stdout)
#define all(x) x.begin(),x.end()
#define debug(a) cout<<#a<<": ";for(auto i:a)cout<<i<<" ";cout<<'\n';

typedef long long ll;
typedef unsigned long long llu;
typedef pair<ll,ll> pii;
typedef vector<ll> vl;
typedef vector<int> vi;
int xx[4]={0,0,1,-1};
int yy[4]={-1,1,0,0};

int main()
{

       #ifndef ONLINE_JUDGE
		READ
		WRITE
       #endif
		ll n,m;
		sff(n,m);
		map<ll,ll>mp;
		vector<ll>vec(n);
		fori(0,n)cin>>vec[i];
		fori(0,n)mp[vec[i]]=1;
		ll res=0;
		sort(all(vec),greater<ll>());
		fori(0,n){
			if(vec[i]%m!=0 &&mp[vec[i]]==1 )res++;
			else if(mp[vec[i]]==1 && mp[vec[i]/m]==1){
			res++;
			mp[vec[i]/m]=2;
		}
		}
		cout<<res<<endl;
 	return 0;
 }


#include<bits/stdc++.h>
using namespace std;
#define tk printf("Case %d:\n",q++)
#define READ freopen("input.txt","r",stdin);
#define WRITE freopen("output.txt","w",stdout);
#define sf(x) scanf("%lld",&x)
#define sff(x,y) scanf("%lld %lld",&x,&y)
#define sfff(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define fori(x,y) for(ll i=x;i<y;i++)
#define forj(x,y) for(ll j=x;j<y;j++)
#define eachs(y) for(auto &x:y)cin>>x
#define each(y) for(auto x:y)
#define eachp(y) for(auto x:y)cout<<x<<" ";cout<<endl;
#define fs(y) for(auto &x:y)cin>>x
#define fp(y) for(auto x:y)cout<<x<<" "
#define pb push_back
#define pf push_front
#define ff first
#define ss second
#define pi acos(-1.0)
#define inf  LLONG_MAX
#define testcase ll t;sf(t);
#define flash fflush(stdout)
#define all(x) x.begin(),x.end()
#define debug(a) cout<<#a<<": ";for(auto i:a)cout<<i<<" ";cout<<'\n';

typedef long long ll;
typedef unsigned long long llu;
typedef pair<ll,ll> pii;
typedef vector<ll> vl;
typedef vector<int> vi;
int xx[4]={0,0,1,-1};
int yy[4]={-1,1,0,0};

int main()
{

       #ifndef ONLINE_JUDGE
		READ
		WRITE
       #endif
		ll n,m;
		sff(n,m);
		map<ll,ll>mp;
		vector<ll>vec(n);
		fori(0,n)cin>>vec[i];
		fori(0,n)mp[vec[i]*m]=1;
		ll res=0;
		fori(0,n)if(mp[vec[i]]==1 && vec[i]/m <vec[i])res++;
		cout<<res<<endl;
 	return 0;
 }


// Problem: A. k-Multiple Free Set
// Contest: Codeforces - Codeforces Round #168 (Div. 1)
// URL: https://codeforces.com/problemset/problem/274/A
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// Muallif: Azimjon Mehmonali o'g'li

#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define int long long

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

#define F first
#define S second
#define pb push_back
#define endl "\n"

#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SORT(a) sort(ALL(a))
#define rSORT(a) sort(rALL(a))
#define REV(a) reverse(ALL(a))
#define sqr(x) ((x) * (x))

//=========================================================
int recur_depth = 0;
#ifdef DEBUG
#define xtp(x)                                                           \
	{                                                                    \
		++recur_depth;                                                   \
		auto x_ = x;                                                     \
		--recur_depth;                                                   \
		cerr << string(recur_depth, '\t') << __func__ << ":" << __LINE__ \
			 << "\t" << #x << " = " << x_ << endl;                       \
	}
#else
#define xtp(x)
#endif
template <typename Ostream, typename Cont>
typename enable_if<is_same<Ostream, ostream>::value, Ostream&>::type operator<<(
	Ostream& os, const Cont& v) {
	os << "[";
	for (auto& x : v) {
		os << x << ", ";
	}
	return os << "]";
}
template <typename Ostream, typename... Ts>
Ostream& operator<<(Ostream& os, const pair<Ts...>& p) {
	return os << "{" << p.first << ", " << p.second << "}";
}
//=========================================================

#define TEZ                  \
	ios::sync_with_stdio(0); \
	cin.tie(0);

const long double PI = 3.1415926535897;
const int mod = 1000000007LL;
const int INF = 1e18;

signed main() {
	TEZ;

	int n, k;
	cin >> n >> k;

	vi a(n);
	set<int> s;

	for (int& i : a)
		cin >> i, s.insert(i);

	for (int i : a) {
		if (i % k == 0) {
			s.erase(i / k);
		}
	}

	cout << max((int)s.size(), n - (int)s.size()) << endl;

	return 0;
}


// Problem: A. k-Multiple Free Set
// Contest: Codeforces - Codeforces Round #168 (Div. 1)
// URL: https://codeforces.com/problemset/problem/274/A
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// Muallif: Azimjon Mehmonali o'g'li

#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define int long long

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

#define F first
#define S second
#define pb push_back
#define endl "\n"

#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SORT(a) sort(ALL(a))
#define rSORT(a) sort(rALL(a))
#define REV(a) reverse(ALL(a))
#define sqr(x) ((x) * (x))

//=========================================================
int recur_depth = 0;
#ifdef DEBUG
#define xtp(x)                                                           \
	{                                                                    \
		++recur_depth;                                                   \
		auto x_ = x;                                                     \
		--recur_depth;                                                   \
		cerr << string(recur_depth, '\t') << __func__ << ":" << __LINE__ \
			 << "\t" << #x << " = " << x_ << endl;                       \
	}
#else
#define xtp(x)
#endif
template <typename Ostream, typename Cont>
typename enable_if<is_same<Ostream, ostream>::value, Ostream&>::type operator<<(
	Ostream& os, const Cont& v) {
	os << "[";
	for (auto& x : v) {
		os << x << ", ";
	}
	return os << "]";
}
template <typename Ostream, typename... Ts>
Ostream& operator<<(Ostream& os, const pair<Ts...>& p) {
	return os << "{" << p.first << ", " << p.second << "}";
}
//=========================================================

#define TEZ                  \
	ios::sync_with_stdio(0); \
	cin.tie(0);

const long double PI = 3.1415926535897;
const int mod = 1000000007LL;
const int INF = 1e18;

signed main() {
	TEZ;

	int n, k;
	cin >> n >> k;

	vi a(n);
	set<int> s;

	for (int& i : a)
		cin >> i, s.insert(i);

	for (int i : a) {
		if (i % k == 0) {
			s.erase(i / k);
		}
	}

	cout << max((ull)s.size(), n - s.size()) << endl;

	return 0;
}


// Problem: A. k-Multiple Free Set
// Contest: Codeforces - Codeforces Round #168 (Div. 1)
// URL: https://codeforces.com/problemset/problem/274/A
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// Muallif: Azimjon Mehmonali o'g'li

#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define int long long

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

#define F first
#define S second
#define pb push_back
#define endl "\n"

#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SORT(a) sort(ALL(a))
#define rSORT(a) sort(rALL(a))
#define REV(a) reverse(ALL(a))
#define sqr(x) ((x) * (x))

//=========================================================
int recur_depth = 0;
#ifdef DEBUG
#define xtp(x)                                                           \
	{                                                                    \
		++recur_depth;                                                   \
		auto x_ = x;                                                     \
		--recur_depth;                                                   \
		cerr << string(recur_depth, '\t') << __func__ << ":" << __LINE__ \
			 << "\t" << #x << " = " << x_ << endl;                       \
	}
#else
#define xtp(x)
#endif
template <typename Ostream, typename Cont>
typename enable_if<is_same<Ostream, ostream>::value, Ostream&>::type operator<<(
	Ostream& os, const Cont& v) {
	os << "[";
	for (auto& x : v) {
		os << x << ", ";
	}
	return os << "]";
}
template <typename Ostream, typename... Ts>
Ostream& operator<<(Ostream& os, const pair<Ts...>& p) {
	return os << "{" << p.first << ", " << p.second << "}";
}
//=========================================================

#define TEZ                  \
	ios::sync_with_stdio(0); \
	cin.tie(0);

const long double PI = 3.1415926535897;
const int mod = 1000000007LL;
const int INF = 1e18;

signed main() {
	TEZ;

	int n, k;
	cin >> n >> k;

	vi a(n);
	set<int> s;

	for (int& i : a)
		cin >> i, s.insert(i);

	for (int i : a) {
		if (i % k == 0) {
			s.erase(i / k);
		}
	}

	cout << max(s.size(), n - s.size()) << endl;

	return 0;
}


// Problem: A. k-Multiple Free Set
// Contest: Codeforces - Codeforces Round #168 (Div. 1)
// URL: https://codeforces.com/problemset/problem/274/A
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// Muallif: Azimjon Mehmonali o'g'li

#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define int long long

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

#define F first
#define S second
#define pb push_back
#define endl "\n"

#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SORT(a) sort(ALL(a))
#define rSORT(a) sort(rALL(a))
#define REV(a) reverse(ALL(a))
#define sqr(x) ((x) * (x))

//=========================================================
int recur_depth = 0;
#ifdef DEBUG
#define xtp(x)                                                           \
	{                                                                    \
		++recur_depth;                                                   \
		auto x_ = x;                                                     \
		--recur_depth;                                                   \
		cerr << string(recur_depth, '\t') << __func__ << ":" << __LINE__ \
			 << "\t" << #x << " = " << x_ << endl;                       \
	}
#else
#define xtp(x)
#endif
template <typename Ostream, typename Cont>
typename enable_if<is_same<Ostream, ostream>::value, Ostream&>::type operator<<(
	Ostream& os, const Cont& v) {
	os << "[";
	for (auto& x : v) {
		os << x << ", ";
	}
	return os << "]";
}
template <typename Ostream, typename... Ts>
Ostream& operator<<(Ostream& os, const pair<Ts...>& p) {
	return os << "{" << p.first << ", " << p.second << "}";
}
//=========================================================

#define TEZ                  \
	ios::sync_with_stdio(0); \
	cin.tie(0);

const long double PI = 3.1415926535897;
const int mod = 1000000007LL;
const int INF = 1e18;

signed main() {
	TEZ;

	int n, k;
	cin >> n >> k;

	vi a(n);
	multiset<int> s;

	for (int& i : a)
		cin >> i, s.insert(i);

	for (int i : a) {
		if (i % k == 0) {
			s.erase(i / k);
		}
	}

	cout << s.size() << endl;

	return 0;
}


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

ll arr[100000];

ll bsearch(ll l, ll r, ll n) {
	while (l <= r) {
		ll mid = (l + r) / 2;

		if (arr[mid] == n)
			return mid;
		else if (arr[mid] > n)
			r = mid - 1;
		else
			l = mid + 1;
	}
	return -1;
}

int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll n, k;
	cin >> n >> k;
	for (ll i = 0; i < n; i++) {
		cin >> arr[i];
	}
	sort(arr, arr + n);
	ll mark[n] = {0};
	ll gr1 = 0, gr2 = 0;

	for (ll i = 0; i < n; i++) {
		if (mark[i] == 1) continue;
		mark[i] = 1;
		gr1++;
		ll ind = bsearch(i + 1, n - 1, k * arr[i]);

		if (ind != -1) {
			mark[ind] = 1;
			gr2++;
		}
	}
	cout << max(gr1, gr2) << endl;

	return 0;
}


#include <iostream>
#include <vector>
#include <math.h>
#include <iomanip>
#include <map>
#include <algorithm>
#include <set>
#include <string.h>
#include <stdio.h>
#include <queue>
#include <stack>
using namespace std;

int main()
{
    int k,n;
    cin>>n>>k;
    set<int> fir;
    set<int> sec;
    for(int i =0;i<n;i++)
    {
        int x;
        cin>>x;
        set<int> dop = fir;
        dop.insert(x*2);
        if(dop.size() == fir.size())
        {
            continue;
        }

        dop = sec;
        dop.insert(x);

        if(dop.size() == sec.size())
        {
            continue;
        }
        fir.insert(x);
        sec.insert(x*2);

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

}


#include <iostream>
#include <vector>
#include <math.h>
#include <iomanip>
#include <map>
#include <algorithm>
#include <set>
#include <string.h>
#include <stdio.h>
#include <queue>
#include <stack>
using namespace std;

int main()
{
    int k,n;
    cin>>n>>k;
    map<int,int> fir;
    map<int,int> sec;

    for(int i =0;i<n;i++)
    {
        int x;
        cin>>x;
        if(fir[x*k] == 1)
        {
          //  cout<<fir.size()<<endl;
            fir.erase(k*x);
           // cout<<fir.size()<<endl;
            continue;
        }
        if(fir[x*k] == 0)
               fir.erase(k*x);

        if(sec[x] == 1)
        {
            //  cout<<fir.size()<<endl;
            fir.erase(k*x);
          //  cout<<fir.size()<<endl;

            sec.erase(x);
            continue;
        }
        fir[x] = 1;
        sec[x*k] =1;
        if(sec[x] == 0)
               sec.erase(x);
    }
    cout<<fir.size()<<endl;

}


#include <iostream>
#include <vector>
#include <math.h>
#include <iomanip>
#include <map>
#include <algorithm>
#include <set>
#include <string.h>
#include <stdio.h>
#include <queue>
#include <stack>
using namespace std;

int main()
{
    int k,n;
    cin>>n>>k;
    map<int,int> fir;
    map<int,int> sec;

    for(int i =0;i<n;i++)
    {
        int x;
        cin>>x;
        if(fir[x*2] == 1)
        {
          //  cout<<fir.size()<<endl;
            fir.erase(2*x);
           // cout<<fir.size()<<endl;
            continue;
        }
        if(fir[x*2] == 0)
               fir.erase(2*x);

        if(sec[x] == 1)
        {
            //  cout<<fir.size()<<endl;
            fir.erase(2*x);
          //  cout<<fir.size()<<endl;

            sec.erase(x);
            continue;
        }
        fir[x] = 1;
        sec[x*2] =1;
        if(sec[x] == 0)
               sec.erase(x);
    }
    cout<<fir.size()<<endl;

}


#include <iostream>
#include <vector>
#include <math.h>
#include <iomanip>
#include <map>
#include <algorithm>
#include <set>
#include <string.h>
#include <stdio.h>
#include <queue>
#include <stack>
using namespace std;
typedef long long ll;
int main()
{
    int k,n;
    cin>>n>>k;
    map<ll,ll> fir;
    map<ll,ll> sec;

    for(int i =0;i<n;i++)
    {
        ll x;
        cin>>x;
        if(fir[x*k] == 1)
        {
            continue;
        }
        if(fir[x*k] == 0)
               fir.erase(k*x);

        if(sec[x] == 1)
        {
            continue;
        }

        if(sec[x] == 0)
               sec.erase(x);
        fir[x] = 1;
        sec[x*k] =1;
    }
    cout<<fir.size()<<endl;

}


#include <iostream>
#include <vector>
#include <math.h>
#include <iomanip>
#include <map>
#include <algorithm>
#include <set>
#include <string.h>
#include <stdio.h>
#include <queue>
#include <stack>
using namespace std;
typedef long long ll;
int main()
{
    int k,n;
    cin>>n>>k;
    map<ll,ll> fir;
    map<ll,ll> sec;

    for(int i =0;i<n;i++)
    {
        ll x;
        cin>>x;
        if(fir[x*k] == 1)
        {
          //  cout<<fir.size()<<endl;
            fir.erase(k*x);
           // cout<<fir.size()<<endl;
            continue;
        }
        if(fir[x*k] == 0)
               fir.erase(k*x);

        if(sec[x] == 1)
        {
            //  cout<<fir.size()<<endl;
            fir.erase(k*x);
          //  cout<<fir.size()<<endl;

            sec.erase(x);
            continue;
        }
        fir[x] = 1;
        sec[x*k] =1;
        if(sec[x] == 0)
               sec.erase(x);
    }
    cout<<fir.size()<<endl;

}


#include <iostream>
#include <vector>
#include <math.h>
#include <iomanip>
#include <map>
#include <algorithm>
#include <set>
#include <string.h>
#include <stdio.h>
#include <queue>
#include <stack>
using namespace std;

int main()
{
    int k,n;
    cin>>n>>k;
    map<int,int> fir;
    map<int,int> sec;
    for(int i =0;i<n;i++)
    {
        int x;
        cin>>x;
        map<int,int> dop = fir;
        dop[x*2] =1;
        if(dop.size() == fir.size())
        {
            continue;
        }

        dop = sec;
        dop[x] = 1;

        if(dop.size() == sec.size())
        {
            continue;
        }
        fir[x] =1;
        sec[x*2] =1;

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

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fill fill_n
#define vli vector<ll>
#define pb push_back
#define comp(v) v.begin(),v.end()
#define ff first
#define ss second
#define infile freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
const int M = 1e9+7;
const int N = 2e5;
ll po(int a,int b){
    if(b==0) return 1;
    ll ans=1;
    if(b%2==0){
        ans = po(a,b/2)%M;
        ans=(ans%M * ans%M)%M;
    }
    else{
        ans = po(a,(b-1)/2)%M;
        ans = (ans%M * ans%M * a)%M;
    }
    return ans%M;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll x[n];
    set<ll> s;
    for(int i=0;i<n;i++){
        cin>>x[i];
        s.insert(x[i]);
    }
    for(int i=0;i<n;i++){
        auto it = s.find(k*x[i]);
        if(it != s.end()){
            s.erase(it);
        }
    }
    cout<<s.size()<<"\n";

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fill fill_n
#define vli vector<ll>
#define pb push_back
#define comp(v) v.begin(),v.end()
#define ff first
#define ss second
#define infile freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
const int M = 1e9+7;
const int N = 2e5;
ll po(int a,int b){
    if(b==0) return 1;
    ll ans=1;
    if(b%2==0){
        ans = po(a,b/2)%M;
        ans=(ans%M * ans%M)%M;
    }
    else{
        ans = po(a,(b-1)/2)%M;
        ans = (ans%M * ans%M * a)%M;
    }
    return ans%M;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll x[n];
    set<ll> s;
    for(int i=0;i<n;i++){
        cin>>x[i];
        s.insert(x[i]);
    }
    for(int i=0;i<n;i++){
       auto it1 = s.find(x[i]);

       if(it1!=s.end()){
        auto it = s.find(k*x[i]);
        if(it != s.end()){
            s.erase(it);
        }
       }
    }
    if(n==1) cout<<1<<"\n";
    else
    cout<<s.size()<<"\n";

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fill fill_n
#define vli vector<ll>
#define pb push_back
#define comp(v) v.begin(),v.end()
#define ff first
#define ss second
#define infile freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
const int M = 1e9+7;
const int N = 2e5;
ll po(int a,int b){
    if(b==0) return 1;
    ll ans=1;
    if(b%2==0){
        ans = po(a,b/2)%M;
        ans=(ans%M * ans%M)%M;
    }
    else{
        ans = po(a,(b-1)/2)%M;
        ans = (ans%M * ans%M * a)%M;
    }
    return ans%M;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll x[n];
    set<ll> s;
    for(int i=0;i<n;i++){
        cin>>x[i];

    }
    sort(x,x+n);
    for(int i=0;i<n;i++){
        s.insert(x[i]);
    }
    for(int i=0;i<n;i++){
       auto it1 = s.find(x[i]);

       if(it1!=s.end()){
        auto it = s.find(k*x[i]);
        if(it != s.end()){
            s.erase(it);
        }
       }
    }
    if(n==1) cout<<1<<"\n";
    else
    cout<<s.size()<<"\n";

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fill fill_n
#define vli vector<ll>
#define pb push_back
#define comp(v) v.begin(),v.end()
#define ff first
#define ss second
#define infile freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
const int M = 1e9+7;
const int N = 2e5;
ll po(int a,int b){
    if(b==0) return 1;
    ll ans=1;
    if(b%2==0){
        ans = po(a,b/2)%M;
        ans=(ans%M * ans%M)%M;
    }
    else{
        ans = po(a,(b-1)/2)%M;
        ans = (ans%M * ans%M * a)%M;
    }
    return ans%M;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll x[n];
    set<ll> s;
    for(int i=0;i<n;i++){
        cin>>x[i];
        s.insert(x[i]);
    }
    for(int i=0;i<n;i++){
       auto it1 = s.find(x[i]);

       if(it1!=s.end()){
        auto it = s.find(k*x[i]);
        if(it != s.end()){
            s.erase(it);
        }
       }
    }
    cout<<s.size()<<"\n";

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fill fill_n
#define vli vector<ll>
#define pb push_back
#define comp(v) v.begin(),v.end()
#define ff first
#define ss second
#define infile freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
const int M = 1e9+7;
const int N = 2e5;
ll po(int a,int b){
    if(b==0) return 1;
    ll ans=1;
    if(b%2==0){
        ans = po(a,b/2)%M;
        ans=(ans%M * ans%M)%M;
    }
    else{
        ans = po(a,(b-1)/2)%M;
        ans = (ans%M * ans%M * a)%M;
    }
    return ans%M;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll x[n];
    set<ll> s;
    for(int i=0;i<n;i++){
        cin>>x[i];

    }
    sort(x,x+n);
    for(int i=0;i<n;i++){
        s.insert(x[i]);
    }
    for(int i=0;i<n;i++){
       auto it1 = s.find(x[i]);

       if(it1!=s.end()){
        auto it = s.find(k*x[i]);
        if(it != s.end()){
            s.erase(it);
        }
       }
    }
    if(n==1) cout<<1<<"\n";
    else if(k==1) cout<<n<<"\n";
    else
    cout<<s.size()<<"\n";

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 10;
const int INF = 1e9;
const double EPS = 1e-10;
const double PI = acosl(-1);

#define int long long

signed main() {
    //freopen("beasts.in", "r", stdin);
    //freopen("beasts.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k, cnt = 1;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] % k != 0)
            cnt++;
    }
    cout << cnt;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 10;
const int INF = 1e9;
const double EPS = 1e-10;
const double PI = acosl(-1);

#define int long double

map<int, int> used;

signed main() {
    //freopen("beasts.in", "r", stdin);
    //freopen("beasts.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k, cnt = 0;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < n; i++) {
        if (!used[1.0 * a[i] / k]) {
            used[1.0 * a[i]]++;
            cnt++;
        }
    }
    cout << cnt;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 10;
const int INF = 1e9;
const double EPS = 1e-10;
const double PI = acosl(-1);

#define int long long

signed main() {
    //freopen("beasts.in", "r", stdin);
    //freopen("beasts.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k, cnt = 0;
    cin >> n >> k;
    vector<int> a(n);
    bool tr = false;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] % k == 0 && !tr) {
            cnt++;
            tr = true;
        }
        if (a[i] % k != 0)
            cnt++;
    }
    cout << cnt;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 10;
const int INF = 1e9;
const double EPS = 1e-10;
const double PI = acosl(-1);

#define int long double

map<int, int> used;

signed main() {
    //freopen("beasts.in", "r", stdin);
    //freopen("beasts.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k, cnt = 0;
    cin >> n >> k;
    vector<int> a(n);
    sort(a.begin(), a.end());
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (!used[1.0 * a[i] / k]) {
            used[1.0 * a[i]]++;
            cnt++;
        }
    }
    cout << cnt;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 10;
const int INF = 1e9;
const double EPS = 1e-10;
const double PI = acosl(-1);

#define int long long

map<float, float> used;

signed main() {
    //freopen("beasts.in", "r", stdin);
    //freopen("beasts.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k, cnt = 0;
    cin >> n >> k;
    vector<int> a(n);
    sort(a.begin(), a.end());
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (!used[1.0 * a[i] / k]) {
            used[a[i]]++;
            cnt++;
        }
    }
    cout << cnt;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 10;
const int INF = 1e9;
const double EPS = 1e-10;
const double PI = acosl(-1);

#define int long long

map<int, int> mp, used;

signed main() {
    //freopen("beasts.in", "r", stdin);
    //freopen("beasts.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k, cnt = 0;
    cin >> n >> k;
    vector<int> a(n);
    sort(a.begin(), a.end());
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (!mp[a[i]] || (a[i] / k > 0 && mp[a[i] / k] && !used[a[i] / k])) {
            used[a[i]]++;
            cnt++;
        }
        mp[a[i] * k]++;
    }
    cout << cnt;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 10;
const int INF = 1e9;
const double EPS = 1e-10;
const double PI = acosl(-1);

#define int long long

bool comp(int a, int b) {
    return a > b;
}

signed main() {
    //freopen("beasts.in", "r", stdin);
    //freopen("beasts.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k, mx = 1;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end(), comp);
    int l = 0, r = 1, umn = a[0];
    while (r < n) {
        while (r < n && max(umn, a[r]) % min(umn, a[r]) != 0) {
            umn *= a[r];
            r++;
        }
        mx = max(mx, r - l);
        umn /= a[l];
        l++;
    }
    cout << mx;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 10;
const int INF = 1e9;
const double EPS = 1e-10;
const double PI = acosl(-1);

#define int long long

signed main() {
    //freopen("beasts.in", "r", stdin);
    //freopen("beasts.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k, cnt = 0;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] % k && !cnt)
            cnt++;
        if (a[i] % k != 0)
            cnt++;
    }
    cout << cnt;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 10;
const int INF = 1e9;
const double EPS = 1e-10;
const double PI = acosl(-1);

#define int long long

bool comp(int a, int b) {
    return a > b;
}

signed main() {
    //freopen("beasts.in", "r", stdin);
    //freopen("beasts.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k, mx = 1;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end(), comp);
    int l = 0, r = 1, umn = a[0];
    while (r < n && l < n) {
        while (r < n && max(umn, a[r]) % min(umn, a[r]) != 0) {
            umn *= a[r];
            r++;
        }
        mx = max(mx, r - l);
        umn /= a[l];
        l++;
    }
    cout << mx;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 10;
const int INF = 1e9;
const double EPS = 1e-10;
const double PI = acosl(-1);

#define int long long

signed main() {
    //freopen("beasts.in", "r", stdin);
    //freopen("beasts.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k, cnt = 0;
    cin >> n >> k;
    vector<int> a(n);
    bool tr = false;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] % k == 0 && !tr) {
            cnt--;
            tr = true;
        }
        if (a[i] % k == 0)
            cnt++;
    }
    cout << n - cnt;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 10;
const int INF = 1e9;
const double EPS = 1e-10;
const double PI = acosl(-1);

#define int long long

signed main() {
    //freopen("beasts.in", "r", stdin);
    //freopen("beasts.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k, cnt = 0;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] % k == 0 && !cnt)
            cnt++;
        if (a[i] % k != 0)
            cnt++;
    }
    cout << cnt;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 10;
const int INF = 1e9;
const double EPS = 1e-10;
const double PI = acosl(-1);

#define int long long

map<int, int> mp, used;

signed main() {
    //freopen("beasts.in", "r", stdin);
    //freopen("beasts.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k, cnt = 0;
    cin >> n >> k;
    vector<int> a(n);
    sort(a.begin(), a.end());
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (!mp[a[i]] || (a[i] / k >= 0 && mp[a[i] / k] && !used[a[i] / k])) {
            used[a[i]]++;
            cnt++;
        }
        mp[a[i] * k]++;
    }
    cout << cnt;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 10;
const int INF = 1e9;
const double EPS = 1e-10;
const double PI = acosl(-1);

#define int long double

map<int, int> used;

signed main() {
    //freopen("beasts.in", "r", stdin);
    //freopen("beasts.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k, cnt = 0;
    cin >> n >> k;
    vector<int> a(n);
    sort(a.begin(), a.end());
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        if (!used[1.0 * a[i] / k]) {
            used[1.0 * a[i]]++;
            cnt++;
        }
    }
    cout << cnt;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 10;
const int INF = 1e9;
const double EPS = 1e-10;
const double PI = acosl(-1);

#define int long double

map<int, int> used;

signed main() {
    //freopen("beasts.in", "r", stdin);
    //freopen("beasts.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k, cnt = 0;
    cin >> n >> k;
    vector<int> a(n);
    sort(a.begin(), a.end());
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (!used[1.0 * a[i] / k]) {
            used[a[i]]++;
            cnt++;
        }
    }
    cout << cnt;
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define graph vector<vi>

const ll mod = 1000000007;
ll po(ll x, ll n ){
	ll ans=1;
     while(n>0){
     	if(n&1) ans=(ans*x)%mod;
     	x=(x*x)%mod;
     	n/=2;
     }
     return ans;
}

pair<int,int> base(int n,int k){

	int p=0;

	while(n%k==0){
		n /= k;
		p++;
	}

	return mp(n,p);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r" , stdin);
	//freopen("output.txt", "w" , stdout);
	#endif

	int n,k;
	cin >> n >> k;

	vector<int> v(n);
	map<pair<int,int>,int> list;

	rep(i,n)cin >> v[i];

	set<int> st;

	rep(i,n){
		pair<int,int> b=base(v[i],k);
		list[mp(b.ff,(b.ss)%2)]++;
		st.insert(b.ff);
	}

	int ans=0;

	for(auto it=st.begin();it!=st.end();it++){
		int value=*it;
		int c=list[mp(value,0)];

		if(list[mp(value,1)])
			c=max(c,list[mp(value,1)]);

		ans += c;
	}

	cout << ans << el;

	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define graph vector<vi>

const ll mod = 1000000007;
ll po(ll x, ll n ){
	ll ans=1;
     while(n>0){
     	if(n&1) ans=(ans*x)%mod;
     	x=(x*x)%mod;
     	n/=2;
     }
     return ans;
}

pair<int,int> base(int n,int k){

	int p=0;

	while(n%k==0){
		n /= k;
		p++;
	}

	return mp(n,p%2);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r" , stdin);
	//freopen("output.txt", "w" , stdout);
	#endif

	int n,k;
	cin >> n >> k;

	if(k==1){
		set<int> st;
		int x;

		rep(i,n){
			cin >> x;
			st.insert(x);
		}

		cout << st.size() ;
		return 0;
	}

	vector<int> v(n);
	map<pair<int,int>,int> list;

	rep(i,n)cin >> v[i];

	set<int> st;

	vector<pair<int,int>> vp;

	rep(i,n){
		pair<int,int> b=base(v[i],k);
		vp.pb(b);
		st.insert(b.ff);
	}

	for(int i=0;i<vp.size();i++){
		list[vp[i]]++;
	}

	int ans=0;

	for(auto it=st.begin();it!=st.end();it++){
		ans += max(list[mp(*it,0)],list[mp(*it,1)]);
	}

	cout << ans << el;

	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define graph vector<vi>

const ll mod = 1000000007;
ll po(ll x, ll n ){
	ll ans=1;
     while(n>0){
     	if(n&1) ans=(ans*x)%mod;
     	x=(x*x)%mod;
     	n/=2;
     }
     return ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r" , stdin);
	//freopen("output.txt", "w" , stdout);
	#endif

	int n,k;
	cin >> n >> k;
	vector<int> v(n);

	set<int> s;

	rep(i,n){
	    cin >> v[i];
	    s.insert(v[i]);
	}

	if(k==1){
		cout << n;
		return 0;
	}

	sort(all(v));
	int ans=0;
	for(auto it=s.begin();it!=s.end();it++){
	    if(s.count((*it)*k)){
			s.erase((*it)*k);
		}
	    ans++;
	}

	cout << ans << el;

	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define graph vector<vi>

const ll mod = 1000000007;
ll po(ll x, ll n ){
	ll ans=1;
     while(n>0){
     	if(n&1) ans=(ans*x)%mod;
     	x=(x*x)%mod;
     	n/=2;
     }
     return ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r" , stdin);
	//freopen("output.txt", "w" , stdout);
	#endif

	int n,k;
	cin >> n >> k;
	vector<int> v(n);

	set<int> s;

	rep(i,n){
	    cin >> v[i];
	    s.insert(v[i]);
	}

	if(k==1){
		cout << n;
		return 0;
	}

	sort(all(v));

	rep(i,n){
	    if(s.count(v[i]*k))
	        s.erase(v[i]*k);
	}

	cout << s.size() << el;

	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define graph vector<vi>

const ll mod = 1000000007;
ll po(ll x, ll n ){
	ll ans=1;
     while(n>0){
     	if(n&1) ans=(ans*x)%mod;
     	x=(x*x)%mod;
     	n/=2;
     }
     return ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r" , stdin);
	//freopen("output.txt", "w" , stdout);
	#endif

	int n,k;
	cin >> n >> k;

	vector<int> v(n);

	rep(i,n)cin >> v[i];

	unordered_map<int,int> m;

	vector<int> dp(n,1);

	m[v[0]]++;

	rep_a(i,1,n){
		dp[i]=dp[i-1]+1;
		if(v[i]%k==0 && m[v[i]/k]){
			dp[i]-=1;
		}
		m[v[i]]++;
	}

	int mx=0;

	rep(i,n)
		mx=max(mx,dp[i]);

	cout << mx ;

	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define graph vector<vi>

const ll mod = 1000000007;
ll po(ll x, ll n ){
	ll ans=1;
     while(n>0){
     	if(n&1) ans=(ans*x)%mod;
     	x=(x*x)%mod;
     	n/=2;
     }
     return ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r" , stdin);
	//freopen("output.txt", "w" , stdout);
	#endif

	int n,k;
	cin >> n >> k;
	vector<int> v(n);

	set<int> s;

	rep(i,n){
	    cin >> v[i];
	    s.insert(v[i]);
	}

	sort(all(v));

	rep(i,n){
	    if(s.find(v[i]*k))
	        s.erase(v[i].k);
	}

	cout << s.size() << el;

	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define INF 1e9
#define pb push_back
#define mp  make_pair
#define loop(a,n) for(long long i=a;i<n;i++)
#define vil vector<long long int>
#define vi vector<int>
#define sz(v) v.size()
#define setbits(x)          __builtin_popcountll(x)
using namespace std;
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
bool isperfect(ll n){
    ll y=sqrt(n);
    if(n%y==0&&y*y==n)return true;
    return false;
}
bool comp(pair<ll,ll> a,pair<ll,ll> b){
    return a.second<b.second;
}
ll powi(ll a,ll b){
    ll ans=1;
    while(b>0){
        if(b&1)ans=ans*a;
        b=b>>1;
        a=a*a;
    }
    return ans;
}
int main()
{
  ll n,k,x;
  cin>>n>>k;

  set<ll> s;

  loop(0,n){cin>>x;s.insert(x);}

  ll ans=0;
  if(k==1){cout<<n;return 0;}
  for(auto x: s){
      if(s.count(x*k))s.erase(x*k);
      ans++;
  }
  cout<<ans;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define graph vector<vi>

const ll mod = 1000000007;
ll po(ll x, ll n ){
	ll ans=1;
     while(n>0){
     	if(n&1) ans=(ans*x)%mod;
     	x=(x*x)%mod;
     	n/=2;
     }
     return ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r" , stdin);
	//freopen("output.txt", "w" , stdout);
	#endif

	int n,k,x;
	cin >> n >> k;

	set<int> s;

	rep(i,n){
		cin >> x;
	    s.insert(x);
	}

	if(k==1){
		cout << n;
		return 0;
	}

	int ans=0;

	for(auto x: s){
		if(s.count(x*k))
			s.erase(x*k);
		ans++;
	}

	cout << ans ;

	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define graph vector<vi>

const ll mod = 1000000007;
ll po(ll x, ll n ){
	ll ans=1;
     while(n>0){
     	if(n&1) ans=(ans*x)%mod;
     	x=(x*x)%mod;
     	n/=2;
     }
     return ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r" , stdin);
	//freopen("output.txt", "w" , stdout);
	#endif

	ll n,k,x;
	cin >> n >> k;

	set<ll> s;

	rep(i,n){
		cin >> x;
	    s.insert(x);
	}

	if(k==1){
		cout << n;
		return 0;
	}

	ll ans=0;

	for(auto x: s){
		if(s.count(x*k))
			s.erase(x*k);
		ans++;
	}

	cout << ans ;

	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define graph vector<vi>

const ll mod = 1000000007;
ll po(ll x, ll n ){
	ll ans=1;
     while(n>0){
     	if(n&1) ans=(ans*x)%mod;
     	x=(x*x)%mod;
     	n/=2;
     }
     return ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r" , stdin);
	//freopen("output.txt", "w" , stdout);
	#endif

	int n,k;
	cin >> n >> k;
	vector<int> v(n);

	set<int> s;

	rep(i,n){
	    cin >> v[i];
	    s.insert(v[i]);
	}

	if(k==1){
		cout << n;
		return 0;
	}

	sort(all(v));
	int ans=0;

	for(auto x: s){
		if(s.count(x*k))
			s.erase(x*k);
	}

	cout << s.size() << el;

	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define graph vector<vi>

const ll mod = 1000000007;
ll po(ll x, ll n ){
	ll ans=1;
     while(n>0){
     	if(n&1) ans=(ans*x)%mod;
     	x=(x*x)%mod;
     	n/=2;
     }
     return ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r" , stdin);
	//freopen("output.txt", "w" , stdout);
	#endif

	int n,k;
	cin >> n >> k;
	vector<int> v(n);

	set<int> s;

	rep(i,n){
	    cin >> v[i];
	    s.insert(v[i]);
	}

	if(k==1){
		cout << n;
		return 0;
	}

	for(auto x: s){
		if(s.count(x*k))
			s.erase(x*k);
	}

	cout << s.size() ;

	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define graph vector<vi>

const ll mod = 1000000007;
ll po(ll x, ll n ){
	ll ans=1;
     while(n>0){
     	if(n&1) ans=(ans*x)%mod;
     	x=(x*x)%mod;
     	n/=2;
     }
     return ans;
}

pair<int,int> base(int n,int k){

	int p=0;

	while(n%k==0){
		n /= k;
		p++;
	}

	return mp(n,p);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r" , stdin);
	//freopen("output.txt", "w" , stdout);
	#endif

	int n,k;
	cin >> n >> k;

	if(k==1){
		set<int> st;
		int x;

		rep(i,n){
			cin >> x;
			st.insert(x);
		}

		cout << st.size() ;
		return 0;
	}

	vector<int> v(n);
	map<pair<int,int>,int> list;

	rep(i,n)cin >> v[i];

	set<int> st;

	rep(i,n){
		pair<int,int> b=base(v[i],k);
		list[mp(b.ff,(b.ss)%2)]++;
		st.insert(b.ff);
	}

	int ans=0;

	for(auto it=st.begin();it!=st.end();it++){
		int value=*it;
		int c=list[mp(value,0)];

		ans += max({c,list[mp(value,1)],0});
	}

	cout << ans << el;

	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define graph vector<vi>

const ll mod = 1000000007;
ll po(ll x, ll n ){
	ll ans=1;
     while(n>0){
     	if(n&1) ans=(ans*x)%mod;
     	x=(x*x)%mod;
     	n/=2;
     }
     return ans;
}

pair<int,int> base(int n,int k){

	int p=0;

	while(n%k==0){
		n /= k;
		p++;
	}

	return mp(n,p);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r" , stdin);
	//freopen("output.txt", "w" , stdout);
	#endif

	int n,k;
	cin >> n >> k;

	if(k==1){
		set<int> st;
		int x;

		rep(i,n){
			cin >> x;
			st.insert(x);
		}

		cout << st.size() ;
		return 0;
	}

	vector<int> v(n);
	map<pair<int,int>,int> list;

	rep(i,n)cin >> v[i];

	set<int> st;

	rep(i,n){
		pair<int,int> b=base(v[i],k);
		list[mp(b.ff,(b.ss)%2)]++;
		st.insert(b.ff);
	}

	int ans=0;

	for(auto it=st.begin();it!=st.end();it++){
		int value=*it;
		int c=list[mp(value,0)];

		if(list[mp(value,1)])
			c=max(c,list[mp(value,1)]);

		ans += c;
	}

	cout << ans << el;

	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define graph vector<vi>

const ll mod = 1000000007;
ll po(ll x, ll n ){
	ll ans=1;
     while(n>0){
     	if(n&1) ans=(ans*x)%mod;
     	x=(x*x)%mod;
     	n/=2;
     }
     return ans;
}

pair<ll,ll> base(ll n,ll k){

	ll p=0;

	while(n%k==0){
		n /= k;
		p++;
	}

	return mp(n,p);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r" , stdin);
	//freopen("output.txt", "w" , stdout);
	#endif

	ll n,k;
	cin >> n >> k;

	if(k==1){
		set<ll> st;
		ll x;

		rep(i,n){
			cin >> x;
			st.insert(x);
		}

		cout << st.size() ;
		return 0;
	}

	vector<ll> v(n);
	map<pair<ll,ll>,ll> list;

	rep(i,n)cin >> v[i];

	set<ll> st;

	rep(i,n){
		pair<ll,ll> b=base(v[i],k);
		list[mp(b.ff,(b.ss)%2)]++;
		st.insert(b.ff);
	}

	ll ans=0;

	for(auto it=st.begin();it!=st.end();it++){
		ll value=*it;
		ll c=list[mp(value,0)];

		if(list[mp(value,1)])
			c=max(c,list[mp(value,1)]);

		ans += c;
	}

	cout << ans << el;

	return 0;
}


#include<map>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){
    long long  n,k;
    cin>>n>>k;
    map<long long,long long> orig;
    vector<bool> v(n,false);
    vector<long long> org(n);
    for(int i=0;i<n;++i){
        cin>>org[i];
        orig[org[i]]=i;
    }
    long long ans=0;
    sort(org.begin(),org.end());
    for(int i=0;i<n;++i){
        long long temp=0;
        long long x=org[i];
        while(orig.find(x)!=orig.end() && v[x]==false){
            temp++;
            v[x]=true;
            x*=k;
        }
        ans+=temp%2==0?temp/2:temp/2+1;
    }
    cout<<ans;
    return 0;
}


#include<set>
#include<iostream>
using namespace std;
int main(void){
    long long  n,k;
    cin>>n>>k;
    set<long long> orig;
    for(int i=0;i<n;++i){
        long long x;
        cin>>x;
        orig.insert(x);
    }
    set<long long> p1,p2;
    for(auto x: orig){
        if(p2.find(x)==p2.end()){
            p1.insert(x);
            if(orig.find(2*x)!=orig.end())p2.insert(2*x);
        }
    }
    cout<<max(p1.size(),p2.size());
    return 0;
}


#include<unordered_map>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){
    long long  n,k;
    cin>>n>>k;
    unordered_map<long long,long long> orig;
    vector<bool> v(n,false);
    vector<long long> org(n);
    for(int i=0;i<n;++i){
        cin>>org[i];
        orig[org[i]]=i;
    }
    long long ans=0;
    sort(org.begin(),org.end());
    for(int i=0;i<n;++i){
        long long temp=0;
        long long x=org[i];
        while(orig.find(x)!=orig.end() && v[x]==false){
            temp++;
            v[x]=true;
            x*=k;
        }
        ans+=temp%2==0?temp/2:temp/2+1;
    }
    cout<<ans;
    return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
long long bs(long long x,vector<long long> &a){
    long long s=0,e=a.size();
    while(s<=e){
        long long m=(s+e)/2;
        if(a[m]==x)return m;
        else if(a[m]>x)e=m-1;
        else s=m+1;
    }
    return -1;
}
int main(void){
    long long  n,k;
    cin>>n>>k;
    vector<bool> v(n,false);
    vector<long long> org(n);
    for(int i=0;i<n;++i){
        cin>>org[i];
    }
    long long ans=0;
    sort(org.begin(),org.end());
    for(int i=0;i<n;++i){
        long long temp=0;
        long long x=org[i];
        long long j=bs(x,org);
        while(j!=-1 && v[j]==false){
            temp++;
            v[j]=true;
            x*=k;
            j=bs(x,org);
        }
        ans+=temp%2==0?temp/2:temp/2+1;
    }
    cout<<ans;
    return 0;
}


#include<set>
#include<iostream>
using namespace std;
int main(void){
    int n,k;
    cin>>n>>k;
    set<int> orig;
    for(int i=0;i<n;++i){
        int x;
        cin>>x;
        orig.insert(x);
    }
    set<int> p1,p2;
    for(auto x: orig){
        if(p2.find(x)==p2.end()){
            p1.insert(x);
            if(orig.find(2*x)!=orig.end())p2.insert(2*x);
        }
    }
    cout<<max(p1.size(),p2.size());
    return 0;
}


#include<map>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){
    long long  n,k;
    cin>>n>>k;
    map<long long,long long> orig;
    vector<bool> v(n,false);
    vector<long long> org(n);
    for(int i=0;i<n;++i){
        cin>>org[i];
        orig[org[i]]=i;
    }
    long long ans=0;
    sort(org.begin(),org.end());
    for(int i=0;i<n;++i){
        long long temp=0;
        long long x=org[i];
        while(x>=0 && orig.find(x)!=orig.end() && v[x]==false){
            temp++;
            v[x]=true;
            x*=k;
        }
        ans+=temp%2==0?temp/2:temp/2+1;
    }
    cout<<ans;
    return 0;
}


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

map <int, int> mp;

int main() {
    int n, k, maximo = 0;

    cin >> n >> k;

    int v[n];

    for(int i = 0; i < n; i ++)
        cin >> v[i];

    sort(v, v + n);

    for(int i = 0; i < n; i ++)
        if(v[i] % k || !mp.count (v[i]/k)) {
            mp[v[i]] = 1;
            maximo ++;
        }

    cout << maximo << endl;
}


#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
const int inf=2147483647;
int h[100010],nex[200010],to[200010],M;
void add(int a,int b){
	M++;
	to[M]=b;
	nex[M]=h[a];
	h[a]=M;
}
vector<int>d[100010];
int q[2000010],c[100010],dis[100010],n;
void bfs(int f){
	int head,tail,x,i;
	head=1;
	tail=0;
	for(i=1;i<=n;i++){
		if(c[i]==f){
			tail++;
			q[tail]=i;
			dis[i]=0;
		}else
			dis[i]=inf;
	}
	while(head<=tail){
		x=q[head];
		head++;
		for(i=h[x];i;i=nex[i]){
			if(dis[x]+1<dis[to[i]]){
				dis[to[i]]=dis[x]+1;
				tail++;
				q[tail]=to[i];
			}
		}
	}
	for(i=1;i<=n;i++)d[i].push_back(dis[i]);
}
int main(){
	int m,k,s,i,j,x,y,ans;
	scanf("%d%d%d%d",&n,&m,&k,&s);
	for(i=1;i<=n;i++)scanf("%d",c+i);
	while(m--){
		scanf("%d%d",&x,&y);
		add(x,y);
		add(y,x);
	}
	for(i=1;i<=k;i++)bfs(i);
	for(i=1;i<=n;i++){
		sort(d[i].begin(),d[i].end());
		ans=0;
		for(j=0;j<s;j++)ans+=d[i][j];
		printf("%d ",ans);
	}
}


#include<bits/stdc++.h>
using namespace std;
int cnt,head[320000],n,m,k,s,w[320000],dis[120000][120],type[120000];
struct node{int next,to;} sxd[640000];
queue <int> q;
bool vis[120000];
void add(int x,int y) {
	sxd[++cnt].next=head[x];
	sxd[cnt].to=y;
	head[x]=cnt;
}
void bfs(int typ) {
	queue <int> q;
	memset(vis,0,sizeof vis);
	for(int i=1;i<=n;i++) {
		if(type[i]==typ) {
			q.push(i);
			vis[i]=1;
			dis[i][typ]=0;
		}
	}
	while(!q.empty()) {
		int t=q.front();
		q.pop();
		for(int i=head[t];i;i=sxd[i].next) {
			if(!vis[sxd[i].to]) {
				dis[sxd[i].to][typ]=dis[t][typ]+1;
				q.push(sxd[i].to);
				vis[sxd[i].to]=true;
			}
		}
	}
}
void solve() {
	for(int i=1;i<=k;i++) bfs(i);
	for(int i=1;i<=n;i++) {
		sort(dis[i]+1,dis[i]+k+1);
		int ans=0;
		for(int j=1;j<=s;j++)
			ans+=dis[i][j];
		cout<<ans<<" ";
	}
}
int main() {
	ios::sync_with_stdio(false);
	cin>>n>>m>>k>>s;
	for(int i=1;i<=n;i++) {
		cin>>type[i];
	}
	for(int i=1;i<=m;i++) {
		int x,y;
		cin>>x>>y;
		add(x,y);
		add(y,x);
	}
	solve();
	return 0;
}
//zj1=


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
const int maxn=100010;
struct Edge{
	int to,next;
}edges[maxn<<1];
int head[maxn],cnt=0,good[maxn];
int dis[maxn][110];
int n,m,k,s;

void addEdge(int u,int v){
	edges[++cnt].to=v;
	edges[cnt].next=head[u];
	head[u]=cnt;
}

queue<int> q;
vector<int> vv[110];
void bfs(int tp){     //tp:type
	while(!q.empty()) q.pop();
	int sz=vv[tp].size();
	for(int i=0;i<sz;i++){
		dis[vv[tp][i]][tp]=0;
		q.push(vv[tp][i]);
	}
	int u,v;
	while(!q.empty()){
		u=q.front();
		q.pop();
		for(int i=head[u];i!=-1;i=edges[i].next){
			v=edges[i].to;
//			printf("[BFS]dis[%d][%d]=%d,dis[%d][%d]=%d\n",v,tp,dis[v][tp],u,tp,dis[u][tp]);
			if(dis[v][tp]>dis[u][tp]+1){
				dis[v][tp]=dis[u][tp]+1;
				q.push(v);
			}
		}
	}
}
int main(){
	memset(head,-1,sizeof(head));
	scanf("%d%d%d%d",&n,&m,&k,&s);
	for(int i=1;i<=n;i++){
		scanf("%d",&good[i]);
		vv[good[i]].push_back(i);
	}
	int u,v;
	for(int i=1;i<=m;i++){
		scanf("%d%d",&u,&v);
		addEdge(u,v);
		addEdge(v,u);
	}
	memset(dis,0x3f,sizeof(dis));
	for(int i=1;i<=k;i++){
		bfs(i);
//		for(int j=1;j<=n;j++){
//			printf("dis[%d][%d]=%d\n",j,i,dis[j][i]);
//		}
	}
	for(int i=1;i<=n;i++){
		nth_element(dis[i]+1,dis[i]+1+s,dis[i]+1+k);
		int res=0;
		for(int j=1;j<=s;j++) res+=dis[i][j];
		printf("%d ",res);
	}
}


#include<bits/stdc++.h>
using namespace std;
#define     N       100005
#define     M       105
#define     pb      push_back

int i,j,k,l,n,m,f[N][M],Color[N],v,x,y,ans;
vector  <int> V[N];
queue   <int> Q;

void    Spfa(int x)
{
    while (!Q.empty()) Q.pop();
    for (int i=1;i<=n;i++) if (Color[i]==x)
    {
        Q.push(i);
        f[i][x]=0;
    }
    for (;!Q.empty();)
    {
        for (int i=0;i<V[Q.front()].size();i++)
        {
            if (f[V[Q.front()][i]][x]>f[Q.front()][x]+1)
            {
                Q.push(V[Q.front()][i]);
                f[V[Q.front()][i]][x]=f[Q.front()][x]+1;
            }
        }
        Q.pop();
    }
}

int main()
{
    scanf("%d%d%d%d",&n,&m,&k,&v);
    for (i=1;i<=n;i++) scanf("%d",&Color[i]);
    for (i=1;i<=m;i++)
    {
        scanf("%d%d",&x,&y);
        V[x].pb(y);
        V[y].pb(x);
    }
    memset(f,0x3f,sizeof(f));
    for (i=1;i<=k;i++)
    {
        Spfa(i);
    }
    for (i=1;i<=n;i++)
    {
        ans=0;
        sort(f[i]+1,f[i]+k+1);
        for (j=1;j<=v;j++) ans+=f[i][j];
        printf("%d ",ans);
    }
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int n,m,gs,s,d[maxn],v[maxn];
struct cc1{
	int x,len;
};
queue <cc1> q;
vector <int> good[110];
vector <int> ed[maxn];
priority_queue <int,vector <int> , greater<int> > h[maxn];

void bfs()
{
	while (!q.empty())
	{
		int k=q.front().x,w=q.front().len;
		q.pop();
		for (int i=0;i<ed[k].size();i++)
		{
			int y=ed[k][i];
			if (v[y]==0) {
				d[y]=w+1;
				v[y]=1;
				cc1 l;
				l.x=y;l.len=w+1;
				q.push(l);
			}
		}
	}
}

int main()
{
	scanf("%d %d %d %d",&n,&m,&gs,&s);
	for (int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		good[x].push_back(i);
	}
	for (int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d %d",&x,&y);
		ed[x].push_back(y);
		ed[y].push_back(x);
	}
	for (int i=1;i<=gs;i++)
	{
		memset(v,0,sizeof(v));
		memset(d,0x3f,sizeof(d));
		for (int j=0;j<good[i].size();j++)
		{
			cc1 l;
			l.x=good[i][j];l.len=0;
			q.push(l);
			d[good[i][j]]=0;
			v[good[i][j]]=1;
		}
		bfs();
		for (int j=1;j<=n;j++)
			h[j].push(d[j]);
	}
	for (int i=1;i<=n;i++)
	{
		int sum=0;
		for (int j=1;j<=s;j++)
			{
				sum+=h[i].top();
				h[i].pop();
			}
		printf("%d ",sum);
	}

}


#include<bits/stdc++.h>
using namespace std;
const int inf=1<<30;
struct edge {
	int v,next;
}e[200005];
int a[100005],head[100005],dp[100005][105],vis[100005],q[100005][2];
int n,m,k,s,ecnt=0;
priority_queue<int,vector<int>,greater<int> > que;
int read() {
	char c=getchar(); int x=0,f=1;
	while (c<'0' || c>'9') {
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9') {
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
void addedge(int u,int v) {
	e[ecnt].v=v;
	e[ecnt].next=head[u];
	head[u]=ecnt++;
}
void bfs(int p) {
	memset(vis,0,sizeof(vis));
	int cnt=0;
	for (int i=1; i<=n; i++) {
		if (a[i]==p) {
			q[++cnt][0]=i;
			q[cnt][1]=0;
			vis[i]=1;
		}
	}
	int i=1;
	while (i<=cnt) {
		int u=q[i][0],d=q[i][1];
		dp[u][p]=min(dp[u][p],d);
		for (int j=head[u]; j>=0; j=e[j].next) {
			int v=e[j].v;
			if (vis[v]==0) {
				q[++cnt][0]=v;
				q[cnt][1]=d+1;
				vis[v]=1;
			}
		}
		++i;
	}
}
int main() {
	n=read(),m=read(),k=read(),s=read();
	memset(head,-1,sizeof(head));
	for (int i=1; i<=n; i++) a[i]=read();
	for (int i=1; i<=m; i++) {
		int u=read(),v=read();
		addedge(u,v);
		addedge(v,u);
	}
	for (int i=1; i<=n; i++) {
		for (int j=1; j<=k; j++) {
			dp[i][j]=inf;
		}
	}
	for (int i=1; i<=k; i++) bfs(i);
	for (int i=1; i<=n; i++) {
		while (!que.empty()) que.pop();
		for (int j=1; j<=k; j++) que.push(dp[i][j]);
		int ans=0;
		for (int j=1; j<=s; j++) {
			ans+=que.top();
			que.pop();
		}
		printf("%d", ans);
		if (i<n) printf(" ");
	}
	printf("\n");
	return 0;
}


#include <bits/stdc++.h>
#define LL long long
#define maxn 100100
#define iter multiset<int>::iterator
using namespace std;
int n, m, k, s;
int a[maxn];
struct node
{
	int v;
	node *nxt;
} e[2*maxn], *h[maxn];
int z;
inline void addedge(int u, int v)
{
	e[++z].v = v; e[z].nxt = h[u]; h[u] = &e[z];
	e[++z].v = u; e[z].nxt = h[v]; h[v] = &e[z];
}
multiset<int> st[maxn];
int dis[maxn];
queue<int> que;
void bfs()
{
	while(!que.empty())
	{
		int x = que.front(); que.pop();
		st[x].insert(dis[x]);
		for(node *p = h[x]; p; p = p->nxt)
		{
			if(!dis[p->v])
			{
				dis[p->v] = dis[x] + 1;
				que.push(p->v);
			}
		}
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m >> k >> s;
	for(int i = 1; i <= n; i ++)
		cin >> a[i];
	for(int i = 0, u, v; i < m; i ++)
	{
		cin >> u >> v;
		addedge(u, v);
	}
	for(int i = 1; i <= k; i ++)
	{
		memset(dis, 0, sizeof(dis));
		for(int j = 1; j <= n; j ++)
			if(a[j] == i)
			{
				dis[j] = 1;
				que.push(j);
			}
		bfs();
	}
	for(int i = 1; i <= n; i ++)
	{
		iter it = st[i].begin();
		int Ans = 0;
		for(int j = 0; j < s; j ++, it ++)
		{
//			cout << (*it) << ' ';
			Ans += (*it);
		}
		Ans -= s;
		cout << Ans << ' ';
//		cout << endl;
	}
	cout << endl;
	return 0;
}


#include <bits/stdc++.h>
#define LL long long
#define maxn 100100
#define iter multiset<int>::iterator
using namespace std;
int n, m, k, s;
int a[maxn];
struct node
{
	int v;
	node *nxt;
} e[2*maxn], *h[maxn];
int z;
inline void addedge(int u, int v)
{
	e[++z].v = v; e[z].nxt = h[u]; h[u] = &e[z];
	e[++z].v = u; e[z].nxt = h[v]; h[v] = &e[z];
}
int val[maxn][110];
int q;
int dis[maxn];
int que[maxn], head, tail;
void bfs()
{
	while(head != tail)
	{
		int x = que[head++];
		val[x][q] = dis[x];
		for(node *p = h[x]; p; p = p->nxt)
		{
			if(!dis[p->v])
			{
				dis[p->v] = dis[x] + 1;
				que[tail++] = p->v;
			}
		}
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m >> k >> s;
	for(int i = 1; i <= n; i ++)
		cin >> a[i];
	for(int i = 0, u, v; i < m; i ++)
	{
		cin >> u >> v;
		addedge(u, v);
	}
	for(int i = 1; i <= k; i ++)
	{
		q = i - 1;
		memset(dis, 0, sizeof(dis));
		head = tail = 0;
		for(int j = 1; j <= n; j ++)
			if(a[j] == i)
			{
				dis[j] = 1;
				que[tail++] = j;
			}
		bfs();
	}
	for(int i = 1; i <= n; i ++)
	{
		sort(val[i], val[i] + k);
		int Ans = 0;
		for(int j = 0; j < s; j ++)
		{
//			cout << (*it) << ' ';
			Ans += val[i][j];
		}
		Ans -= s;
		cout << Ans << ' ';
//		cout << endl;
	}
	cout << endl;
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<cmath>
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
namespace io
{
	int F()
	{
		int F=1,n=0;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
}
int cnt;
int main()
{
	int last,n=io::F(),c=io::F();
	last=io::F(),cnt=1;
	for(register int i=1;i<n;++i)
	{
		int now=io::F();
		if(now-last>c)cnt=1;
			else ++cnt;
		last=now;
	}
	printf("%d",cnt);
	return 0;
}