Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- #include <algorithm>
- #include <cmath>
- #include <string>
- #include <vector>
- #include <map>
- #include <set>
- #include <queue>
- #include <assert.h>
- using namespace std;
- #define ll long long
- #define ull unsigned long long
- const ll INF = 1e18;
- const double PI = acos(-1.0);
- int main()
- {
- //freopen("INPUT.TXT", "r", stdin);
- //freopen("OUTPUT.TXT", "w", stdout);
- ios::sync_with_stdio(false);
- int n;
- cin >> n;
- string s;
- cin >> s;
- int cnt0 = 0, cnt1 = 0;
- for (int i = 0; i < n; i++)
- {
- if (s[i] == '0')
- cnt0++;
- else
- cnt1++;
- }
- int mini = min(cnt0, cnt1);
- int res = n - mini * 2;
- cout << res;
- //system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement