#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e6 + 10;
char a[MAX_N];
const int BUFSIZE = 1000000;
char buf[BUFSIZE + 1];
string nextString() {
  scanf("%s", buf);
  return buf;
}
int main() {
  int n;
  cin >> n;
  int j = 0;
  for (int i = 0; i < (n); ++i) {
    char c;
    cin >> c;
    a[j] = c;
    ++j;
    if (j >= 2 && a[j - 2] != a[j - 1]) {
      j -= 2;
    }
  }
  cout << j << endl;
  return 0;
}
