#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
const int N = 100050;
char s[N];
map<int, int> M;
int main()
{
    int n;
    scanf("%d%s", &n, s);
    int ans1 = 0, ans2 = 0;
    M[0] = -1;
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == '1')
            cnt++;
        else
            cnt--;
        auto ite = M.find(cnt);
        if (ite != M.end())
            ans1 = max(ans1, i - ite->second);
        if (!M.count(cnt)) M[cnt] = i;
    }
    ans2 = min(count(s, s + n, '0'), count(s, s + n, '1')) << 1;
    printf("%d %d", ans1, (ans2 | 1) - 1);
    return 0;
}