#include <iostream>
using namespace std;
int cifmax(int n){
int mx=n%10;
n=n/10;
while(n){
if(n%10>mx) mx=n%10;
n=n/10;
}
return ms;
}
int main(){
int v[100],n,k,nr=0;
//Citire
cout << "N: "
cin >> n;
for(i=0;i<n;i++) cin >> v[i];
cout << "K: "
cin >> k;
//Testare
for(i=0;i<n;i++)if(cifmax(v[i]==k))nr++;
cout << "Numar : " << nr;
}