#include<bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;

#pragma GCC optimize("O3")
#ifdef LOCAL
#include "/Users/lbjlc/Desktop/coding/debug_utils.h"
#else
#define print(...) ;
#define printn(...) ;
#define printg(...) ;
#define fprint(...) ;
#define fprintn(...) ;
#endif

#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define pb push_back
// #define mp make_pair
#define fi first
#define se second
#define maxi(x, y) x = max(x, y)
#define mini(x, y) x = min(x, y)
// long long fact(long long n) { if(!n) return 1; return n*fact(n-1); }
// #define endl '\n'
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int get_random() {
    static uniform_int_distribution<int> dist(0, 1e9 + 6);
    return dist(rng);
}
#define solve_testcase int T;cin>>T;for(int t=1;t<=T;t++){solve(t);}


typedef unsigned long long ull;
typedef long long ll;
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;
typedef vector<long long> vll;
#define bd(type,op,val) bind(op<type>(), std::placeholders::_1, val)

template<class T>
void make_unique(T & v) {
    sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());
}
int geti() { int x; cin >> x; return x; }
long long getll() { long long x; cin >> x; return x; }
double getd() { double x; cin >> x; return x; }
// pair<int, int> a(geti(), geti()) does not work
// pair<int, int> a({geti(), geti()}) works, since it uses initializer.

const int MAXN = 3e5 + 100;

void solve(int tt) {
    // cout<<"Case #"<<tt<<": ";
}

int main(int argc, char * argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // solve_testcase;

    int n;
    cin>>n;

    string s;
    cin>>s;
    const string s110="110";

    ll tot=1e10;
    if(n==1) {
    	if(s[0]=='0') cout<<tot<<endl;
    	else cout<<2*tot<<endl;
    	return 0;
    }

    if(s[0]=='0') s = "11"+s;
    else if(s[1]=='0') s = "1"+s;

    n=s.size();
    if(s[n-1]=='1') {
    	if(s[n-2]=='1') s+='0';
    	else s += "10";
    }

    print(s);

    if(s.size()%3) {
    	cout<<0<<endl;
    	return 0;
    }

    int ok=1;
    rep(i,0,n) {
    	if(s[i]!=(i%3==2?'0':'1'))
    		ok=0;
    }
    if(!ok) {
    	cout<<0<<endl;
    	return 0;
    }

    cout<<tot-ll(s.size())/3+1<<endl;




    return 0;
}












#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> II;
typedef pair<LL, II> III;
typedef priority_queue<III, vector<III>, greater<>> Queue;
static const LL INF = 1LL << 60;

LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; }
LL lcm(LL a, LL b) { return (a / gcd(a, b)) * b; }

void solve(long long N, long long M, long long K, std::vector<long long> &A) {
	vector<LD> e(N + M + 2);
	vector<LD> pz(N + M + 2);
	vector<LL> z(N + 2);
	LD esum = 0;
	LD zsum = 0;
	for (int i = 0; i < K; i++) {
		z[A[i]] = 1;
	}
	for (LL i = N - 1; i >= 0; --i) {
		e[i] = 1.0 + esum / M;
		if (z[i]) {
			e[i] = 0;
			pz[i] = 1.0;
		} else {
			pz[i] = zsum / M;
		}
		esum -= e[i + M];
		esum += e[i];
		zsum -= pz[i + M];
		zsum += pz[i];
	}
	LD ans = e[0];
	if (pz[0] > 0) {
		if (pz[0] >= (1.0 - 1e-10)) {
			cout << -1 << endl;
			return;
		}
		LD a = 1.0 - pz[0];
		ans /= a;
	}
	cout << ans << endl;
}

int main() {
	cout.precision(10);
    long long N;
	std::cin >> N;
	long long M;
	std::cin >> M;
	long long K;
	std::cin >> K;
	std::vector<long long> A(K);
	for (int i = 0; i < K; i++) {
		std::cin >> A[i]; // A[i]--;
	}
	solve(N, M, K, A);
	return 0;
}
