http://codeforces.com/problemset/problem/556/A
解题思路:
1.计算0和1的个数,答案就是大减小
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int a0 = 0,a1 = 0;
String str = sc.nextLine();
str = sc.nextLine();
for(int i = 0;i < str.length();i++) {
if(str.charAt(i) == '1') {
a1++;
} else if(str.charAt(i) == '0'){
a0++;
}
}
System.out.println(Math.abs(a0 - a1));
}
}