#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll K;
    cin >> K;
    string S,T;
    cin >> S >> T;
    long double ans=0;
    vector <ll> pow10 = {1,10,100,1000, 10000, 100000};
    for (int i=1; i<=9; ++i)
    {
        for (int j=1; j<=9; ++j)
        {
            vector <int> freqS(10, 0), freqT(10, 0), freqcombine(10, 0);
            for (int k=0; k<4; ++k)
            {
                freqS[(S[k]-'0')]++;
                freqT[(T[k]-'0')]++;
                freqcombine[(S[k]-'0')]++;
                freqcombine[(T[k]-'0')]++;
            }
            bool possible=true;
            for (int k=1; k<=9; ++k)
            {
                if (freqcombine[k]>K) {
                    possible=false;
                }
            }
            if (!possible) continue;
            freqS[i]++;
            freqT[j]++;
            ll scoreA =0, scoreB=0;
            for (int k=1; k<=9; ++k)
            {
                scoreA += k*pow10[freqS[k]];
                scoreB += k*pow10[freqT[k]];
            }
            long double prob = ((long double)(K-freqcombine[i]))/(9*K-8);
            freqcombine[i]++;
            prob *= ((long double)(K-freqcombine[j]))/(9*K-9);
            if (scoreA>scoreB) ans += prob;
        }
    }
    cout << fixed << setprecision(20) << ans << "\n";
    return 0;
}
#include <iostream>
using namespace std;
using ll= long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define ALL(x) x.begin(),x.end()
#define MOD (int)1e9+7

signed main() {
  ll n, k;
  ll ans=0;
  cin>>n>>k;
  ll a[n];
  ll numc[n];
  REP(i,n) cin>>a[i];
  REP(i,n) numc[i]=0;
  REP(i,n) {
    numc[a[i]]++;
  }
  if(numc[0]>k) numc[0]=k;
  REP(i,n) {
    if(i==0){
      ans+=numc[i];
    }else if(numc[i-1]>numc[i]){
      ans+=numc[i];
    }else{
      numc[i]=numc[i-1];
      ans+=numc[i];
    }

  }
  
  cout<<ans<<endl;
  return 0;
}
