#include <bits/stdc++.h>
#pragma GCC optimize(3)
#define int long long
#define ri register
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define is insert
#define es erase
using namespace std;
inline int read()
{
    int s = 0, w = 1;
    ri char ch = getchar();
    while (ch < '0' || ch > '9')
    {
        if (ch == '-')
            w = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
        s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar();
    return s * w;
}
int n;
string t;
int INF = 1e10;
signed main()
{
    n = read();
    cin >> t;
    if (t == "1")
    {
        printf("%lld\n", INF * 2);
        return 0;
    }
    int flg = 0;
    int be = 0;
    if (t[0] == '0')
        be = 1, flg++;
    else if (t.substr(0, 2) == "10")
        be = 2, flg++;
    int res = 0;
    for (; be + 2 < n; be += 3)
    {
        if (t.substr(be, 3) == "110")
            res++;
        else
            return puts("0") & 0;
    }
    if (be != n)
    {
        if (t.substr(be) == "1" || t.substr(be) == "11")
            flg++;
        else
            return puts("0") & 0;
    }
    printf("%lld\n", INF - (res + flg) + 1);
    return 0;
}
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <vector>
#include <numeric>
#include <string>

int main() {
	int k;
	std::cin >> k;
	std::vector<int> v(10, k);
	std::vector<double> tv(10, 0);
	std::vector<double> av(10, 0);
	int ta = 0; 
	int ao = 0;
	std::string s;

	std::cin >> s;

	for (int c = 0; c < 4; c++) {
		int f;
		f = std::stoi(s.substr(c, 1));
		tv[f] += 1;
		v[f] -= 1;
	}

	
	for (int c = 1; c < 10; c++) {
		ta += c*pow(10, tv[c]);
	}

	std::cin >> s;

	for (int c = 0; c < 4; c++) {
		int f;
		f = std::stoi(s.substr(c, 1));
		av[f] += 1;
		v[f] -= 1;
	}

	for (int c = 1; c < 10; c++) {
		ao += c*pow(10, av[c]);
	}


	double ans = 0.;

	for (int c = 1; c < 10; c++) {
		for (int b = 1; b < 10; b++) {
			if (c == b) {
				if (v[c] > 1) {
					if (ao + b * pow(10, av[b] + 1) - b * pow(10, av[b]) < ta + c * pow(10, tv[c] + 1) - c * pow(10, tv[c])) {
						ans += static_cast<double>(v[c]) / static_cast<double>(std::accumulate(v.begin() + 1, v.end(), 0)) * static_cast<double>(v[c] - 1) / static_cast<double>(std::accumulate(v.begin() + 1, v.end(), 0) - 1);
					}
				}
			}
			else {
				if (v[c] > 0 && v[b] > 0) {
					if (ao + b * pow(10, av[b] + 1) - b * pow(10, av[b]) < ta + c * pow(10, tv[c] + 1) - c * pow(10, tv[c])) {
						ans += static_cast<double>(v[c]) / static_cast<double>(std::accumulate(v.begin() + 1, v.end(), 0)) * static_cast<double>(v[b]) / static_cast<double>(std::accumulate(v.begin() + 1, v.end(), 0) - 1);
					}
				}
			}
		}
	}

	std::cout << ans << std::endl;

}