#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define BE(x) x.begin(), x.end()

int main() {
    ll n;
    string t;
    cin >> n >> t;

    ll m = 10000000000;
    if (t == "1") {
        cout << m * 2LL << endl;
        return 0;
    }

    if (t[0] == '0') t = "11" + t, n += 2;
    else if (t.substr(0, 2) == "10") t = "1" + t, n++;

    string s = "";
    while (s.size() < t.size()) s += "110";

    if (s.substr(0, n) == t) cout << m - (n+2)/3 + 1 << endl;
    else cout << 0 << endl;
}
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAX_N = 1e9 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> par;
typedef vector<par> parv;
typedef vector<vi> vvi;
// Author : Koushal Bhat
#define forr(i,p,n) for( ll i=p; i<n; i++)
#define forn(i,p,n) for(ll i=p; i<=n; i++)
#define rev(i,n,p) for(ll i=n; i>=p; i--)
#define PI 3.14159265358979323846
#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)



void solve() {
    ll n=0;
    cin>>n;
    forr(i,1,MAX_N)
    {
        ll op=(i*(i+1))/2;
        if(op>=n)
        {
            cout<<i<<"\n";
            return;
        }

    }

}

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