#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int N = 234, I5 = 5005;
int n;
ll x[N];
P a[N];
int f[I5][N], k;
bool exist[I5][N];

int factors(ll x, int divisor) {
    int res = 0;
    while (x % divisor == 0) {
        res++;
        x /= divisor;
    }
    return res;
}

int main() {
    #ifndef ONLINE_JUDGE
        freopen("input", "r", stdin);
        //freopen("output", "w", stdout);
    #endif
    cin >> n >> k;
    for(int i = 1; i <= n; i++) cin >> x[i];

    for(int i = 1; i <= n; i++) a[i] = make_pair(factors(x[i], 2), factors(x[i], 5));
    sort(a+1,a+n+1,[](P a, P b) { return a.second > b.second; });

    int upper = 0; for(int i = 1; i <= k; i++) upper += a[i].second;

    int res = 0;
    exist[0][0] = true;
    for(int ik = 1; ik <= k; ik++) {
        for(int i5 = 1; i5 <= upper; i5++)
            for(int i = 1; i <= n; i++)
                if (a[i].second <= i5 && exist[i5-a[i].second][ik-1]) {
                    f[i5][ik] = max(f[i5][ik], f[i5 - a[i].second][ik - 1] + a[i].first);
                    exist[i5][ik] = true;
                }
    }
    for(int i5 = 1; i5 <= upper; i5++) res = max(res, min(i5, f[i5][k]));

    cout << res;
}


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

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define EPS 1e-9
#define INF  1e15 +1    /// 10^15 + 1
#define INF2 1<<63 /// 2^63
#define all(a)  a.begin(),a.end()
#define forn(i,n) for(int i=0;i<n;i++)
#define dbg(x) cout << #x"=" << x << '\n';
#define dbg2(x,y) cout << #x"=" << x << " " << #y"=" << y << '\n';
#define dbg3(x,y,z) cout << #x"=" << x << " " << #y"=" << y << " " << #z"=" << z << '\n';
#define MOD 1000000007

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector < vi > vvi;
typedef vector < vll > vvll;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;
typedef vector < pii > vpii;
typedef vector < pll > vpll;
typedef vector < vpii > vvpii;
typedef vector < vpll > vvpll;

ll n,x,i,j,k,a,b,c,m,h,t,y,q;
vpll v;
ll dp[202][102][102];

ll bt(ll cual,ll cuantos,ll a, ll b){
	//dbg(cual) dbg3(cuantos,a,b)
	if(cuantos==k) return min(a,b);
	if(cual>=n) return 0;
	if(dp[cuantos][a][b] != -1) return dp[cuantos][a][b];
	ll res  = max( bt(cual+1,cuantos,a,b) , bt(cual+1,cuantos+1,a+v[cual].fi,b+v[cual].se) );
	return dp[cuantos][a][b] = res;
}

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

	memset(dp,-1,sizeof(dp));
	cin>>n>>k;
	forn(i,n){
		cin>>a;
		b=c=0;
		while(a%2==0){ a/=2; b++; }
		while(a%5==0){ a/=5; c++; }
		if(b || c) v.pb(mp(b,c));
	}
	n = v.size();
	a = bt(0,0,0,0);
	cout<<a;

	cout<<'\n';
}


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

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define EPS 1e-9
#define INF  1e15 +1    /// 10^15 + 1
#define INF2 1<<63 /// 2^63
#define all(a)  a.begin(),a.end()
#define forn(i,n) for(int i=0;i<n;i++)
#define dbg(x) cout << #x"=" << x << '\n';
#define dbg2(x,y) cout << #x"=" << x << " " << #y"=" << y << '\n';
#define dbg3(x,y,z) cout << #x"=" << x << " " << #y"=" << y << " " << #z"=" << z << '\n';
#define MOD 1000000007

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector < vi > vvi;
typedef vector < vll > vvll;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;
typedef vector < pii > vpii;
typedef vector < pll > vpll;
typedef vector < vpii > vvpii;
typedef vector < vpll > vvpll;

ll n,x,i,j,k,a,b,c,m,h,t,y,q;
vpll v;
ll dp[2][205][3605];

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

	memset(dp,-1,sizeof(dp));
	cin>>n>>k;
	forn(i,n){
		cin>>a;
		b=c=0;
		while(a%2==0){ a/=2; b++; }
		while(a%5==0){ a/=5; c++; }
		if(b || c) v.pb(mp(b,c));
	}
	n = v.size();

	dp[0][0][0] = 0;

	a=0;
	for(i=0;i<n;i++){
		// 1 = act  0 = old
		for(j= 1 ; j<=k ; j++){
			for(x=v[i].se;x<=3600;x++){
				if(dp[0][j-1][x-v[i].se]!=-1) dp[1][j][x] = max( dp[1][j][x] , dp[0][j-1][x-v[i].se] + v[i].fi );
				dp[1][j][x] = max(dp[1][j][x],dp[0][j][x]);
				a = max(a, min(x,dp[1][k][x]) );
			}
		}
		for(j= 1 ; j<=k ; j++) for(x=0;x<=3600;x++) dp[0][j][x] = dp[1][j][x];
	}

	cout<<a;

	cout<<'\n';
}


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

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define EPS 1e-9
#define INF  1e15 +1    /// 10^15 + 1
#define INF2 1<<63 /// 2^63
#define all(a)  a.begin(),a.end()
#define forn(i,n) for(int i=0;i<n;i++)
#define dbg(x) cout << #x"=" << x << '\n';
#define dbg2(x,y) cout << #x"=" << x << " " << #y"=" << y << '\n';
#define dbg3(x,y,z) cout << #x"=" << x << " " << #y"=" << y << " " << #z"=" << z << '\n';
#define MOD 1000000007

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector < vi > vvi;
typedef vector < vll > vvll;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;
typedef vector < pii > vpii;
typedef vector < pll > vpll;
typedef vector < vpii > vvpii;
typedef vector < vpll > vvpll;

ll n,x,i,j,k,a,b,c,m,h,t,y,q;
vpll v;
ll dp[2][205][3605*2 +1];

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

	memset(dp,-1,sizeof(dp));
	cin>>n>>k;
	forn(i,n){
		cin>>a;
		b=c=0;
		while(a%2==0){ a/=2; b++; }
		while(a%5==0){ a/=5; c++; }
		if(b || c) v.pb(mp(b,c));
	}
	n = v.size();

	dp[0][0][0] = 0;

	a=0;
	for(i=0;i<n;i++){
		// 1 = act  0 = old
		for(j= 1 ; j<=k ; j++){
			for(x=v[i].se;x<=3600;x++){
				if(dp[0][j-1][x-v[i].se]!=-1) dp[1][j][x] = max( dp[1][j][x] , dp[0][j-1][x-v[i].se] + v[i].fi );
				dp[1][j][x] = max(dp[1][j][x],dp[0][j][x]);
				a = max(a, min(x,dp[1][j][x]) );
				//cout<<dp[1][j][x]<<" ";
			}   //cout<<'\n';
		}       //cout<<'\n';
		for(j= 1 ; j<=k ; j++) for(x=0;x<=3600;x++) dp[0][j][x] = dp[1][j][x];
	}

	cout<<a;

	cout<<'\n';
}


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

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define EPS 1e-9
#define INF  1e15 +1    /// 10^15 + 1
#define INF2 1<<63 /// 2^63
#define all(a)  a.begin(),a.end()
#define forn(i,n) for(int i=0;i<n;i++)
#define dbg(x) cout << #x"=" << x << '\n';
#define dbg2(x,y) cout << #x"=" << x << " " << #y"=" << y << '\n';
#define dbg3(x,y,z) cout << #x"=" << x << " " << #y"=" << y << " " << #z"=" << z << '\n';
#define MOD 1000000007

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector < vi > vvi;
typedef vector < vll > vvll;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;
typedef vector < pii > vpii;
typedef vector < pll > vpll;
typedef vector < vpii > vvpii;
typedef vector < vpll > vvpll;

ll n,x,i,j,k,a,b,c,m,h,t,y,q;
vpll v;
ll dp[2][205][3605];

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

	memset(dp,-1,sizeof(dp));
	cin>>n>>k;
	forn(i,n){
		cin>>a;
		b=c=0;
		while(a%2==0){ a/=2; b++; }
		while(a%5==0){ a/=5; c++; }
		if(b || c) v.pb(mp(b,c));
	}
	n = v.size();

	dp[0][0][0] = 0;

	a=0;
	for(i=0;i<n;i++){
		// 1 = act  0 = old
		for(j= 1 ; j<=k ; j++){
			for(x=v[i].se;x<=3600;x++){
				//dp[1][j][x] = dp[0][j][x];
				if(dp[0][j-1][x-v[i].se]!=-1) dp[1][j][x] = max( dp[0][j][x] , dp[0][j-1][x-v[i].se] + v[i].fi );

				a = max(a, min(x,dp[1][k][x]) );
			}
		}
		for(j= 1 ; j<=k ; j++) for(x=0;x<=3600;x++) dp[0][j][x] = dp[1][j][x];
	}

	cout<<a;

	cout<<'\n';
}


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

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define EPS 1e-9
#define INF  1e15 +1    /// 10^15 + 1
#define INF2 1<<63 /// 2^63
#define all(a)  a.begin(),a.end()
#define forn(i,n) for(int i=0;i<n;i++)
#define dbg(x) cout << #x"=" << x << '\n';
#define dbg2(x,y) cout << #x"=" << x << " " << #y"=" << y << '\n';
#define dbg3(x,y,z) cout << #x"=" << x << " " << #y"=" << y << " " << #z"=" << z << '\n';
#define MOD 1000000007

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector < vi > vvi;
typedef vector < vll > vvll;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;
typedef vector < pii > vpii;
typedef vector < pll > vpll;
typedef vector < vpii > vvpii;
typedef vector < vpll > vvpll;

ll n,x,i,j,k,a,b,c,m,h,t,y,q;
vpll v;
ll dp[2][205][3605];

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

	memset(dp,-1,sizeof(dp));
	cin>>n>>k;
	forn(i,n){
		cin>>a;
		b=c=0;
		while(a%2==0){ a/=2; b++; }
		while(a%5==0){ a/=5; c++; }
		if(b || c) v.pb(mp(b,c));
	}
	n = v.size();

	dp[0][0][0] = 0;

	a=0;
	for(i=0;i<n;i++){
		// 1 = act  0 = old
		for(j= 1 ; j<=k ; j++){
			for(x=v[i].se;x<=3600;x++){
				if(dp[0][j-1][x-v[i].se]!=-1) dp[1][j][x] = max( dp[1][j][x] , dp[0][j-1][x-v[i].se] + v[i].fi );
				dp[1][j][x] = max(dp[1][j][x],dp[0][j][x]);
				a = max(a, min(x,dp[1][j][x]) );
				//cout<<dp[1][j][x]<<" ";
			}   //cout<<'\n';
		}       //cout<<'\n';
		for(j= 1 ; j<=k ; j++) for(x=0;x<=3600;x++) dp[0][j][x] = dp[1][j][x];
	}

	cout<<a;

	cout<<'\n';
}


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

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define EPS 1e-9
#define INF  1e15 +1    /// 10^15 + 1
#define INF2 1<<63 /// 2^63
#define all(a)  a.begin(),a.end()
#define forn(i,n) for(int i=0;i<n;i++)
#define dbg(x) cout << #x"=" << x << '\n';
#define dbg2(x,y) cout << #x"=" << x << " " << #y"=" << y << '\n';
#define dbg3(x,y,z) cout << #x"=" << x << " " << #y"=" << y << " " << #z"=" << z << '\n';
#define MOD 1000000007

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector < vi > vvi;
typedef vector < vll > vvll;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;
typedef vector < pii > vpii;
typedef vector < pll > vpll;
typedef vector < vpii > vvpii;
typedef vector < vpll > vvpll;

ll n,x,i,j,k,a,b,c,m,h,t,y,q;
vpll v;
ll MAXI = 3605*2;
ll dp[2][205][3605*2 + 5];

// ya estoy hasta la v :'v

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

	memset(dp,-1,sizeof(dp));
	cin>>n>>k;
	forn(i,n){
		cin>>a;
		b=c=0;
		while(a%2==0){ a/=2; b++; }
		while(a%5==0){ a/=5; c++; }
		if(b || c) v.pb(mp(b,c));
	}
	n = v.size();

	dp[0][0][0] = 0;

	a=0;
	for(i=0;i<n;i++){
		// 1 = act  0 = old
		for(j= 1 ; j<=k ; j++){
			for(x=v[i].se;x<=MAXI;x++){
				if(dp[0][j-1][x-v[i].se]!=-1) dp[1][j][x] = max( dp[1][j][x] , dp[0][j-1][x-v[i].se] + v[i].fi );
				dp[1][j][x] = max(dp[1][j][x],dp[0][j][x]);
				a = max(a, min(x,dp[1][j][x]) );
				//cout<<dp[1][j][x]<<" ";
			}   //cout<<'\n';
		}       //cout<<'\n';
		for(j= 1 ; j<=k ; j++) for(x=0;x<=MAXI;x++) dp[0][j][x] = dp[1][j][x];
	}

	cout<<a;

	cout<<'\n';
}


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

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define EPS 1e-9
#define INF  1e15 +1    /// 10^15 + 1
#define INF2 1<<63 /// 2^63
#define all(a)  a.begin(),a.end()
#define forn(i,n) for(int i=0;i<n;i++)
#define dbg(x) cout << #x"=" << x << '\n';
#define dbg2(x,y) cout << #x"=" << x << " " << #y"=" << y << '\n';
#define dbg3(x,y,z) cout << #x"=" << x << " " << #y"=" << y << " " << #z"=" << z << '\n';
#define MOD 1000000007

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector < vi > vvi;
typedef vector < vll > vvll;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;
typedef vector < pii > vpii;
typedef vector < pll > vpll;
typedef vector < vpii > vvpii;
typedef vector < vpll > vvpll;

ll n,x,i,j,k,a,b,c,m,h,t,y,q;
vpll v;
ll dp[202][1002][1002];

ll bt(ll cual,ll cuantos,ll a, ll b){
	//dbg(cual) dbg3(cuantos,a,b)
	if(cuantos==k || (cuantos && cual==n)) return min(a,b);
	if(cual>=n) return 0;
	if(dp[cuantos][a][b] != -1) return dp[cuantos][a][b];
	ll res = 0;
	res = max( bt(cual+1,cuantos,a,b) , bt(cual+1,cuantos+1,a+v[cual].fi,b+v[cual].se) );
	return dp[cuantos][a][b] = res;
}

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

	memset(dp,-1,sizeof(dp));
	cin>>n>>k;
	forn(i,n){
		cin>>a;
		b=c=0;
		while(a%2==0){ a/=2; b++; }
		while(a%5==0){ a/=5; c++; }
		if(b || c) v.pb(mp(b,c));
	}
	n = v.size();
	a = bt(0,0,0,0);
	cout<<a;

	cout<<'\n';
}


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

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define EPS 1e-9
#define INF  1e15 +1    /// 10^15 + 1
#define INF2 1<<63 /// 2^63
#define all(a)  a.begin(),a.end()
#define forn(i,n) for(int i=0;i<n;i++)
#define dbg(x) cout << #x"=" << x << '\n';
#define dbg2(x,y) cout << #x"=" << x << " " << #y"=" << y << '\n';
#define dbg3(x,y,z) cout << #x"=" << x << " " << #y"=" << y << " " << #z"=" << z << '\n';
#define MOD 1000000007

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector < vi > vvi;
typedef vector < vll > vvll;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;
typedef vector < pii > vpii;
typedef vector < pll > vpll;
typedef vector < vpii > vvpii;
typedef vector < vpll > vvpll;

ll n,x,i,j,k,a,b,c,m,h,t,y,q;
vpll v;
ll dp[1002][1002];

ll bt(ll cual,ll cuantos,ll a, ll b){
	//dbg(cual) dbg3(cuantos,a,b)
	if(cuantos==k || (cuantos && cual==n)) return min(a,b);
	if(cual>=n) return 0;
	if(dp[a][b] != -1) return dp[a][b];
	ll res = 0;
	res = max( bt(cual+1,cuantos,a,b) , bt(cual+1,cuantos+1,a+v[cual].fi,b+v[cual].se) );
	return dp[a][b] = res;
}

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

	memset(dp,-1,sizeof(dp));
	cin>>n>>k;
	forn(i,n){
		cin>>a;
		b=c=0;
		while(a%2==0){ a/=2; b++; }
		while(a%5==0){ a/=5; c++; }
		if(b || c) v.pb(mp(b,c));
	}
	n = v.size();
	a = bt(0,0,0,0);
	cout<<a;

	cout<<'\n';
}


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

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define EPS 1e-9
#define INF  1e15 +1    /// 10^15 + 1
#define INF2 1<<63 /// 2^63
#define all(a)  a.begin(),a.end()
#define forn(i,n) for(int i=0;i<n;i++)
#define dbg(x) cout << #x"=" << x << '\n';
#define dbg2(x,y) cout << #x"=" << x << " " << #y"=" << y << '\n';
#define dbg3(x,y,z) cout << #x"=" << x << " " << #y"=" << y << " " << #z"=" << z << '\n';
#define MOD 1000000007

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector < vi > vvi;
typedef vector < vll > vvll;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;
typedef vector < pii > vpii;
typedef vector < pll > vpll;
typedef vector < vpii > vvpii;
typedef vector < vpll > vvpll;

ll n,x,i,j,k,a,b,c,m,h,t,y,q;
vpll v;
ll dp[2][205][3605];

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

	memset(dp,-1,sizeof(dp));
	cin>>n>>k;
	forn(i,n){
		cin>>a;
		b=c=0;
		while(a%2==0){ a/=2; b++; }
		while(a%5==0){ a/=5; c++; }
		if(b || c) v.pb(mp(b,c));
	}
	n = v.size();

	dp[0][0][0] = 0;

	for(i=0;i<n;i++){
		// 1 = act  0 = old
		for(j= 1 ; j<=k ; j++){
			for(x=v[i].se;x<=3600;x++){
				//dp[1][j][x] = dp[0][j][x];
				if(dp[0][j-1][x-v[i].se]!=-1) dp[1][j][x] = max( dp[0][j][x] , dp[0][j-1][x-v[i].se] + v[i].fi );
			}
		}
		for(j= 1 ; j<=k ; j++) for(x=0;x<=3600;x++) dp[0][j][x] = dp[1][j][x];
	}

	a=0;  // i pot5    dp[][] pot2
	for(i=0;i<=3600;i++){ a = max(a, min(i,dp[0][k][i]) );} //dbg2(i,dp[k][i])}

	cout<<a;

	cout<<'\n';
}


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

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define EPS 1e-9
#define INF  1e15 +1    /// 10^15 + 1
#define INF2 1<<63 /// 2^63
#define all(a)  a.begin(),a.end()
#define forn(i,n) for(int i=0;i<n;i++)
#define dbg(x) cout << #x"=" << x << '\n';
#define dbg2(x,y) cout << #x"=" << x << " " << #y"=" << y << '\n';
#define dbg3(x,y,z) cout << #x"=" << x << " " << #y"=" << y << " " << #z"=" << z << '\n';
#define MOD 1000000007

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector < vi > vvi;
typedef vector < vll > vvll;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;
typedef vector < pii > vpii;
typedef vector < pll > vpll;
typedef vector < vpii > vvpii;
typedef vector < vpll > vvpll;

ll n,x,i,j,k,a,b,c,m,h,t,y,q;
vpll v;
ll MAXI = 3605*2;
ll dp[2][205][3605*2];

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

	memset(dp,-1,sizeof(dp));
	cin>>n>>k;
	forn(i,n){
		cin>>a;
		b=c=0;
		while(a%2==0){ a/=2; b++; }
		while(a%5==0){ a/=5; c++; }
		if(b || c) v.pb(mp(b,c));
	}
	n = v.size();

	dp[0][0][0] = 0;

	a=0;
	for(i=0;i<n;i++){
		// 1 = act  0 = old
		for(j= 1 ; j<=k ; j++){
			for(x=v[i].se;x<=MAXI;x++){
				if(dp[0][j-1][x-v[i].se]!=-1) dp[1][j][x] = max( dp[1][j][x] , dp[0][j-1][x-v[i].se] + v[i].fi );
				dp[1][j][x] = max(dp[1][j][x],dp[0][j][x]);
				a = max(a, min(x,dp[1][j][x]) );
				//cout<<dp[1][j][x]<<" ";
			}   //cout<<'\n';
		}       //cout<<'\n';
		for(j= 1 ; j<=k ; j++) for(x=0;x<=MAXI;x++) dp[0][j][x] = dp[1][j][x];
	}

	cout<<a;

	cout<<'\n';
}


#include <bits/stdc++.h>
#define int long long
#define st first
#define inf 1000600000000000004
#define nd second
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define mt make_tuple
#define e(a, b) get<b>(a)
using namespace std;
map<pair<int, int>, int> M, M2;
int dp[207][6007];
int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k;
	cin>>n>>k;
	int a;
	for(int i=0; i<=n; i++)
	{
		for (int j=0; j<=30*n; j++)
		{
			dp[i][j]=-inf;
		}
	}
	dp[0][0]=0;
	for (int i=0; i<n; i++)
	{
		cin>>a;
		int p=0;
		for(;a%5==0;a/=5)
			p++;
		int d=0;
		for(;a%2==0;a/=2)
			d++;
		for (int j=k-1; j>=0; j--)
		{
			for (int k=0; k<=30*n; k++)
			{
				dp[j+1][k+p]=max(dp[j+1][k+p], dp[j][k]+d);
			}
		}
	}
	int wynik=0;
	for (int j=0; j<=30*n; j++)
	{
			wynik=max(wynik, min(j, dp[k][j]));
	}
	cout<<wynik;
	return 0;
}


#include <bits/stdc++.h>
#define int long long
#define st first
#define inf 1000600000000000004
#define nd second
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define mt make_tuple
#define e(a, b) get<b>(a)
using namespace std;
map<pair<int, int>, int> M, M2;
int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k;
	cin>>n>>k;
	int a;
	M[{0, 0}]=0;
	for (int i=0; i<n; i++)
	{
		cin>>a;
		int d=0;
		while(a%2==0)
		{
			d++;
			a/=2;
		}
		int p=0;
		while(a%5==0)
		{
			p++;
			a/=5;
		}
		//M2.clear();
		for (auto it : M)
		{
			M2[it.st]=it.nd;
		}
		for (auto it : M2)
		{
			if (M.find({it.st.st+d, it.st.nd+p})==M.end())
			{
				M[{it.st.st+d, it.st.nd+p}]=it.nd+1;
			}
			else
				M[{it.st.st+d, it.st.nd+p}]=min(M[{it.st.st+d, it.st.nd+p}], it.nd+1);
		}
		/*for (auto it : M)
		{
			cout<<it.st.st<<","<<it.st.nd<<": "<<it.nd<<"    ";
		}
		cout<<"\n";*/
	}
	int wynik=0;
	for (auto it : M)
	{
		if (it.nd<=k)
		{
			wynik=max(wynik, min(it.st.st, it.st.nd));
		}
	}
	cout<<wynik;
	return 0;
}


#include <bits/stdc++.h>
#define int long long
#define st first
#define inf 1000600000000000004
#define nd second
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define mt make_tuple
#define e(a, b) get<b>(a)
using namespace std;
map<pair<int, int>, int> M, M2;
int dp[207][6007];
int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k;
	cin>>n>>k;
	int a;
	for(int i=0; i<=n; i++)
	{
		for (int j=0; j<=30*n; j++)
		{
			dp[i][j]=inf;
		}
	}
	dp[0][0]=0;
	for (int i=0; i<n; i++)
	{
		cin>>a;
		int p=0;
		for(;a%5==0;a/=5)
			p++;
		int d=0;
		for(;a%2==0;a/=2)
			d++;
		for (int j=k-1; j>=0; j--)
		{
			for (int k=0; k<=30*n; k++)
			{
				dp[j+1][k+p]=max(dp[j+1][k+p], dp[j][k]+d);
			}
		}
	}
	int wynik=0;
	for (int j=0; j<=30*n; j++)
	{
		if (dp[k][j]<inf)
			wynik=max(wynik, min(j, dp[k][j]));
	}
	cout<<wynik;
	return 0;
}


#include <bits/stdc++.h>
#define int long long
#define st first
#define inf 1000600000000000004
#define nd second
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define mt make_tuple
#define e(a, b) get<b>(a)
using namespace std;
map<pair<int, int>, int> M, M2;
int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k;
	cin>>n>>k;
	int a;
	M[{0, 0}]=0;
	for (int i=0; i<n; i++)
	{
		cin>>a;
		int d=0;
		while(a%2==0)
		{
			d++;
			a/=2;
		}
		int p=0;
		while(a%5==0)
		{
			p++;
			a/=5;
		}
		//M2.clear();
		for (auto it : M)
		{
			M2[it.st]=it.nd;
		}
		for (auto it : M2)
		{
			if (M.find({it.st.st+d, it.st.nd+p})==M.end())
			{
				M[{it.st.st+d, it.st.nd+p}]=it.nd+1;
			}
			else
				M[{it.st.st+d, it.st.nd+p}]=min(M[{it.st.st+d, it.st.nd+p}], it.nd+1);
		}
		/*for (auto it : M2)
		{
			cout<<it.st.st<<","<<it.st.nd<<": "<<it.nd<<"    ";
		}
		cout<<"\n";*/
	}
	int wynik=0;
	for (auto it : M)
	{
		if (it.nd==k)
		{
			wynik=max(wynik, min(it.st.st, it.st.nd));
		}
	}
	cout<<wynik;
	return 0;
}


#include <bits/stdc++.h>
#define int long long
#define st first
#define inf 1000600000000000004
#define nd second
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define mt make_tuple
#define e(a, b) get<b>(a)
using namespace std;
map<pair<int, int>, int> M, M2;
int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k;
	cin>>n>>k;
	int a;
	M[{0, 0}]=0;
	for (int i=0; i<n; i++)
	{
		cin>>a;
		int d=0;
		while(a%2==0)
		{
			d++;
			a/=2;
		}
		int p=0;
		while(a%5==0)
		{
			p++;
			a/=5;
		}
		M2.clear();
		for (auto it : M)
		{
			M2[it.st]=it.nd;
		}
		for (auto it : M2)
		{
			M[{it.st.st+d, it.st.nd+p}]=min(M[{it.st.st+d, it.st.nd+p}]==0 ? inf : M[{it.st.st+d, it.st.nd+p}], it.nd+1);
		}
		/*for (auto it : M2)
		{
			cout<<it.st.st<<","<<it.st.nd<<": "<<it.nd<<"    ";
		}
		cout<<"\n";*/
	}
	int wynik=0;
	for (auto it : M)
	{
		if (it.nd<=k)
		{
			wynik=max(wynik, min(it.st.st, it.st.nd));
		}
	}
	cout<<wynik;
	return 0;
}


#include <bits/stdc++.h>
#define int long long
#define st first
#define inf 1000600000000000004
#define nd second
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define mt make_tuple
#define e(a, b) get<b>(a)
using namespace std;
map<pair<int, int>, int> M, M2;
int dp[207][6007];
int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k;
	cin>>n>>k;
	int a;
	for(int i=0; i<=n; i++)
	{
		for (int j=0; j<=30*n; j++)
		{
			dp[i][j]=inf;
		}
	}
	dp[0][0]=0;
	for (int i=0; i<n; i++)
	{
		cin>>a;
		int p=0;
		for(;a%5==0;a/=5)
			p++;
		int d=0;
		for(;a%2==0;a/=2)
			d++;
		for (int j=k-1; j>=0; j--)
		{
			for (int k=0; k<=30*n; k++)
			{
				dp[j+1][k+p]=min(dp[j+1][k+p], dp[j][k]+d);
			}
		}
	}
	int wynik=0;
	for (int j=0; j<=30*n; j++)
	{
		if (dp[k][j]<inf)
			wynik=max(wynik, min(j, dp[k][j]));
	}
	cout<<wynik;
	return 0;
}


#include <bits/stdc++.h>
#define int long long
#define st first
#define inf 1000600000000000004
#define nd second
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define mt make_tuple
#define e(a, b) get<b>(a)
using namespace std;
unordered_map<pair<int, int>, int> M, M2;
int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k;
	cin>>n>>k;
	int a;
	M[{0, 0}]=0;
	for (int i=0; i<n; i++)
	{
		cin>>a;
		int d=0;
		while(a%2==0)
		{
			d++;
			a/=2;
		}
		int p=0;
		while(a%5==0)
		{
			p++;
			a/=5;
		}
		//M2.clear();
		for (auto it : M)
		{
			M2[it.st]=it.nd;
		}
		for (auto it : M2)
		{
			if (M.find({it.st.st+d, it.st.nd+p})==M.end())
			{
				M[{it.st.st+d, it.st.nd+p}]=it.nd+1;
			}
			else
				M[{it.st.st+d, it.st.nd+p}]=min(M[{it.st.st+d, it.st.nd+p}], it.nd+1);
		}
		/*for (auto it : M)
		{
			cout<<it.st.st<<","<<it.st.nd<<": "<<it.nd<<"    ";
		}
		cout<<"\n";*/
	}
	int wynik=0;
	for (auto it : M)
	{
		if (it.nd<=k)
		{
			wynik=max(wynik, min(it.st.st, it.st.nd));
		}
	}
	cout<<wynik;
	return 0;
}


#include <bits/stdc++.h>
#define int long long
#define st first
#define inf 1000600000000000004
#define nd second
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define mt make_tuple
#define e(a, b) get<b>(a)
using namespace std;
map<pair<int, int>, int> M, M2;
int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k;
	cin>>n>>k;
	int a;
	M[{0, 0}]=0;
	for (int i=0; i<n; i++)
	{
		cin>>a;
		int d=0;
		while(a%2==0)
		{
			d++;
			a/=2;
		}
		int p=0;
		while(a%5==0)
		{
			p++;
			a/=5;
		}
		//M2.clear();
		for (auto it : M)
		{
			M2[it.st]=it.nd;
		}
		for (auto it : M2)
		{
			M[{it.st.st+d, it.st.nd+p}]=min(M[{it.st.st+d, it.st.nd+p}]==0 ? inf : M[{it.st.st+d, it.st.nd+p}], it.nd+1);
		}
		/*for (auto it : M2)
		{
			cout<<it.st.st<<","<<it.st.nd<<": "<<it.nd<<"    ";
		}
		cout<<"\n";*/
	}
	int wynik=0;
	for (auto it : M)
	{
		if (it.nd==k)
		{
			wynik=max(wynik, min(it.st.st, it.st.nd));
		}
	}
	cout<<wynik;
	return 0;
}


#include <bits/stdc++.h>
#define int long long
#define st first
#define inf 1000600000000000004
#define nd second
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define mt make_tuple
#define e(a, b) get<b>(a)
using namespace std;
map<pair<int, int>, int> M, M2;
int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k;
	cin>>n>>k;
	int a;
	M[{0, 0}]=0;
	for (int i=0; i<n; i++)
	{
		cin>>a;
		int d=0;
		while(a%2==0)
		{
			d++;
			a/=2;
		}
		int p=0;
		while(a%5==0)
		{
			p++;
			a/=5;
		}
		//M2.clear();
		for (auto it : M)
		{
			M2[it.st]=it.nd;
		}
		for (auto it : M2)
		{
			if (M.find({it.st.st+d, it.st.nd+p})==M.end())
			{
				M[{it.st.st+d, it.st.nd+p}]=it.nd+1;
			}
			else
				M[{it.st.st+d, it.st.nd+p}]=min(M[{it.st.st+d, it.st.nd+p}], it.nd+1);
		}
		for (auto it : M)
		{
			cout<<it.st.st<<","<<it.st.nd<<": "<<it.nd<<"    ";
		}
		cout<<"\n";
	}
	int wynik=0;
	for (auto it : M)
	{
		if (it.nd<=k)
		{
			wynik=max(wynik, min(it.st.st, it.st.nd));
		}
	}
	cout<<wynik;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define SZ(x) ((int)(x.size()))
#define fi first
#define se second
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define FORI(i,n) for(int (i)=1;(i)<=(n);++(i))
#define IN(x,y) ((y).find((x))!=(y).end())
#define ALL(t) t.begin(),t.end()
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define REP(i,a,b) for(int (i)=(a);(i)<=(b);++i)
#define REPD(i,a,b) for(int (i)=(a); (i)>=(b);--i)
#define REMAX(a,b) (a)=max((a),(b));
#define REMIN(a,b) (a)=min((a),(b));
#define DBG cerr << "debug here" << endl;
#define DBGV(vari) cerr << #vari<< " = "<< (vari) <<endl;

typedef long long ll;
const int INF = 1e9;

const int N = 200+2;
ll a[N];
int d2[N];
int d5[N];
const int B2 = 62;
const int B5 = 27;
bool dp[N][N][B2][B5];

int main()
{
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        auto b = a[i];
        while (b % 2 == 0) {
            d2[i]++;
            b /= 2;
        }
        b = a[i];
        while (b % 5 == 0) {
            d5[i]++;
            b /= 5;
        }
    }
    dp[0][0][0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        dp[i][0][0][0] = 1;
        for (int j = 0; j <= k; ++j) {
            for (int k2 = 0; k2 < B2; ++k2) {
                for (int k5 = 0; k5 < B5; ++k5) {
                    dp[i][j][k2][k5] |= dp[i-1][j][k2][k5];
                    if (j > 0 && d2[i] <= k2 && d5[i] <= k5) {
                        dp[i][j][k2][k5] |= dp[i-1][j-1][k2-d2[i]][k5-d5[i]];
                    }
                }
            }
        }
    }

    int res = 0;
    for (int k2 = 0; k2 < B2; ++k2) {
        for (int k5 = 0; k5 < B5; ++k5) {
            if (dp[n][k][k2][k5]) {
                res = max(res, min(k2, k5));
            }
        }
    }
    cout << res << endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define SZ(x) ((int)(x.size()))
#define fi first
#define se second
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define FORI(i,n) for(int (i)=1;(i)<=(n);++(i))
#define IN(x,y) ((y).find((x))!=(y).end())
#define ALL(t) t.begin(),t.end()
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define REP(i,a,b) for(int (i)=(a);(i)<=(b);++i)
#define REPD(i,a,b) for(int (i)=(a); (i)>=(b);--i)
#define REMAX(a,b) (a)=max((a),(b));
#define REMIN(a,b) (a)=min((a),(b));
#define DBG cerr << "debug here" << endl;
#define DBGV(vari) cerr << #vari<< " = "<< (vari) <<endl;

typedef long long ll;
const int INF = 1e9;

const int N = 200+2;
ll a[N];
int d2[N];
int d5[N];

const int MAXF5 = N*26;
int dp[2][N][MAXF5+1];

int main()
{
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        auto b = a[i];
        while (b % 2 == 0) {
            d2[i]++;
            b /= 2;
        }
        b = a[i];
        while (b % 5 == 0) {
            d5[i]++;
            b /= 5;
        }
    }

    for (int i = 0; i < 2; ++i) {
        for (int j = 0; j <= k; ++j) {
            for (int f5 = 0; f5 <= MAXF5; ++f5) {
                dp[i][j][f5] = -1;
            }
        }
    }
    int cur = 0;
    dp[cur][0][0] = 0;

    for (int i = 1; i <= n; ++i) {
        cur = 1-cur;
        for (int j = 0; j <= i; ++j) {
            for (int f5 = 0; f5 <= MAXF5; ++f5) {
                dp[cur][j][f5] = dp[1-cur][j][f5];
                if (j > 0 && f5 - d5[i] >= 0 && dp[1-cur][j-1][f5-d5[i]] != -1) {
                    REMAX(dp[cur][j][f5], dp[1-cur][j-1][f5-d5[i]] + d2[i]);
                }
            }
        }
    }
    int res = 0;
    for (int f5 = 0; f5 <= MAXF5; ++f5) {
        if (dp[cur][k][f5] != -1) {
            REMAX(res, min(f5, dp[cur][k][f5]));
        }
    }
    cout << res << endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define SZ(x) ((int)(x.size()))
#define fi first
#define se second
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define FORI(i,n) for(int (i)=1;(i)<=(n);++(i))
#define IN(x,y) ((y).find((x))!=(y).end())
#define ALL(t) t.begin(),t.end()
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define REP(i,a,b) for(int (i)=(a);(i)<=(b);++i)
#define REPD(i,a,b) for(int (i)=(a); (i)>=(b);--i)
#define REMAX(a,b) (a)=max((a),(b));
#define REMIN(a,b) (a)=min((a),(b));
#define DBG cerr << "debug here" << endl;
#define DBGV(vari) cerr << #vari<< " = "<< (vari) <<endl;

typedef long long ll;
const int INF = 1e9;

const int N = 200+2;
ll a[N];
int d2[N];
int d5[N];
set<pii> dp[2][N];

int main()
{
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        auto b = a[i];
        while (b % 2 == 0) {
            d2[i]++;
            b /= 2;
        }
        b = a[i];
        while (b % 5 == 0) {
            d5[i]++;
            b /= 5;
        }
    }
    int cur = 0;
    dp[cur][0].insert(mp(0,0));
    for (int i = 1; i <= n; ++i) {
        cur = 1-cur;
        for (int j = 0; j <= i; ++j) {
            dp[cur][j].clear();
            dp[cur][j] = dp[1-cur][j];
            if (j > 0) {
                for (auto it = dp[1-cur][j-1].begin(); it != dp[1-cur][j-1].end(); ++it) {
                    int k2 = it->fi;
                    int k5 = it->se;
                    dp[cur][j].insert(mp(k2+d2[i], k5+d5[i]));
                }
            }
        }
    }

    int res = 0;
    for (auto it = dp[cur][k].begin(); it != dp[cur][k].end(); ++it) {
        int k2 = it->fi;
        int k5 = it->se;
        res = max(res, min(k2,k5));
    }
    cout << res << endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define SZ(x) ((int)(x.size()))
#define fi first
#define se second
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define FORI(i,n) for(int (i)=1;(i)<=(n);++(i))
#define IN(x,y) ((y).find((x))!=(y).end())
#define ALL(t) t.begin(),t.end()
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define REP(i,a,b) for(int (i)=(a);(i)<=(b);++i)
#define REPD(i,a,b) for(int (i)=(a); (i)>=(b);--i)
#define REMAX(a,b) (a)=max((a),(b));
#define REMIN(a,b) (a)=min((a),(b));
#define DBG cerr << "debug here" << endl;
#define DBGV(vari) cerr << #vari<< " = "<< (vari) <<endl;

typedef long long ll;
const int INF = 1e9;

const int N = 200+2;
ll a[N];
int d2[N];
int d5[N];
set<pii> dp[2][N];

int main()
{
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        auto b = a[i];
        while (b % 2 == 0) {
            d2[i]++;
            b /= 2;
        }
        b = a[i];
        while (b % 5 == 0) {
            d5[i]++;
            b /= 5;
        }
    }
    int cur = 0;
    dp[cur][0].insert(mp(0,0));
    for (int i = 1; i <= n; ++i) {
        cur = 1-cur;
        for (int j = 0; j <= i; ++j) {
            dp[cur][j] = dp[1-cur][j];
            if (j > 0) {
                for (auto it = dp[1-cur][j-1].begin(); it != dp[1-cur][j-1].end(); ++it) {
                    int k2 = it->fi;
                    int k5 = it->se;
                    dp[cur][j].insert(mp(k2+d2[i], k5+d5[i]));
                }
            }
            map<int, int> m2;
            map<int, int> m5;
            for (auto it = dp[cur][j].begin(); it != dp[cur][j].end(); ++it) {
                int k2 = it->fi;
                int k5 = it->se;
                {
                    auto it = m2.find(k2);
                    if (it == m2.end()) {
                        m2.insert(mp(k2, k5));
                    } else {
                        REMAX(it->se, k5);
                    }
                }
                {
                    auto it = m5.find(k2);
                    if (it == m5.end()) {
                        m5.insert(mp(k5, k2));
                    } else {
                        REMAX(it->se, k2);
                    }
                }
            }
            auto it = dp[cur][j].begin();
            while (it != dp[cur][j].end()) {
                int k2 = it->fi;
                int k5 = it->se;
                auto mm2 = m2.find(k2)->se;
                auto mm5 = m5.find(k5)->se;

                if (k5 < mm2 && k2 < mm5) {
                    auto tmpit = it;
                    tmpit++;
                    dp[cur][j].erase(it);
                    it = tmpit;
                } else {
                    ++it;
                }
            }
        }
    }

    int res = 0;
    for (auto it = dp[cur][k].begin(); it != dp[cur][k].end(); ++it) {
        int k2 = it->fi;
        int k5 = it->se;
        res = max(res, min(k2,k5));
    }
    cout << res << endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define SZ(x) ((int)(x.size()))
#define fi first
#define se second
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define FORI(i,n) for(int (i)=1;(i)<=(n);++(i))
#define IN(x,y) ((y).find((x))!=(y).end())
#define ALL(t) t.begin(),t.end()
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define REP(i,a,b) for(int (i)=(a);(i)<=(b);++i)
#define REPD(i,a,b) for(int (i)=(a); (i)>=(b);--i)
#define REMAX(a,b) (a)=max((a),(b));
#define REMIN(a,b) (a)=min((a),(b));
#define DBG cerr << "debug here" << endl;
#define DBGV(vari) cerr << #vari<< " = "<< (vari) <<endl;

typedef long long ll;
const int INF = 1e9;

const int N = 200+2;
ll a[N];
int d2[N];
int d5[N];

const int MAXF5 = N*26;
int dp[N][N][MAXF5+1];

int main()
{
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        auto b = a[i];
        while (b % 2 == 0) {
            d2[i]++;
            b /= 2;
        }
        b = a[i];
        while (b % 5 == 0) {
            d5[i]++;
            b /= 5;
        }
    }

    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= k; ++j) {
            for (int f5 = 0; f5 <= MAXF5; ++f5) {
                dp[i][j][f5] = -1;
            }
        }
    }
    dp[0][0][0] = 0;

    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= i; ++j) {
            for (int f5 = 0; f5 <= MAXF5; ++f5) {
                dp[i][j][f5] = dp[i-1][j][f5];
                if (j > 0 && f5 - d5[i] >= 0 && dp[i-1][j-1][f5-d5[i]] != -1) {
                    REMAX(dp[i][j][f5], dp[i-1][j-1][f5-d5[i]] + d2[i]);
                }
            }
        }
    }
    int res = 0;
    for (int f5 = 0; f5 <= MAXF5; ++f5) {
        if (dp[n][k][f5] != -1) {
            REMAX(res, min(f5, dp[n][k][f5]));
        }
    }
    cout << res << endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define SZ(x) ((int)(x.size()))
#define fi first
#define se second
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define FORI(i,n) for(int (i)=1;(i)<=(n);++(i))
#define IN(x,y) ((y).find((x))!=(y).end())
#define ALL(t) t.begin(),t.end()
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define REP(i,a,b) for(int (i)=(a);(i)<=(b);++i)
#define REPD(i,a,b) for(int (i)=(a); (i)>=(b);--i)
#define REMAX(a,b) (a)=max((a),(b));
#define REMIN(a,b) (a)=min((a),(b));
#define DBG cerr << "debug here" << endl;
#define DBGV(vari) cerr << #vari<< " = "<< (vari) <<endl;

typedef long long ll;
const int INF = 1e9;

const int N = 200+2;
ll a[N];
int d2[N];
int d5[N];
set<pii> dp[2][N];

int main()
{
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        auto b = a[i];
        while (b % 2 == 0) {
            d2[i]++;
            b /= 2;
        }
        b = a[i];
        while (b % 5 == 0) {
            d5[i]++;
            b /= 5;
        }
    }
    int cur = 0;
    dp[cur][0].insert(mp(0,0));
    for (int i = 1; i <= n; ++i) {
        cur = 1-cur;
        for (int j = 0; j <= i; ++j) {
            dp[cur][j] = dp[1-cur][j];
            if (j > 0) {
                for (auto it = dp[1-cur][j-1].begin(); it != dp[1-cur][j-1].end(); ++it) {
                    int k2 = it->fi;
                    int k5 = it->se;
                    dp[cur][j].insert(mp(k2+d2[i], k5+d5[i]));
                }
            }
            map<int, int> m2;
            map<int, int> m5;
            for (auto it = dp[cur][j].begin(); it != dp[cur][j].end(); ++it) {
                int k2 = it->fi;
                int k5 = it->se;
                {
                    auto it = m2.find(k2);
                    if (it == m2.end()) {
                        m2.insert(mp(k2, k5));
                    } else {
                        REMAX(it->se, k5);
                    }
                }
                {
                    auto it = m5.find(k2);
                    if (it == m5.end()) {
                        m5.insert(mp(k5, k2));
                    } else {
                        REMAX(it->se, k2);
                    }
                }
            }
            auto it = dp[cur][j].begin();
            while (it != dp[cur][j].end()) {
                int k2 = it->fi;
                int k5 = it->se;
                auto mm2 = m2.find(k2)->se;
                auto mm5 = m5.find(k5)->se;

                if (k5 != mm2 && k2 != mm5 && k5 <= mm2 && k2 <= mm5) {
                    auto tmpit = it;
                    tmpit++;
                    dp[cur][j].erase(it);
                    it = tmpit;
                } else {
                    ++it;
                }
            }
        }
    }

    int res = 0;
    for (auto it = dp[cur][k].begin(); it != dp[cur][k].end(); ++it) {
        int k2 = it->fi;
        int k5 = it->se;
        res = max(res, min(k2,k5));
    }
    cout << res << endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define SZ(x) ((int)(x.size()))
#define fi first
#define se second
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define FORI(i,n) for(int (i)=1;(i)<=(n);++(i))
#define IN(x,y) ((y).find((x))!=(y).end())
#define ALL(t) t.begin(),t.end()
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define REP(i,a,b) for(int (i)=(a);(i)<=(b);++i)
#define REPD(i,a,b) for(int (i)=(a); (i)>=(b);--i)
#define REMAX(a,b) (a)=max((a),(b));
#define REMIN(a,b) (a)=min((a),(b));
#define DBG cerr << "debug here" << endl;
#define DBGV(vari) cerr << #vari<< " = "<< (vari) <<endl;

typedef long long ll;
const int INF = 1e9;

const int N = 200+2;
ll a[N];
int d2[N];
int d5[N];
set<pii> dp[2][N];

int main()
{
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        auto b = a[i];
        while (b % 2 == 0) {
            d2[i]++;
            b /= 2;
        }
        b = a[i];
        while (b % 5 == 0) {
            d5[i]++;
            b /= 5;
        }
    }
    int cur = 0;
    dp[cur][0].insert(mp(0,0));
    for (int i = 1; i <= n; ++i) {
        cur = 1-cur;
        for (int j = 0; j <= i; ++j) {
            dp[cur][j] = dp[1-cur][j];
            if (j > 0) {
                for (auto it = dp[1-cur][j-1].begin(); it != dp[1-cur][j-1].end(); ++it) {
                    int k2 = it->fi;
                    int k5 = it->se;
                    dp[cur][j].insert(mp(k2+d2[i], k5+d5[i]));
                }
            }
            int mm = 0;
            for (auto it = dp[cur][j].begin(); it != dp[cur][j].end(); ++it) {
                int k2 = it->fi;
                int k5 = it->se;
                mm = max(mm, min(k2, k5));
            }
            auto it = dp[cur][j].begin();
            while (it != dp[cur][j].end()) {
                int k2 = it->fi;
                int k5 = it->se;
                if (max(k2, k5) < mm) {
                    auto tmpit = it;
                    tmpit++;
                    dp[cur][j].erase(it);
                    it = tmpit;
                } else {
                    ++it;
                }
            }
        }
    }

    int res = 0;
    for (auto it = dp[cur][k].begin(); it != dp[cur][k].end(); ++it) {
        int k2 = it->fi;
        int k5 = it->se;
        res = max(res, min(k2,k5));
    }
    cout << res << endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define SZ(x) ((int)(x.size()))
#define fi first
#define se second
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define FORI(i,n) for(int (i)=1;(i)<=(n);++(i))
#define IN(x,y) ((y).find((x))!=(y).end())
#define ALL(t) t.begin(),t.end()
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define REP(i,a,b) for(int (i)=(a);(i)<=(b);++i)
#define REPD(i,a,b) for(int (i)=(a); (i)>=(b);--i)
#define REMAX(a,b) (a)=max((a),(b));
#define REMIN(a,b) (a)=min((a),(b));
#define DBG cerr << "debug here" << endl;
#define DBGV(vari) cerr << #vari<< " = "<< (vari) <<endl;

typedef long long ll;
const int INF = 1e9;

const int N = 200+2;
ll a[N];
int d2[N];
int d5[N];
set<pii> dp[2][N];

int main()
{
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        auto b = a[i];
        while (b % 2 == 0) {
            d2[i]++;
            b /= 2;
        }
        b = a[i];
        while (b % 5 == 0) {
            d5[i]++;
            b /= 5;
        }
    }
    int cur = 0;
    dp[cur][0].insert(mp(0,0));
    for (int i = 1; i <= n; ++i) {
        cur = 1-cur;
        for (int j = 0; j <= i; ++j) {
            dp[cur][j] = dp[1-cur][j];
            if (j > 0) {
                for (auto it = dp[1-cur][j-1].begin(); it != dp[1-cur][j-1].end(); ++it) {
                    int k2 = it->fi;
                    int k5 = it->se;
                    dp[cur][j].insert(mp(k2+d2[i], k5+d5[i]));
                }
            }
            int mm = 0;
            int mm2 = 0;
            int mm5 = 0;
            for (auto it = dp[cur][j].begin(); it != dp[cur][j].end(); ++it) {
                int k2 = it->fi;
                int k5 = it->se;
                int now = min(k2, k5);
                if (now > mm) {
                    mm = cur;
                    mm2 = k2;
                    mm5 = k5;
                } else if (now == mm) {
                    mm2 = max(mm2, k2);
                    mm5 = max(mm5, k5);
                }
            }
            auto it = dp[cur][j].begin();
            while (it != dp[cur][j].end()) {
                int k2 = it->fi;
                int k5 = it->se;
                int now = max(k2, k5);
                if (now < mm || (now == mm && (k2 < mm2 || k5 < mm5))) {
                    auto tmpit = it;
                    tmpit++;
                    dp[cur][j].erase(it);
                    it = tmpit;
                } else {
                    ++it;
                }
            }
        }
    }

    int res = 0;
    for (auto it = dp[cur][k].begin(); it != dp[cur][k].end(); ++it) {
        int k2 = it->fi;
        int k5 = it->se;
        res = max(res, min(k2,k5));
    }
    cout << res << endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define SZ(x) ((int)(x.size()))
#define fi first
#define se second
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define FORI(i,n) for(int (i)=1;(i)<=(n);++(i))
#define IN(x,y) ((y).find((x))!=(y).end())
#define ALL(t) t.begin(),t.end()
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define REP(i,a,b) for(int (i)=(a);(i)<=(b);++i)
#define REPD(i,a,b) for(int (i)=(a); (i)>=(b);--i)
#define REMAX(a,b) (a)=max((a),(b));
#define REMIN(a,b) (a)=min((a),(b));
#define DBG cerr << "debug here" << endl;
#define DBGV(vari) cerr << #vari<< " = "<< (vari) <<endl;

typedef long long ll;
const int INF = 1e9;

const int N = 200+2;
ll a[N];
int d2[N];
int d5[N];
const int B2 = 64;
const int B5 = 40;
bool dp[N][N][B2][B5];

int main()
{
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        auto b = a[i];
        while (b % 2 == 0) {
            d2[i]++;
            b /= 2;
        }
        b = a[i];
        while (b % 5 == 0) {
            d5[i]++;
            b /= 5;
        }
    }
    dp[0][0][0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        dp[i][0][0][0] = 1;
        for (int j = 0; j <= k; ++j) {
            for (int k2 = 0; k2 < B2; ++k2) {
                for (int k5 = 0; k5 < B5; ++k5) {
                    dp[i][j][k2][k5] |= dp[i-1][j][k2][k5];
                    if (j > 0 && d2[i] <= k2 && d5[i] <= k5) {
                        dp[i][j][k2][k5] |= dp[i-1][j-1][k2-d2[i]][k5-d5[i]];
                    }
                }
            }
        }
    }

    int res = 0;
    for (int k2 = 0; k2 < B2; ++k2) {
        for (int k5 = 0; k5 < B5; ++k5) {
            if (dp[n][k][k2][k5]) {
                res = max(res, min(k2, k5));
            }
        }
    }
    cout << res << endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define SZ(x) ((int)(x.size()))
#define fi first
#define se second
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define FORI(i,n) for(int (i)=1;(i)<=(n);++(i))
#define IN(x,y) ((y).find((x))!=(y).end())
#define ALL(t) t.begin(),t.end()
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define REP(i,a,b) for(int (i)=(a);(i)<=(b);++i)
#define REPD(i,a,b) for(int (i)=(a); (i)>=(b);--i)
#define REMAX(a,b) (a)=max((a),(b));
#define REMIN(a,b) (a)=min((a),(b));
#define DBG cerr << "debug here" << endl;
#define DBGV(vari) cerr << #vari<< " = "<< (vari) <<endl;

typedef long long ll;
const int INF = 1e9;

const int N = 200+2;
ll a[N];
int d2[N];
int d5[N];
const int B2 = 60;
const int B5 = 26;
bool dp[N][N][B2][B5];

int main()
{
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        ll b = a[i];
        while (b % 2 == 0) {
            d2[i]++;
            b /= 2;
        }
        b = a[i];
        while (b % 5 == 0) {
            d5[i]++;
            b /= 5;
        }
    }
    dp[0][0][0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        dp[i][0][0][0] = 1;
        for (int j = 1; j <= k; ++j) {
            for (int k2 = 0; k2 < B2; ++k2) {
                for (int k5 = 0; k5 < B5; ++k5) {
                    dp[i][j][k2][k5] |= dp[i-1][j][k2][k5];
                    if (d2[i] <= k2 && d5[i] <= k5) {
                        dp[i][j][k2][k5] |= dp[i-1][j-1][k2-d2[i]][k5-d5[i]];
                    }
                }
            }
        }
    }

    int res = 0;
    for (int k2 = 0; k2 < B2; ++k2) {
        for (int k5 = 0; k5 < B5; ++k5) {
            if (dp[n][k][k2][k5]) {
                res = max(res, min(k2, k5));
            }
        }
    }
    cout << res << endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define SZ(x) ((int)(x.size()))
#define fi first
#define se second
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define FORI(i,n) for(int (i)=1;(i)<=(n);++(i))
#define IN(x,y) ((y).find((x))!=(y).end())
#define ALL(t) t.begin(),t.end()
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define REP(i,a,b) for(int (i)=(a);(i)<=(b);++i)
#define REPD(i,a,b) for(int (i)=(a); (i)>=(b);--i)
#define REMAX(a,b) (a)=max((a),(b));
#define REMIN(a,b) (a)=min((a),(b));
#define DBG cerr << "debug here" << endl;
#define DBGV(vari) cerr << #vari<< " = "<< (vari) <<endl;

typedef long long ll;
const int INF = 1e9;

const int N = 200+2;
ll a[N];
int d2[N];
int d5[N];
set<pii> dp[2][N];

int main()
{
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        auto b = a[i];
        while (b % 2 == 0) {
            d2[i]++;
            b /= 2;
        }
        b = a[i];
        while (b % 5 == 0) {
            d5[i]++;
            b /= 5;
        }
    }
    int cur = 0;
    dp[cur][0].insert(mp(0,0));
    for (int i = 1; i <= n; ++i) {
        cur = 1-cur;
        for (int j = 0; j <= i; ++j) {
            dp[cur][j].clear();
            dp[cur][j] = dp[1-cur][j];
            if (j > 0) {
                for (auto it = dp[1-cur][j-1].begin(); it != dp[1-cur][j-1].end(); ++it) {
                    int k2 = it->fi;
                    int k5 = it->se;
                    dp[cur][j].insert(mp(k2+d2[i], k5+d5[i]));
                }
            }
            int m2 = 0;
            int m5 = 0;
            for (auto it = dp[cur][j].begin(); it != dp[cur][j].end(); ++it) {
                int k2 = it->fi;
                int k5 = it->se;
                m2 = max(m2, k2);
                m5 = max(m5, k5);
            }
            auto it = dp[cur][j].begin();
            while (it != dp[cur][j].end()) {
                int k2 = it->fi;
                int k5 = it->se;
                if (k2 != m2 && k5 != m5) {
                    auto tmpit = it;
                    tmpit++;
                    dp[cur][j].erase(it);
                    it = tmpit;
                } else {
                    ++it;
                }
            }
        }
    }

    int res = 0;
    for (auto it = dp[cur][k].begin(); it != dp[cur][k].end(); ++it) {
        int k2 = it->fi;
        int k5 = it->se;
        res = max(res, min(k2,k5));
    }
    cout << res << endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define SZ(x) ((int)(x.size()))
#define fi first
#define se second
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define FORI(i,n) for(int (i)=1;(i)<=(n);++(i))
#define IN(x,y) ((y).find((x))!=(y).end())
#define ALL(t) t.begin(),t.end()
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define REP(i,a,b) for(int (i)=(a);(i)<=(b);++i)
#define REPD(i,a,b) for(int (i)=(a); (i)>=(b);--i)
#define REMAX(a,b) (a)=max((a),(b));
#define REMIN(a,b) (a)=min((a),(b));
#define DBG cerr << "debug here" << endl;
#define DBGV(vari) cerr << #vari<< " = "<< (vari) <<endl;

typedef long long ll;
const int INF = 1e9;

const int N = 200+2;
ll a[N];
short d2[N];
short d5[N];

const int MAXF5 = N*26;
short dp[N][N][MAXF5+1];

int main()
{
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        auto b = a[i];
        while (b % 2 == 0) {
            d2[i]++;
            b /= 2;
        }
        b = a[i];
        while (b % 5 == 0) {
            d5[i]++;
            b /= 5;
        }
    }

    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= k; ++j) {
            for (int f5 = 0; f5 <= MAXF5; ++f5) {
                dp[i][j][f5] = -1;
            }
        }
    }
    dp[0][0][0] = 0;

    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= i; ++j) {
            for (short f5 = 0; f5 <= MAXF5; ++f5) {
                dp[i][j][f5] = dp[i-1][j][f5];
                if (j > 0 && f5 - d5[i] >= 0 && dp[i-1][j-1][f5-d5[i]] != -1) {
                    REMAX(dp[i][j][f5], short(dp[i-1][j-1][f5-d5[i]] + d2[i]));
                }
            }
        }
    }
    short res = 0;
    for (short f5 = 0; f5 <= MAXF5; ++f5) {
        if (dp[n][k][f5] != -1) {
            REMAX(res, min(f5, dp[n][k][f5]));
        }
    }
    cout << res << endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define SZ(x) ((int)(x.size()))
#define fi first
#define se second
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define FORI(i,n) for(int (i)=1;(i)<=(n);++(i))
#define IN(x,y) ((y).find((x))!=(y).end())
#define ALL(t) t.begin(),t.end()
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define REP(i,a,b) for(int (i)=(a);(i)<=(b);++i)
#define REPD(i,a,b) for(int (i)=(a); (i)>=(b);--i)
#define REMAX(a,b) (a)=max((a),(b));
#define REMIN(a,b) (a)=min((a),(b));
#define DBG cerr << "debug here" << endl;
#define DBGV(vari) cerr << #vari<< " = "<< (vari) <<endl;

typedef long long ll;
const int INF = 1e9;

const int N = 200+2;
ll a[N];
int d2[N];
int d5[N];
const int B2 = 62;
const int B5 = 27;
bool dp[N][N][B2][B5];

int main()
{
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        auto b = a[i];
        while (b % 2 == 0) {
            d2[i]++;
            b /= 2;
        }
        b = a[i];
        while (b % 5 == 0) {
            d5[i]++;
            b /= 5;
        }
    }
    dp[0][0][0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        dp[i][0][0][0] = 1;
        for (int j = 0; j <= i; ++j) {
            for (int k2 = 0; k2 < B2; ++k2) {
                for (int k5 = 0; k5 < B5; ++k5) {
                    dp[i][j][k2][k5] |= dp[i-1][j][k2][k5];
                    if (j > 0 && d2[i] <= k2 && d5[i] <= k5) {
                        dp[i][j][k2][k5] |= dp[i-1][j-1][k2-d2[i]][k5-d5[i]];
                    }
                }
            }
        }
    }

    int res = 0;
    for (int k2 = 0; k2 < B2; ++k2) {
        for (int k5 = 0; k5 < B5; ++k5) {
            if (dp[n][k][k2][k5]) {
                res = max(res, min(k2, k5));
            }
        }
    }
    cout << res << endl;
    return 0;
}


//#include<bits/stdc++.h>
//using namespace std;
//#define LL long long
//int main()
//{
//    LL t=1e18;
//    return 0;
//}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
short  dp[7200][2200];
long long   tu[201];
int  er[201], wu[201];
#define max(a,b)    (((a) > (b)) ? (a) : (b))
#define min(a,b)    (((a) < (b)) ? (a) : (b))
int  main()
{
//	cout << max(1, 2);
	//return 0;
//	memset(dp, -1, sizeof(dp));
//	cout << dp[0][1];
	int  n, k;
	scanf("%d%d", &n, &k);
	for (int a = 1; a <= n; a++)scanf("%I64d", &tu[a]);
	int  ee = 0, ww = 0;
	for (int a = 1; a <= n; a++)
	{
		long long   t = tu[a];
		while (t % 5 == 0)
		{
			wu[a]++;
			ww++;
			t /= 5;
		}
		while (t % 2 == 0)
		{
			er[a]++;
			ee++;
			t >>= 1;
		}
	}
//	cout << "yes\n";
/*	for (int  a = 1; a <= n; a++)cout << wu[a] << " ";
	cout << endl;
	for (int  a = 1; a <= n; a++)cout << er[a] << " ";
*///	return 0;
	memset(dp, -1, sizeof(dp));
	dp[0][0] = 0;
	int  dan = 0;

	for (int a = 1; a <= n; a++)
	{
		for (int b = ee; b >=0; b--)
		{
			if (b - er[a] < 0)continue;
			for (int c = ww; c>=0; c--)
			{
//                dp[b][c] = -1;
				if (c - wu[a] < 0)continue;
				if (dp[b - er[a]][c - wu[a]] >= 0 && dp[b][c]<0)
//                    dp[b][c] = min(dp[])
                    dp[b][c] = dp[b - er[a]][c - wu[a]] + 1;
				if(dp[b - er[a]][c - wu[a]]>=0)dp[b][c] = min(dp[b][c], dp[b - er[a]][c - wu[a]] + 1);
			}
		}
	}
/*	for (int a = 1; a <= ee; a++)
	{
		for (int b = 1; b <= ww; b++)
		{
			cout << (dp[a][b]>0?dp[a][b]:0) << " ";
		}
	}
	return 0;*/
	for (int a = 0; a <= ee; a++)
	{
		for (int b = 0; b <= ww; b++)
		{
			if (dp[a][b] < 0)continue;
			if (dp[a][b] > k)continue;
			dan = max(min(a, b), dan);
		}
	}
	printf("%d\n", dan);
}


#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define N 205
int n, k, dp[N][6000];
int two[N], five[N];
void solve()
{
    memset(two, 0, sizeof(two));
    memset(five, 0, sizeof(five));
    memset(dp, 0xbf, sizeof(dp));
    int tf=0;
    for(int i=1; i<=n; i++)
    {
        LL x, tmp;cin>>x;tmp=x;
        while(x%2==0)
        {
            two[i]++;
            x/=2;
        }
        x=tmp;
        while(x%5==0)
        {
            five[i]++;
            x/=5;
            tf++;
        }
    }
    dp[0][0] = 0;
    int ans = 0;
    for(int i=1; i<=n; i++)
        for(int j = min(k, i); j >= 1; j--)
            for(int k = tf; k >= five[i]; k--)
                dp[j][k] = max(dp[j][k], dp[j-1][k-five[i]]+two[i]);
    for(int i = 1; i <= tf; i++)
        ans = max(ans, min(dp[k][i], i));
    cout << ans << endl;
}
int main()
{
    while(cin>>n>>k)
    {
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define N 205
int n, k, dp[N][12050];
int two[N], five[N];
void solve()
{
    memset(two, 0, sizeof(two));
    memset(five, 0, sizeof(five));
    memset(dp, 0, sizeof(dp));
    int tf=0;
    for(int i=1; i<=n; i++)
    {
        LL x, tmp;cin>>x;tmp=x;
        while(x%2==0)
        {
            two[i]++;
            x/=2;
        }
        x=tmp;
        while(x%5==0)
        {
            five[i]++;
            x/=5;
            tf++;
        }
    }
    int ans = 0;
    for(int i=1; i<=n; i++)
        for(int j=tf; j>=five[i]; j--)
            dp[i][j] = max(dp[i-1][j-five[i]]+two[i], dp[i][j]);
    for(int i = 1; i <= tf; i++)
        ans = max(ans, min(dp[k][i], i));
    cout << ans << endl;
}
int main()
{
    while(cin>>n>>k)
    {
        solve();
    }
    return 0;
}


#include <cstdio>
#include <algorithm>
using namespace std;
#define mst(a,b) memset((a),(b),sizeof(a))
#define rush() int T;scanf("%d",&T);while(T--)

typedef long long ll;
const int maxn = 205;
const int maxm = 205*64;
const ll mod = 1e9+7;
const int INF = 0x3f3f3f;
const double eps = 1e-9;

int dp[maxn][maxm];
int n,k;
ll x;

int main()
{
    while(~scanf("%d%d",&n,&k))
    {
        for(int i=0;i<=k;i++)
        for(int j=0;j<maxm;j++)
        {
            dp[i][j]=-INF;
        }
        dp[0][0]=0;
        for(int i=0;i<n;i++)
        {
            int n2=0,n5=0;
            scanf("%I64d",&x);
            while(x%2==0) x/=2,n2++;
            while(x%5==0) x/=5,n5++;
            for(int j=k;j>=1;j--)
            for(int l=n2;l<maxm;l++)
            {
                dp[j][l]=max(dp[j][l],dp[j-1][l-n2]+n5);
            }
        }
        int ans=0;
        for(int i=1;i<maxm;i++)
        {
            ans=max(ans,min(i,dp[k][i]));
        }
        printf("%d\n",ans);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define N 205
int n, k, dp[N][12050];
int two[N], five[N];
void solve()
{
    memset(two, 0, sizeof(two));
    memset(five, 0, sizeof(five));
    memset(dp, 0, sizeof(dp));
    int tf=0;
    for(int i=1; i<=n; i++)
    {
        LL x, tmp;cin>>x;tmp=x;
        while(x%2==0)
        {
            two[i]++;
            x/=2;
        }
        x=tmp;
        while(x%5==0)
        {
            five[i]++;
            x/=5;
            tf++;
        }
    }
    int ans = 0;
    for(int i=1; i<=n; i++)
        for(int j = min(k, i); j >= 1; j--)
            for(int k = tf; k >= five[i]; k--)
                dp[j][k] = max(dp[j][k], dp[j-1][k-five[i]]+two[i]);
    for(int i = 1; i <= tf; i++)
        ans = max(ans, min(dp[k][i], i));
    cout << ans << endl;
}
int main()
{
    while(cin>>n>>k)
    {
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define N 205
int n, k, dp[N][12050];
int two[N], five[N];
void solve()
{
    memset(two, 0, sizeof(two));
    memset(five, 0, sizeof(five));
    memset(dp, 0, sizeof(dp));
    int tf=0;
    for(int i=1; i<=n; i++)
    {
        LL x, tmp;cin>>x;tmp=x;
        while(x%2==0)
        {
            two[i]++;
            x/=2;
        }
        x=tmp;
        while(x%5==0)
        {
            five[i]++;
            x/=5;
            tf++;
        }
    }
    int ans = 0;
    for(int i=1; i<=n; i++)
    {
        for(int j=tf; j>=five[i]; j--)
        {
            dp[i][j] = max(dp[i-1][j-five[i]]+two[i], dp[i][j]);
            ans = max(ans, min(j, dp[i][j]));
        }
    }
    cout << ans << endl;
}
int main()
{
    while(cin>>n>>k)
    {
        solve();
    }
    return 0;
}


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

const int N = 222;
int n,k,pw2[N],pw5[N];
ll a[N];
pair<int,int> get(ll val){
    int a=0,b=0;
    while(val % 2 == 0 && val > 0){
        a++; val /= 2;
    }
    while(val % 5 == 0 && val > 0){
        b++; val /= 5;
    }
    return make_pair(a,b);
}
int dp[2][N+10][6666];
int main(){
#ifdef home
    freopen("input.txt","r",stdin);
#endif // home
    cin >> n >> k;
    for(int i = 0;i < n; ++i) {
        cin >> a[i];
        auto x = get(a[i]);
        pw2[i] = x.first;
        pw5[i] = x.second;
    }
    memset(dp,0xff,sizeof dp);
    int cur = 0;
    dp[cur][0][0] = 0;
    for(int i=0;i<n;++i){
        cur ^= 1;
        for(int j=0;j<N;++j)for(int k=0;k<6666;++k) dp[cur][j][k]=-1;
        dp[cur][0][0] = 0;
        for(int j=1;j<=1+i;++j)for(int f=0;f<6666;++f){
            dp[cur][j][f] = max(dp[cur][j][f],dp[cur^1][j][f]);
            if(j-1>=0 && f-pw5[i]>=0 && dp[cur^1][j-1][f-pw5[i] ] >= 0) dp[cur][j][f] = max(dp[cur][j][f], dp[cur^1][j-1][f-pw5[i] ] + pw2[i]);
        }
    }
    int ans = 0;
    for(int f=0;f<6666;++f) ans = max(ans, min(f, dp[cur][k][f]));
    cout << ans << '\n';
}


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

const int N = 222;
int n,k;
ll a[N];
pair<int,int> get(ll val){
    int a=0,b=0;
    while(val % 2 == 0 && val > 0){
        a++; val /= 2;
    }
    while(val % 5 == 0 && val > 0){
        b++; val /= 5;
    }
    return make_pair(a,b);
}
int dp[2][N][4444];
int main(){
#ifdef home
    freopen("input.txt","r",stdin);
#endif // home
    cin >> n >> k;
    for(int i = 0;i < n; ++i) cin >> a[i];
//    can[cur][taken][2s][5s];
    int cur = 0;
    memset(dp,0xff,sizeof dp);
    dp[cur][0][0] = 0;
    for(int i=0;i<n;++i){
        cur ^= 1;
        for(int j=0;j<=i;++j)for(int f=0;f<=4000;++f)if(~dp[cur^1][j][f]){
            auto x = get(a[i]);
            dp[cur][j][f] = dp[cur^1][j][f];
            dp[cur][j + 1][f + x.second] = max(dp[cur][j+1][f + x.second], dp[cur^1][j][f] + x.first);
        }
    }
    int ans = 0;
    for(int f=0;f<4000;++f) ans = max(ans, min(f, dp[cur][k][f]));
    cout << ans << '\n';
}


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

const int N = 222;
int n,k;
ll a[N];
pair<int,int> get(ll val){
    int a=0,b=0;
    while(val % 2 == 0 && val > 0){
        a++; val /= 2;
    }
    while(val % 5 == 0 && val > 0){
        b++; val /= 5;
    }
    return make_pair(a,b);
}
bool can[2][202][65][65];
int main(){
#ifdef home
    freopen("input.txt","r",stdin);
#endif // home
    cin >> n >> k;
    for(int i = 0;i < n; ++i) cin >> a[i];
//    can[cur][taken][2s][5s];
    int cur = 0;
    can[0][0][0][0] = 1;
    for(int i=0;i<n;++i) {
        cur ^= 1;
        for(int j=0;j<=i;++j) for(int t = 0;t < 64;++t) for(int f = 0;f < 50;++f) if(can[cur^1][j][t][f]) {
            ll val = a[i];
            auto vv = get(a[i]);
            can[cur][j + 1][t + vv.first][f + vv.second] = 1;
            can[cur][j][t][f] = 1;
        }
    }
    int res = 0;
    for(int i=0;i<64;++i) for(int j=0;j<50;++j){
        if(can[cur][k][i][j]){
            res = max(res, min(i,j));
        }
    }
    cout << res << '\n';
}


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

const int N = 222;
int n,k,pw2[N],pw5[N];
ll a[N];
pair<int,int> get(ll val){
    int a=0,b=0;
    while(val % 2 == 0 && val > 0){
        a++; val /= 2;
    }
    while(val % 5 == 0 && val > 0){
        b++; val /= 5;
    }
    return make_pair(a,b);
}
int dp[2][N+10][4444];
int main(){
#ifdef home
    freopen("input.txt","r",stdin);
#endif // home
    cin >> n >> k;
    for(int i = 0;i < n; ++i) {
        cin >> a[i];
        auto x = get(a[i]);
        pw2[i] = x.first;
        pw5[i] = x.second;
    }
    memset(dp,0xff,sizeof dp);
    int cur = 0;
    dp[cur][0][0] = 0;
    for(int i=0;i<n;++i){
        cur ^= 1;
        for(int j=0;j<N;++j)for(int k=0;k<=4000;++k) dp[cur][j][k]=-1;
        dp[cur][0][0] = 0;
        for(int j=1;j<=1+i;++j)for(int f=0;f<=4000;++f){
            dp[cur][j][f] = max(dp[cur][j][f],dp[cur^1][j][f]);
            if(j-1>=0 && f-pw5[i]>=0 && dp[cur^1][j-1][f-pw5[i] ] >= 0) dp[cur][j][f] = max(dp[cur][j][f], dp[cur^1][j-1][f-pw5[i] ] + pw2[i]);
        }
    }
    int ans = 0;
    for(int f=0;f<4000;++f) ans = max(ans, min(f, dp[cur][k][f]));
    cout << ans << '\n';
}


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

const int N = 222;
int n,k;
ll a[N];
pair<int,int> get(ll val){
    int a=0,b=0;
    while(val % 2 == 0 && val > 0){
        a++; val /= 2;
    }
    while(val % 5 == 0 && val > 0){
        b++; val /= 5;
    }
    return make_pair(a,b);
}
int dp[2][202][4000];
int main(){
#ifdef home
    freopen("input.txt","r",stdin);
#endif // home
    cin >> n >> k;
    for(int i = 0;i < n; ++i) cin >> a[i];
//    can[cur][taken][2s][5s];
    int cur = 0;
    memset(dp,0xff,sizeof dp);
    dp[cur][0][0] = 0;
    for(int i=0;i<n;++i){
        cur ^= 1;
        for(int j=0;j<=i;++j)for(int f=0;f<=4000;++f)if(~dp[cur^1][j][f]){
            auto x = get(a[i]);
            dp[cur][j][f] = dp[cur^1][j][f];
            dp[cur][j + 1][f + x.second] = max(dp[cur][j+1][f + x.second], dp[cur^1][j][f] + x.first);
        }
    }
    int ans = 0;
    for(int f=0;f<4000;++f) ans = max(ans, min(f, dp[cur][k][f]));
    cout << ans << '\n';
}


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

const int N = 222;
int n,k,pw2[N],pw5[N];
ll a[N];
pair<int,int> get(ll val){
    int a=0,b=0;
    while(val % 2 == 0 && val > 0){
        a++; val /= 2;
    }
    while(val % 5 == 0 && val > 0){
        b++; val /= 5;
    }
    return make_pair(a,b);
}
int dp[2][N][4444];
int main(){
#ifdef home
    freopen("input.txt","r",stdin);
#endif // home
    cin >> n >> k;
    for(int i = 0;i < n; ++i) {
        cin >> a[i];
        auto x = get(a[i]);
        pw2[i] = x.first;
        pw5[i] = x.second;
    }
    memset(dp,0xff,sizeof dp);
    int cur = 0;
    dp[cur][0][0] = 0;
    for(int i=0;i<n;++i){
        cur ^= 1;
        for(int j=0;j<=i;++j)for(int f=0;f<=4000;++f)if(~dp[cur^1][j][f]){
            dp[cur][j][f] = dp[cur^1][j][f];
            dp[cur][j + 1][f + pw5[i] ] = max(dp[cur][j+1][f + pw5[i] ], dp[cur^1][j][f] + pw2[i]);
        }
        for(int i=0;i<N;++i) for(int j=0;j<=4000;++j) dp[cur^1][i][j] = -1;
    }
    int ans = 0;
    for(int f=0;f<4000;++f) ans = max(ans, min(f, dp[cur][k][f]));
    cout << ans << '\n';
}


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

const int N = 111;
int n,k;
ll a[N];
pair<int,int> get(ll val){
    int a=0,b=0;
    while(val % 2 == 0){
        a++; val /= 2;
    }
    while(val % 5 == 0){
        b++; val /= 5;
    }
    return make_pair(a,b);
}
bool can[2][202][65][65];
int main(){
#ifdef home
    freopen("input.txt","r",stdin);
#endif // home
    cin >> n >> k;
    for(int i = 0;i < n; ++i) cin >> a[i];
//    can[cur][taken][2s][5s];
    int cur = 0;
    can[0][0][0][0] = 1;
    for(int i=0;i<n;++i) {
        cur ^= 1;
        for(int j=0;j<=i;++j) for(int t = 0;t < 64;++t) for(int f = 0;f < 50;++f) if(can[cur^1][j][t][f]) {
            ll val = a[i];
            auto vv = get(a[i]);
            can[cur][j + 1][t + vv.first][f + vv.second] = 1;
            can[cur][j][t][f] = 1;
        }
    }
    int res = 0;
    for(int i=0;i<64;++i) for(int j=0;j<50;++j){
        if(can[cur][k][i][j]){
            res = max(res, min(i,j));
        }
    }
    cout << res << '\n';
}


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

const int N = 222;
int n,k,pw2[N],pw5[N];
ll a[N];
pair<int,int> get(ll val){
    int a=0,b=0;
    while(val % 2 == 0 && val > 0){
        a++; val /= 2;
    }
    while(val % 5 == 0 && val > 0){
        b++; val /= 5;
    }
    return make_pair(a,b);
}
int dp[2][N+10][4444];
int main(){
#ifdef home
    freopen("input.txt","r",stdin);
#endif // home
    cin >> n >> k;
    for(int i = 0;i < n; ++i) {
        cin >> a[i];
        auto x = get(a[i]);
        pw2[i] = x.first;
        pw5[i] = x.second;
    }
    memset(dp,0xff,sizeof dp);
    int cur = 0;
    dp[cur][0][0] = 0;
    for(int i=0;i<n;++i){
        cur ^= 1;
        for(int j=0;j<N;++j)for(int k=0;k<=4000;++k) dp[cur][j][k]=-1;
        dp[cur][0][0] = 0;
        for(int j=0;j<=i;++j)for(int f=0;f<=4000;++f)if(~dp[cur^1][j][f]){
            dp[cur][j][f] = dp[cur^1][j][f];
            dp[cur][j + 1][f + pw5[i] ] = max(dp[cur][j+1][f + pw5[i] ], dp[cur^1][j][f] + pw2[i]);
        }
    }
    int ans = 0;
    for(int f=0;f<4000;++f) ans = max(ans, min(f, dp[cur][k][f]));
    cout << ans << '\n';
}


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

const int N = 222;
int n,k,pw2[N],pw5[N];
ll a[N];
pair<int,int> get(ll val){
    int a=0,b=0;
    while(val % 2 == 0 && val > 0){
        a++; val /= 2;
    }
    while(val % 5 == 0 && val > 0){
        b++; val /= 5;
    }
    return make_pair(a,b);
}
int dp[2][N][4444];
int main(){
#ifdef home
    freopen("input.txt","r",stdin);
#endif // home
    cin >> n >> k;
    for(int i = 0;i < n; ++i) {
        cin >> a[i];
        auto x = get(a[i]);
        pw2[i] = x.first;
        pw5[i] = x.second;
    }
    memset(dp,0xff,sizeof dp);
    int cur = 0;
    dp[cur][0][0] = 0;
    for(int i=0;i<n;++i){
        cur ^= 1;
        for(int j=0;j<=i;++j)for(int f=0;f<=4000;++f)if(~dp[cur^1][j][f]){
            dp[cur][j][f] = dp[cur^1][j][f];
            dp[cur][j + 1][f + pw5[i] ] = max(dp[cur][j+1][f + pw5[i] ], dp[cur^1][j][f] + pw2[i]);
        }
    }
    int ans = 0;
    for(int f=0;f<4000;++f) ans = max(ans, min(f, dp[cur][k][f]));
    cout << ans << '\n';
}


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

const int N = 222;
int n,k,pw2[N],pw5[N];
ll a[N];
pair<int,int> get(ll val){
    int a=0,b=0;
    while(val % 2 == 0 && val > 0){
        a++; val /= 2;
    }
    while(val % 5 == 0 && val > 0){
        b++; val /= 5;
    }
    return make_pair(a,b);
}
int dp[2][N+10][4444];
int main(){
#ifdef home
    freopen("input.txt","r",stdin);
#endif // home
    cin >> n >> k;
    for(int i = 0;i < n; ++i) {
        cin >> a[i];
        auto x = get(a[i]);
        pw2[i] = x.first;
        pw5[i] = x.second;
    }
    memset(dp,0xff,sizeof dp);
    int cur = 0;
    dp[cur][0][0] = 0;
    for(int i=0;i<n;++i){
        cur ^= 1;
        for(int j=0;j<N;++j)for(int k=0;k<=4000;++k) dp[cur][j][k]=-1;
        dp[cur][0][0] = 0;
        for(int j=1;j<=1+i;++j)for(int f=0;f<=4000;++f){
            if(j-1>=0 && f-pw5[i]>=0 && dp[cur^1][j-1][f-pw5[i] ] >= 0) dp[cur][j][f] = max(dp[cur][j][f], dp[cur^1][j-1][f-pw5[i] ] + pw2[i]);
            dp[cur][j][f] = max(dp[cur][j][f],dp[cur^1][j][f]);
        }
    }
    int ans = 0;
    for(int f=0;f<4000;++f) ans = max(ans, min(f, dp[cur][k][f]));
    cout << ans << '\n';
}


#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e9 + 7;

int a[202], b[202], dp[2][202][6000];

int main()
{
	IO_OP;

	int n, k;
	cin >> n >> k;
	for(int i=0;i<n;i++) {
		ll t;
		cin >> t;
		while(t && t % 2 == 0) {
			a[i]++;
			t /= 2;
		}
		while(t && t % 5 == 0) {
			b[i]++;
			t /= 5;
		}
	}
	for(int i=0;i<202;i++)
		for(int j=0;j<6000;j++)
			dp[0][i][j] = dp[1][i][j] = -INF;
	dp[0][1][b[0]] = a[0];
	dp[0][1][0] = 0;
	for(int i=1;i<n;i++) {
		for(int j=1;j<=i+1;j++) {
			for(int l=0;l<6000;l++) {
				dp[i%2][j][l] = dp[(i-1)%2][j][l];
				if(l>=b[i]) dp[i%2][j][l] = max(dp[i%2][j][l], dp[(i-1)%2][j-1][l-b[i]]+a[i]);
			}
		}
	}
	int ans = 0;
	for(int i=0;i<6000;i++)
		ans = max(ans, min(i, dp[(n-1)%2][k][i]));
	cout << ans << endl;
}


#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e9 + 7;

int a[202], b[202], dp[202][202][30];

int main()
{
	IO_OP;

	int n, k;
	cin >> n >> k;
	for(int i=0;i<n;i++) {
		ll t;
		cin >> t;
		while(t && t % 2 == 0) {
			a[i]++;
			t /= 2;
		}
		while(t && t % 5 == 0) {
			b[i]++;
			t /= 5;
		}
	}
	for(int i=0;i<202;i++)
		for(int j=0;j<202;j++)
			for(int k=0;k<30;k++)
				dp[i][j][k] = -INF;
	dp[0][1][b[0]] = a[0];
	for(int i=1;i<n;i++) {
		for(int j=1;j<=i+1;j++) {
			for(int l=0;l<5;l++) {
				dp[i][j][l] = dp[i-1][j][l];
				if(l>=b[i]) dp[i][j][l] = max(dp[i][j][l], dp[i-1][j-1][l-b[i]]+a[i]);
			}
		}
	}
	int ans = 0;
	for(int i=0;i<30;i++)
		ans = max(ans, min(i, dp[n-1][k][i]));
	cout << ans << endl;
}


#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e9 + 7;

int a[202], b[202], dp[202][202][30];

int main()
{
	IO_OP;

	int n, k;
	cin >> n >> k;
	for(int i=0;i<n;i++) {
		int t;
		cin >> t;
		while(t && t % 2 == 0) {
			a[i]++;
			t /= 2;
		}
		while(t && t % 5 == 0) {
			b[i]++;
			t /= 5;
		}
	}
	for(int i=0;i<202;i++)
		for(int j=0;j<202;j++)
			for(int k=0;k<30;k++)
				dp[i][j][k] = -INF;
	dp[0][1][b[0]] = a[0];
	for(int i=1;i<n;i++) {
		for(int j=1;j<=i+1;j++) {
			for(int l=0;l<5;l++) {
				dp[i][j][l] = dp[i-1][j][l];
				if(l>=b[i]) dp[i][j][l] = max(dp[i][j][l], dp[i-1][j-1][l-b[i]]+a[i]);
			}
		}
	}
	int ans = 0;
	for(int i=0;i<30;i++)
		ans = max(ans, min(i, dp[n-1][k][i]));
	cout << ans << endl;
}


#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e9 + 7;

int a[202], b[202], dp[202][202][1000];

int main()
{
	IO_OP;

	int n, k;
	cin >> n >> k;
	for(int i=0;i<n;i++) {
		ll t;
		cin >> t;
		while(t && t % 2 == 0) {
			a[i]++;
			t /= 2;
		}
		while(t && t % 5 == 0) {
			b[i]++;
			t /= 5;
		}
	}
	for(int i=0;i<202;i++)
		for(int j=0;j<202;j++)
			for(int k=0;k<1000;k++)
				dp[i][j][k] = -INF;
	dp[0][1][b[0]] = a[0];
	for(int i=1;i<n;i++) {
		for(int j=1;j<=i+1;j++) {
			for(int l=0;l<1000;l++) {
				dp[i][j][l] = dp[i-1][j][l];
				if(l>=b[i]) dp[i][j][l] = max(dp[i][j][l], dp[i-1][j-1][l-b[i]]+a[i]);
			}
		}
	}
	int ans = 0;
	for(int i=0;i<1000;i++)
		ans = max(ans, min(i, dp[n-1][k][i]));
	cout << ans << endl;
}


#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e9 + 7;

int a[202], b[202], dp[202][202][6003];

int main()
{
	IO_OP;

	int n, k;
	cin >> n >> k;
	for(int i=0;i<n;i++) {
		ll t;
		cin >> t;
		while(t && t % 2 == 0) {
			a[i]++;
			t /= 2;
		}
		while(t && t % 5 == 0) {
			b[i]++;
			t /= 5;
		}
	}
	for(int i=0;i<202;i++)
		for(int j=0;j<202;j++)
			for(int k=0;k<30;k++)
				dp[i][j][k] = -INF;
	dp[0][1][b[0]] = a[0];
	for(int i=1;i<n;i++) {
		for(int j=1;j<=i+1;j++) {
			for(int l=0;l<6003;l++) {
				dp[i][j][l] = dp[i-1][j][l];
				if(l>=b[i]) dp[i][j][l] = max(dp[i][j][l], dp[i-1][j-1][l-b[i]]+a[i]);
			}
		}
	}
	int ans = 0;
	for(int i=0;i<6003;i++)
		ans = max(ans, min(i, dp[n-1][k][i]));
	cout << ans << endl;
}


#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e9 + 7;

int a[202], b[202], dp[2][202][6000];

int main()
{
	IO_OP;

	int n, k;
	cin >> n >> k;
	for(int i=0;i<n;i++) {
		ll t;
		cin >> t;
		while(t && t % 2 == 0) {
			a[i]++;
			t /= 2;
		}
		while(t && t % 5 == 0) {
			b[i]++;
			t /= 5;
		}
	}
	for(int i=0;i<202;i++)
		for(int j=0;j<6000;j++)
			dp[0][i][j] = dp[1][i][j] = -INF;
	dp[0][1][b[0]] = a[0];
	for(int i=1;i<n;i++) {
		for(int j=1;j<=i+1&&j<=k;j++) {
			for(int l=0;l<6000;l++) {
				dp[i%2][j][l] = dp[(i-1)%2][j][l];
				if(l>=b[i]) dp[i%2][j][l] = max(dp[i%2][j][l], dp[(i-1)%2][j-1][l-b[i]]+a[i]);
			}
		}
	}
	int ans = 0;
	for(int i=0;i<6000;i++)
		ans = max(ans, min(i, dp[(n-1)%2][k][i]));
	cout << ans << endl;
}


#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e9 + 7;

int a[202], b[202], dp[202][202][1000];

int main()
{
	IO_OP;

	int n, k;
	cin >> n >> k;
	for(int i=0;i<n;i++) {
		ll t;
		cin >> t;
		while(t && t % 2 == 0) {
			a[i]++;
			t /= 2;
		}
		while(t && t % 5 == 0) {
			b[i]++;
			t /= 5;
		}
	}
	for(int i=0;i<202;i++)
		for(int j=0;j<202;j++)
			for(int k=0;k<30;k++)
				dp[i][j][k] = -INF;
	dp[0][1][b[0]] = a[0];
	for(int i=1;i<n;i++) {
		for(int j=1;j<=i+1;j++) {
			for(int l=0;l<1000;l++) {
				dp[i][j][l] = dp[i-1][j][l];
				if(l>=b[i]) dp[i][j][l] = max(dp[i][j][l], dp[i-1][j-1][l-b[i]]+a[i]);
			}
		}
	}
	int ans = 0;
	for(int i=0;i<1000;i++)
		ans = max(ans, min(i, dp[n-1][k][i]));
	cout << ans << endl;
}


#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e9 + 7;

int a[202], b[202], dp[2][202][6000];

int main()
{
	IO_OP;

	int n, k;
	cin >> n >> k;
	for(int i=0;i<n;i++) {
		ll t;
		cin >> t;
		while(t && t % 2 == 0) {
			a[i]++;
			t /= 2;
		}
		while(t && t % 5 == 0) {
			b[i]++;
			t /= 5;
		}
	}
	for(int i=0;i<202;i++)
		for(int j=0;j<6000;j++)
			dp[0][i][j] = dp[1][i][j] = -INF;
	dp[0][0][0] = 0;
	dp[0][1][b[0]] = a[0];
	for(int i=1;i<n;i++) {
		for(int j=1;j<=i+1;j++) {
			for(int l=0;l<6000;l++) {
				dp[i%2][j][l] = dp[(i-1)%2][j][l];
				if(l>=b[i]) dp[i%2][j][l] = max(dp[i%2][j][l], dp[(i-1)%2][j-1][l-b[i]]+a[i]);
			}
		}
	}
	int ans = 0;
	for(int i=0;i<6000;i++)
		ans = max(ans, min(i, dp[(n-1)%2][k][i]));
	cout << ans << endl;
}


#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e9 + 7;

int a[202], b[202], dp[202][202][1000];

int main()
{
	IO_OP;

	int n, k;
	cin >> n >> k;
	for(int i=0;i<n;i++) {
		ll t;
		cin >> t;
		while(t && t % 2 == 0) {
			a[i]++;
			t /= 2;
		}
		while(t && t % 5 == 0) {
			b[i]++;
			t /= 5;
		}
	}
	for(int i=0;i<202;i++)
		for(int j=0;j<202;j++)
			for(int k=0;k<1000;k++)
				dp[i][j][k] = -INF;
	dp[0][1][b[0]] = a[0];
	for(int i=1;i<n;i++) {
		for(int j=1;j<=i+1&&j<=k;j++) {
			for(int l=0;l<1000;l++) {
				dp[i][j][l] = dp[i-1][j][l];
				if(l>=b[i]) dp[i][j][l] = max(dp[i][j][l], dp[i-1][j-1][l-b[i]]+a[i]);
			}
		}
	}
	int ans = 0;
	for(int i=0;i<1000;i++)
		ans = max(ans, min(i, dp[n-1][k][i]));
	cout << ans << endl;
}


#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e9 + 7;

int a[202], b[202], dp[2][202][6000];

int main()
{
	IO_OP;

	int n, k;
	cin >> n >> k;
	for(int i=0;i<n;i++) {
		ll t;
		cin >> t;
		while(t && t % 2 == 0) {
			a[i]++;
			t /= 2;
		}
		while(t && t % 5 == 0) {
			b[i]++;
			t /= 5;
		}
	}
	for(int i=0;i<202;i++)
		for(int j=0;j<6000;j++)
			dp[0][i][j] = dp[1][i][j] = -INF;
	dp[0][0][0] = 0;
	dp[0][1][b[0]] = a[0];
	for(int i=1;i<n;i++) {
		dp[i%2][0][0] = 0;
		for(int j=1;j<=i+1;j++) {
			for(int l=0;l<6000;l++) {
				dp[i%2][j][l] = dp[(i-1)%2][j][l];
				if(l>=b[i]) dp[i%2][j][l] = max(dp[i%2][j][l], dp[(i-1)%2][j-1][l-b[i]]+a[i]);
			}
		}
	}
	int ans = 0;
	for(int i=0;i<6000;i++)
		ans = max(ans, min(i, dp[(n-1)%2][k][i]));
	cout << ans << endl;
}


#include<bits/stdc++.h>

#define x first
#define y second
#define y0 hi1
#define y1 hi2
#define ll long long
#define mp make_pair
#define pb push_back
#define sqr(a) (a)*(a)
#define ld long double
#define all(a) (a).begin(), (a).end()

using namespace std;

const int inf = 2000000000;
const int N = 200 * 64 + 1;
const int M = 200 * 18 + 1;

int dp[2][N][M];

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    vector<pair<int, int>> a;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;

        pair<int, int> val;
        while(x % 2 == 0){
            x /= 2;
            val.x++;
        }
        while(x % 5 == 0){
            x /= 5;
            val.y++;
        }

        a.pb(val);
    }

    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            for(int k = 0; k < 2; k++){
                dp[k][i][j] = inf;
            }
        }
    }
    dp[0][0][0] = 0;
    dp[1][0][0] = 0;

    for(int i = 0; i < n; i++){
        for(int x = 0; x < N; x++){
            for(int y = 0; y < M; y++){
                if(dp[0][x][y] != inf){
                    dp[1][x + a[i].x][y + a[i].y] = min(dp[1][x + a[i].x][y + a[i].y], dp[0][x][y] + 1);
                }
            }
        }

        for(int x = 0; x < N; x++){
            for(int y = 0; y < M; y++){
                dp[0][x][y] = dp[1][x][y];
            }
        }
    }

    int ans = 0;
    for(int x = N - 1; x >= ans; x--){
        for(int y = N - 1; y >= x; y--){
            if(dp[0][x][y] <= k){
                ans = x;
            }
        }
    }
    cout << ans;
}


#include<bits/stdc++.h>

#define x first
#define y second
#define y0 hi1
#define y1 hi2
#define ll long long
#define mp make_pair
#define pb push_back
#define sqr(a) (a)*(a)
#define ld long double
#define all(a) (a).begin(), (a).end()

using namespace std;

const unsigned char inf = 255;
const int N = 200 * 64 + 1;
const int M = 200 * 18 + 1;

unsigned char dp[2][N][M];

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    vector<pair<int, int>> a;
    for(int i = 0; i < n; i++){
        ll x;
        cin >> x;

        pair<int, int> val;
        while(x % 2 == 0){
            x /= 2;
            val.x++;
        }
        while(x % 5 == 0){
            x /= 5;
            val.y++;
        }

        a.pb(val);
    }

    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            for(int k = 0; k < 2; k++){
                dp[k][i][j] = inf;
            }
        }
    }
    dp[0][0][0] = 0;
    dp[1][0][0] = 0;

    for(int i = 0; i < n; i++){
        for(int x = 0; x < N; x++){
            for(int y = 0; y < M; y++){
                if(dp[0][x][y] != inf){
                    unsigned char f = dp[0][x][y] + 1;
                    dp[1][x + a[i].x][y + a[i].y] = min(dp[1][x + a[i].x][y + a[i].y], f);
                }
            }
        }

        for(int x = 0; x < N; x++){
            for(int y = 0; y < M; y++){
                dp[0][x][y] = dp[1][x][y];
            }
        }
    }

    int ans = 0;
    for(int x = N - 1; x >= ans; x--){
        for(int y = N - 1; y >= x; y--){
            if(dp[0][x][y] <= k){
                ans = x;
            }
        }
    }
    cout << ans;
}


#include<bits/stdc++.h>

#define x first
#define y second
#define y0 hi1
#define y1 hi2
#define ll long long
#define mp make_pair
#define pb push_back
#define sqr(a) (a)*(a)
#define ld long double
#define all(a) (a).begin(), (a).end()

using namespace std;

const int inf = 2e9;
const int N = 200 * 64 + 1;
const int M = 200 * 18 + 1;
const int K = 201;

int dp[2][K][M];

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

    pair<int, int> a[n];
    for(int i = 0; i < n; i++){
        ll x;
        cin >> x;

        pair<int, int> val;
        while(x % 2 == 0){
            x /= 2;
            val.x++;
        }
        while(x % 5 == 0){
            x /= 5;
            val.y++;
        }

        a[i] = val;
    }

    for(int k = 0; k <= kk; k++){
        for(int j = 0; j < M; j++){
            for(int p = 0; p < 2; p++){
                dp[p][k][j] = -1;
            }
        }
    }
    dp[0][0][0] = dp[1][0][0] = 0;

    for(int i = 0; i < n; i++){
        for(int k = 1; k <= min(kk, i + 1); k++){
            for(int y = M - 1; y >= 0; y--){
                if(dp[0][k - 1][y] != -1){
                    dp[1][k][y + a[i].y] = max(dp[1][k][y + a[i].y], dp[0][k - 1][y] + a[i].x);
                }
            }
        }

        for(int k = 1; k <= min(kk, i + 1); k++){
            for(int y = M - 1; y >= 0; y--){
                dp[0][k][y] = dp[1][k][y];
            }
        }
    }

    int ans = 0;
    for(int y = M - 1; y > ans; y--){
        ans = max(ans, min(y, dp[kk][y]));
    }
    cout << ans;
}

/*
2 2
20 50
*/


#include<bits/stdc++.h>

#define x first
#define y second
#define y0 hi1
#define y1 hi2
#define ll long long
#define mp make_pair
#define pb push_back
#define sqr(a) (a)*(a)
#define ld long double
#define all(a) (a).begin(), (a).end()

using namespace std;

const int inf = 2e9;
const int N = 200 * 64 + 1;
const int M = 200 * 18 + 1;
const int K = 201;

int dp[2][K][M];

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

    pair<int, int> a[n];
    for(int i = 0; i < n; i++){
        ll x;
        cin >> x;

        pair<int, int> val;
        while(x % 2 == 0){
            x /= 2;
            val.x++;
        }
        while(x % 5 == 0){
            x /= 5;
            val.y++;
        }

        a[i] = val;
    }

    for(int k = 0; k <= kk; k++){
        for(int j = 0; j < M; j++){
            for(int p = 0; p < 2; p++){
                dp[p][k][j] = -1;
            }
        }
    }
    dp[0][0][0] = dp[1][0][0] = 0;

    for(int i = 0; i < n; i++){
        for(int k = 1; k <= min(kk, i + 1); k++){
            for(int y = M - 1; y >= 0; y--){
                if(dp[0][k - 1][y] != -1){
                    dp[1][k][y + a[i].y] = max(dp[1][k][y + a[i].y], dp[0][k - 1][y] + a[i].x);
                }
            }
        }

        for(int k = 1; k <= min(kk, i + 1); k++){
            for(int y = M - 1; y >= 0; y--){
                dp[0][k][y] = dp[1][k][y];
            }
        }
    }

    for(int y = M - 1; y > 0; y--){
        if(dp[0][kk][y] >= y){
            cout << y;
            return 0;
        }
    }
    cout << 0;
}

/*
2 2
20 50
*/


#include<bits/stdc++.h>

#define x first
#define y second
#define y0 hi1
#define y1 hi2
#define ll long long
#define mp make_pair
#define pb push_back
#define sqr(a) (a)*(a)
#define ld long double
#define all(a) (a).begin(), (a).end()

using namespace std;

const int inf = 2e9;
const int N = 200 * 65 + 1;
const int M = 200 * 19 + 1;
const int K = 205;

int dp[2][K][M];

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

    pair<int, int> a[n];
    for(int i = 0; i < n; i++){
        ll x;
        cin >> x;

        pair<int, int> val;
        while(x % 2 == 0){
            x /= 2;
            val.x++;
        }
        while(x % 5 == 0){
            x /= 5;
            val.y++;
        }

        a[i] = val;
    }

    for(int k = 0; k <= kk; k++){
        for(int j = 0; j < M; j++){
            for(int p = 0; p < 2; p++){
                dp[p][k][j] = -1;
            }
        }
    }
    dp[0][0][0] = dp[1][0][0] = 0;

    for(int i = 0; i < n; i++){
        for(int k = 1; k <= min(kk, i + 1); k++){
            for(int y = M - 1; y >= 0; y--){
                if(dp[0][k - 1][y] != -1){
                    dp[1][k][y + a[i].y] = max(dp[1][k][y + a[i].y], dp[0][k - 1][y] + a[i].x);
                }
            }
        }

        for(int k = 1; k <= min(kk, i + 1); k++){
            for(int y = M - 1; y >= 0; y--){
                dp[0][k][y] = dp[1][k][y];
            }
        }
    }

    int ans = 0;
    for(int y = M - 1; y > ans; y--){
        ans = max(ans, min(y, dp[0][kk][y]));
    }
    cout << ans;
}

/*
2 2
20 50
*/


#include<bits/stdc++.h>

#define x first
#define y second
#define y0 hi1
#define y1 hi2
#define ll long long
#define mp make_pair
#define pb push_back
#define sqr(a) (a)*(a)
#define ld long double
#define all(a) (a).begin(), (a).end()

using namespace std;

const int inf = 2e9;
const int N = 200 * 64 + 1;
const int M = 200 * 18 + 1;
const int K = 201;

int dp[2][K][M];

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

    pair<int, int> a[n];
    for(int i = 0; i < n; i++){
        ll x;
        cin >> x;

        pair<int, int> val;
        while(x % 2 == 0){
            x /= 2;
            val.x++;
        }
        while(x % 5 == 0){
            x /= 5;
            val.y++;
        }

        a[i] = val;
    }

    for(int k = 0; k <= kk; k++){
        for(int j = 0; j < M; j++){
            for(int p = 0; p < 2; p++){
                dp[p][k][j] = -1;
            }
        }
    }
    dp[0][0][0] = dp[1][0][0] = 0;

    for(int i = 0; i < n; i++){
        for(int k = 1; k <= min(kk, i + 1); k++){
            for(int y = M - 1 - a[i].y; y >= 0; y--){
                if(dp[0][k - 1][y] != -1){
                    dp[1][k][y + a[i].y] = max(dp[1][k][y + a[i].y], dp[0][k - 1][y] + a[i].x);
                }
            }
        }

        for(int k = 1; k <= min(kk, i + 1); k++){
            for(int y = M - 1; y >= 0; y--){
                dp[0][k][y] = dp[1][k][y];
            }
        }
    }

    int ans = 0;
    for(int y = M - 1; y > ans; y--){
        ans = max(ans, min(y, dp[0][kk][y]));
    }
    cout << ans;
}

/*
2 2
20 50
*/


#include<bits/stdc++.h>

#define x first
#define y second
#define y0 hi1
#define y1 hi2
#define ll long long
#define mp make_pair
#define pb push_back
#define sqr(a) (a)*(a)
#define ld long double
#define all(a) (a).begin(), (a).end()

using namespace std;

const int inf = 2e9;
const int N = 200 * 64 + 1;
const int M = 200 * 26 + 1;
const int K = 205;

int dp[2][K][M];

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

    pair<int, int> a[n];
    for(int i = 0; i < n; i++){
        ll x;
        cin >> x;

        pair<int, int> val;
        while(x % 2 == 0){
            x /= 2;
            val.x++;
        }
        while(x % 5 == 0){
            x /= 5;
            val.y++;
        }

        a[i] = val;
    }

    for(int k = 0; k <= kk; k++){
        for(int j = 0; j < M; j++){
            for(int p = 0; p < 2; p++){
                dp[p][k][j] = -1;
            }
        }
    }
    dp[0][0][0] = dp[1][0][0] = 0;

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

        for(int k = 1; k <= min(kk, i + 1); k++){
            for(int y = 0; y < M - a[i].y; y++){
                if(dp[0][k - 1][y] != -1){
                    dp[1][k][y + a[i].y] = max(dp[1][k][y + a[i].y], dp[0][k - 1][y] + a[i].x);
                }
            }
        }

        for(int k = 1; k <= min(kk, i + 1); k++){
            for(int y = M - 1; y >= 0; y--){
                dp[0][k][y] = max(dp[0][k][y], dp[1][k][y]);
            }
        }
    }

    int ans = 0;
    for(int y = M - 1; y > ans; y--){
        ans = max(ans, min(y, dp[0][kk][y]));
    }
    cout << ans;
}

/*
2 2
20 50
*/


#include<bits/stdc++.h>

#define x first
#define y second
#define y0 hi1
#define y1 hi2
#define ll long long
#define mp make_pair
#define pb push_back
#define sqr(a) (a)*(a)
#define ld long double
#define all(a) (a).begin(), (a).end()

using namespace std;

const unsigned char inf = 255;
const int N = 200 * 64 + 1;
const int M = 200 * 18 + 1;

unsigned char dp[2][N][M];

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    vector<pair<int, int>> a;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;

        pair<int, int> val;
        while(x % 2 == 0){
            x /= 2;
            val.x++;
        }
        while(x % 5 == 0){
            x /= 5;
            val.y++;
        }

        a.pb(val);
    }

    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            for(int k = 0; k < 2; k++){
                dp[k][i][j] = inf;
            }
        }
    }
    dp[0][0][0] = 0;
    dp[1][0][0] = 0;

    for(int i = 0; i < n; i++){
        for(int x = 0; x < N; x++){
            for(int y = 0; y < M; y++){
                if(dp[0][x][y] != inf){
                    unsigned char f = dp[0][x][y] + 1;
                    dp[1][x + a[i].x][y + a[i].y] = min(dp[1][x + a[i].x][y + a[i].y], f);
                }
            }
        }

        for(int x = 0; x < N; x++){
            for(int y = 0; y < M; y++){
                dp[0][x][y] = dp[1][x][y];
            }
        }
    }

    int ans = 0;
    for(int x = N - 1; x >= ans; x--){
        for(int y = N - 1; y >= x; y--){
            if(dp[0][x][y] <= k){
                ans = x;
            }
        }
    }
    cout << ans;
}