5175: ‘1’和‘0’的配对消除

内存限制:256 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:9 通过:3

题目描述


安卓系统的安德鲁德是一个银河系著名的侦探。在他的空闲时间,他喜欢思考包含零和一的字符串。
有一次,他想到了一个由0和1组成的长度为n的字符串。考虑以下操作:我们选择字符串中任何两个相邻的位置,如果其中一个包含0,另一个包含1,那么我们就可以从字符串中删除这两个数字,结果得到一个长度为n-2的字符串。
现在Andreid想一想,在多次应用上述操作后,字符串的最小长度是多少(可能是0)?请帮助他计算出这个数字。
输入
输入的第一行包含一个整数n(1≤n≤2-105),即Andreid拥有的字符串的长度。
第二行包含长度为n的字符串,只由0和1组成。


Andrewid the Android is a galaxy-famous detective. In his free time he likes to think about strings containing zeros and ones.
Once he thought about a string of length n consisting of zeroes and ones. Consider the following operation: we choose any two adjacent positions in the string, and if one them contains 0, and the other contains 1, then we are allowed to remove these two digits from the string, obtaining a string of length n-2 as a result.
Now Andreid thinks about what is the minimum length of the string that can remain after applying the described operation several times (possibly, zero)? Help him to calculate this number.
Input
First line of the input contains a single integer n (1≤n≤2·105), the length of the string that Andreid has.
The second line contains the string of length n consisting only from zeros and ones.
Output
Output the minimum length of the string that may remain after applying the described operations several times.
Examples
Input
4
1100
Output
0
Input
5
01010
Output
1
Input
8
11101111
Output
6
Note
In the first sample test it is possible to change the string like the following: .
In the second sample test it is possible to change the string like the following: .
In the third sample test it is possible to change the string like the following: .

输入格式

输入的第一行N1<=n<=2*10^5),字符的个数

第二行包含一个长为 N 字符数据。

输出格式

输出一行,1’和‘0’配对消除后的字符剩余个数

Examples
Input
4
1100
Output
0
Input
5
01010
Output
1
Input
8
11101111
Output
6

分析:

 

已知字符个数n,将字符读到string字符串,利用string类的索引读取,读到‘1’就char_Count++,读到0’就char_Count--。

最后输出char_Count的绝对值


输入样例 复制

4
1100

输出样例 复制

0