#include <bits/stdc++.h>
using namespace std;
map<int, int> pre;
map<int, bool> vis;
const int MAXN = 1e5 + 5;
int N, sum[2], ans = 0;
char s[MAXN];
int main() {
  scanf("%d%s", &N, s + 1);
  pre[0] = 0;
  vis[0] = 1;
  for (int i = 1; i <= N; i++) {
    sum[s[i] - '0']++;
    if (vis[sum[0] - sum[1]])
      ans = max(ans, i - pre[sum[0] - sum[1]]);
    else {
      vis[sum[0] - sum[1]] = 1;
      pre[sum[0] - sum[1]] = i;
    }
  }
  cout << ans << endl;
  return 0;
}
