#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long inf = 1e18;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  string a;
  cin >> a;
  int z = 0, o = 0;
  int ans = 0;
  map<int, int> mp;
  for (int i = 0; i < n; ++i) {
    a[i] == '0' ? z++ : o++;
    int balance = o - z;
    if (balance == 0) {
      ans = max(ans, i + 1);
    } else if (mp.count(balance)) {
      ans = max(ans, i - mp[balance]);
    } else
      mp[balance] = i;
  }
  cout << ans << endl;
  return 0;
}
