#include<bits/stdc++.h>
const long long maxn=300001,mod=1e9+7;
inline const void read(long long &a)
{
a=0;
char c=getchar();
while(c<'0'||c>'9')c=getchar();
while(c>='0'&&c<='9')
{
a=(a<<1)+(a<<3)+c-'0';
c=getchar();
}
}
inline const void write(long long a)
{
if(a>=10)write(a/10);
putchar(a%10+'0');
}
inline const bool lucky(long long a)
{
bool r=true;
long long k=a;
while(k)
{
long long c=k%10;
if(c!=7&&c!=4)
{
r=false;
break;
}
k/=10;
}
return r;
}
long long n,a[maxn],k,ans=0;
bool luck[maxn];
struct LUCK_WORD
{
long long l[maxn],end,num[maxn];
inline const void init(){end=0;memset(num,0,sizeof(num));}
inline const void push(long long cc)
{
for(long long i=1;i<=end;i++)if(l[i]==cc){num[i]++;return ;}
l[++end]=cc;
num[end]=1;
}
inline const bool can()
{
for(long long i=1;i<=end;i++)if(num[i]==2)return false;
return true;
}
}line;
int main()
{
freopen("lucky.in","r",stdin);
read(n);read(k);
for(long long i=1;i<=n;i++)
{
read(a[i]);
luck[i]=lucky(a[i]);
}
for(long long i=1;i<=1<<n;i++)
{
line.init();
long long r=0;
for(long long p=1;p<=n;p++)
if(i&(1<<(p-1)))
{
if(luck[p])line.push(a[p]);
r++;
}
if(r==k&&line.can())ans++;
}
write(ans);
return 0;
}