#include <bits/stdc++.h>
using namespace std;
const int M = 1e5 + 10;
int n, cnt, ans;
bool a[M], st[M];
int main() {
  string s;
  cin >> n >> s;
  for (int i = 0; i < n; i++) a[i] = s[i] - '0';
  for (int i = 0; i < n; i++) {
    if (cnt && (st[cnt - 1] ^ a[i]) == 1)
      cnt--, ans += 2;
    else
      st[cnt++] = a[i];
  }
  printf("%d\n", ans);
  return 0;
}
