#include <bits/stdc++.h>
using namespace std;
int main(){
  cout << fixed << setprecision(20);
  int K;
  cin >> K;
  string S;
  cin >> S;
  string T;
  cin >> T;
  vector<int> cnt(10, K);
  for (int i = 0; i < 4; i++){
    cnt[S[i] - '0']--;
    cnt[T[i] - '0']--;
  }
  long long ans1 = 0, ans2 = 0;
  for (int i = 1; i < 10; i++){
    for (int j = 1; j < 10; j++){
      vector<int> cnt1(10, 0);
      for (int k = 0; k < 4; k++){
        cnt1[S[k] - '0']++;
      }
      cnt1[i]++;
      int s1 = 0;
      for (int k = 1; k <= 9; k++){
        int add = k;
        for (int l = 0; l < cnt1[k]; l++){
          add *= 10;
        }
        s1 += add;
      }
      vector<int> cnt2(10, 0);
      for (int k = 0; k < 4; k++){
        cnt2[T[k] - '0']++;
      }
      cnt2[j]++;
      int s2 = 0;
      for (int k = 1; k <= 9; k++){
        int add = k;
        for (int l = 0; l < cnt2[k]; l++){
          add *= 10;
        }
        s2 += add;
      }
      long long a;
      if (i == j){
        a = (long long) cnt[i] * (cnt[i] - 1);
      } else {
        a = (long long) cnt[i] * cnt[j];
      }
      if (s1 > s2){
        ans1 += a;
      }
      ans2 += a;
    }
  }
  cout << (double) ans1 / ans2 << endl;
}
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#define ll long long int
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define PI 3.141592653589793
using namespace std;

int main() {
    int N,K,M,sum=0;

    cin >> N >> K >> M;
    int A;
    REP(i,N-1) {
        cin >> A;
        sum += A;
    }
    int ans = N * M - sum;
    if(ans > K) ans = -1;
    else if(ans < 0) ans = 0;

    cout << ans << endl;

    return 0;
}