#include <bits/stdc++.h>
#define S second
#define F first
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using LL = long long;
using LD = long double;
const int mod = 1e9 + 7;
const int N = 1e5+5, M = 1e6+6, OO = 0x3f3f3f3f;
using namespace std ;

bool compare(const pair<int,int> &a, const pair<int,int> &b){
       return (a.first < b.first);
}

int main(){
    IO
    LL n, Ones = 0, Zeros = 0;
    char s[N];
    scanf("%lld%s", &n, &s);
    for (int i = 0; i < n; ++i) {
        if (s[i] & 1)Ones++;
        else Zeros++;
    }
    LL x = (n - (min(Ones, Zeros))* 2);
    printf("%lld\n", x);
}


#include <bits/stdc++.h>
#define S second
#define F first
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using LL = long long;
using LD = long double;
const int mod = 1e9 + 7;
const int N = 1e5+5, M = 1e6+6, OO = 0x3f3f3f3f;
using namespace std ;

int main(){
    IO
    int n, Ones = 0, Zeros = 0;
    char s[N];
    scanf("%d%s", &n, &s[0]);
    for (int i = 0; i < n; ++i) {
        if (s[i] == '1') Ones++
        else Zeros++;
    }
    printf("%d\n", (n - (min(Ones, Zeros))* 2 ));
}


#include<iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int *p = new int[n];
	for (int i = 0; i < n; i++)
		cin >> p[i];
	int*q = new int[n];
	int *r = new int[n];
	int qq = 0, rr = 0, rrr = 0, qqq = 0;
	for (int i = 0; i < n; i++)
	{
		if (p[i]== 1)
		{
			q[qqq] = i + 1;
			qq++; qqq++;
		}
		if (p[i] == 0)
		{
			r[rrr] = i + 1;
			rr++;
			rrr++;
		}
	}
	int vv = 0;
	if (n != 2 && n != 1)
	{
		for (int i = 0; i < rr; i++)
		{
			int x = 0;
			for (int j = 0; j < qq; j++)
			{

				if (r[i] - q[j] == 1)
				{
					vv++;
					x++;
				}
				if (x == 1)
				{
					x = x + 1;

					while (r[i + 1] - q[j] == x)
					{
						vv++;
						i++;
						j--;
						x++;
					}
				}
			}
		}
		int z = vv * 2;
		int zz = n - z;
		cout << zz;
	}
	if (n == 1)
		cout << "0";
	if (n == 2)
	{
		if (r[0] == 2 && q[0] == 1)
		{
			cout << "0";
		}
		else
			cout << n;
	}
}


#include<iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int *p = new int[n];
	for (int i = 0; i < n; i++)
		cin >> p[i];
	int*q = new int[n];
	int *r = new int[n];
	int qq = 0, rr = 0, rrr = 0, qqq = 0;
	for (int i = 0; i < n; i++)
	{
		if (p[i] == 1)
		{
			q[qqq] = i + 1;
			qq++; qqq++;
		}
		if (p[i] == 0)
		{
			r[rrr] = i + 1;
			rr++;
			rrr++;
		}
	}
	int vv = 0;
		for (int i = 0; i < rr; i++)
		{
			int x = 0;
			for (int j = 0; j < qq; j++)
			{

				if (r[i] - q[j] == 1)
				{
					vv++;
					x++;
				}
				if (x == 1)
				{
					x = x + 1;

					while (r[i + 1] - q[j] == x)
					{
						vv++;
						i++;
						j--;
						x++;
					}
				}
			}
		}
		int z = vv * 2;
		int zz = n - z;
		cout << zz;
}


#include<iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	char *p = new char[n];
	cin >> p;
	int*q = new int[n];
	int *r = new int[n];
	int qq = 0, rr = 0, rrr = 0, qqq = 0;
	for (int i = 0; i < n; i++)
	{
		if (p[i]== '1')
		{
			q[qqq] = i + 1;
			qq++; qqq++;
		}
		if (p[i] == '0')
		{
			r[rrr] = i + 1;
			rr++;
			rrr++;
		}
	}
	int vv = 0;
	if (n != 2 && n != 1)
	{
		for (int i = 0; i < rr; i++)
		{
			int x = 0;
			for (int j = 0; j < qq; j++)
			{

				if (r[i] - q[j] == 1)
				{
					vv++;
					x++;
				}
				if (x == 1)
				{
					x = x + 1;

					while (r[i + 1] - q[j] == x)
					{
						vv++;
						i++;
						j--;
						x++;
					}
				}
			}
		}
		int z = vv * 2;
		int zz = n - z;
		cout << zz;
	}
	if (n == 1)
		cout << "1";
	if (n == 2)
	{
		if (r[0] == 1||r[0]==2)
			cout << n;
		else
			cout << "0";
	}
}


#include<iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int *p = new int[n];
	for (int i = 0; i < n; i++)
		cin >> p[i];
	int*q = new int[n];
	int *r = new int[n];
	int qq = 0, rr = 0, rrr = 0, qqq = 0;
	for (int i = 0; i < n; i++)
	{
		if (p[i] == 1)
		{
			q[qqq] = i + 1;
			qq++; qqq++;
		}
		if (p[i] == 0)
		{
			r[rrr] = i + 1;
			rr++;
			rrr++;
		}
	}
	int vv = 0;
	if (n != 2 && n != 1)
	{
		for (int i = 0; i < rr; i++)
		{
			int x = 0;
			for (int j = 0; j < qq; j++)
			{

				if (r[i] - q[j] == 1)
				{
					vv++;
					x++;
				}
				if (x == 1)
				{
					x = x + 1;

					while (r[i + 1] - q[j] == x)
					{
						vv++;
						i++;
						j--;
						x++;
					}
				}
			}
		}
		int z = vv * 2;
		int zz = n - z;
		cout << zz;
	}
	if (n == 1)
		cout << "0";
	if (n == 2)
	{
		if (r[0] == 2 && q[0] == 1)
		{
			cout << "0";
		}
		else
			cout << n;
	}
}


#include<iostream>
#include<string>
using namespace std;
int  main()
{
	int n;
	cin >> n;
	string a;
	cin >> a;
	int v=0, vv=0;
	for (int i = 0; i < n; i++)
	{
		if (a[i] == '0')
		{
			v++;
		}
		if (a[i] == '1')
		{
			vv++;
		}
	}
	if (v == vv)
		cout << "0";
	int x = 0;
	if (v > vv)
	{
		vv = vv * 2;
		cout << n - vv;
		x = 1;
	}
	if (v < vv&&x != 1)
	{
		v = v * 2;
		cout << n - v;
	}
}


#include<iostream>
#include<string>
using namespace std;
int main()
{
	long long s = 0, d = 0;
	long long n;
	cin >> n;
	char *p = new char[n];
	cin >> p;
	long long*q = new long long[n];
	long long *r = new long long[n];
	long long qq = 0, rr = 0, rrr = 0, qqq = 0;
	for (long long i = 0; i < n; i++)
	{
		if (p[i] == '1')
		{
			q[qqq] = i + 1;
			s = i + 1;
			qq++;
			qqq++;
		}
		if (p[i] == '0')
		{
			r[rrr] = i + 1;
			d = i + 1;
			rr++;
			rrr++;
		}
	}
	long long vv = 0;
	if (n != 2 && n != 1)
	{
		for (long long i = 0; i < rr; i++)
		{
			int x = 0;
			for (long long j = 0; j < qq; j++)
			{
				if (r[0] == 1 && q[0] == 1)
				{
					vv++;
				}
				if (r[i] - q[j] == 1)
				{
					vv++;
					x++;
				}
				if (x == 1)
				{
					x = x + 1;

					while (r[i + 1] - q[j] == x)
					{
						vv++;
						i++;
						j--;
						x++;
					}
				}
			}
		}
		if (s -d==1)
			vv++;
		long long z = vv * 2;
		long long zz = n - z;
		cout << zz;
	}
	if (n == 1)
		cout << "1";
	if (n == 2)
	{
		if (r[0] == 1 && q[0] == 2 || r[0] == 2 && q[0] == 1)
		{
			cout << "0";
		}
		else
			cout << n;
	}
}


#include<iostream>
#include<string>
using namespace std;
int main()
{
	long long s = 0, d = 0;
	long long n;
	cin >> n;
	string p;
	cin >> p;
	long long*q = new long long[n];
	long long *r = new long long[n];
	long long qq = 0, rr = 0, rrr = 0, qqq = 0;
	for (long long i = 0; i < n; i++)
	{
		if (p[i] == '1')
		{
			q[qqq] = i + 1;
			s = i + 1;
			qq++;
			qqq++;
		}
		if (p[i] == '0')
		{
			r[rrr] = i + 1;
			d = i + 1;
			rr++;
			rrr++;
		}
	}
	long long vv = 0;
	if (n != 2 && n != 1)
	{
		for (long long i = 0; i < rr; i++)
		{
			int x = 0;
			for (long long j = 0; j < qq; j++)
			{
				if (r[0] == 1 && q[0] == 1)
				{
					vv++;
				}
				if (r[i] - q[j] == 1)
				{
					vv++;
					x++;
				}
				if (x == 1)
				{
					x = x + 1;

					while (r[i + 1] - q[j] == x)
					{
						vv++;
						i++;
						j--;
						x++;
					}
				}
			}
		}
		if (s -d==1)
			vv++;
		long long z = vv * 2;
		long long zz = n - z;
		cout << zz;
	}
	if (n == 1)
		cout << "1";
	if (n == 2)
	{
		if (r[0] == 1 && q[0] == 2 || r[0] == 2 && q[0] == 1)
		{
			cout << "0";
		}
		else
			cout << n;
	}
}


#include<iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int *p = new int[n];
	for (int i = 0; i < n; i++)
		cin >> p[i];
	int*q = new int[n];
	int *r = new int[n];
	int qq = 0, rr = 0, rrr = 0, qqq = 0;
	for (int i = 0; i < n; i++)
	{
		if (p[i] == 1)
		{
			q[qqq] = i + 1;
			qq++; qqq++;
		}
		if (p[i] == 0)
		{
			r[rrr] = i + 1;
			rr++;
			rrr++;
		}
	}
	int vv = 0;
		for (int i = 0; i < rr; i++)
		{
			int x = 0;
			for (int j = 0; j < qq; j++)
			{

				if (r[i] - q[j] == 1)
				{
					vv++;
					x++;
				}
				if (x == 1)
				{
					x = x + 1;

					while (r[i + 1] - q[j] == x)
					{
						vv++;
						i++;
						j--;
						x++;
					}
				}
			}
		}
		cout << "ff";
}


#include<iostream>
#include<string>
using namespace std;
int  main()
{
	int n;
	cin >> n;
	string a;
	cin >> a;
	int v=0, vv=0;
	for (int i = 0; i < n; i++)
	{
		if (a[i] == '0')
		{
			v++;
		}
		if (a[i] == '1')
		{
			vv++;
		}
	}
	if (v == vv)
		cout << "0";
	if (v > vv)
	{
		vv = vv * 2;
		cout << n - vv;
	}
	if (v < vv)
	{
		v = v * 2;
		cout << n - v;
	}
}


#include<iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	char *p = new char[n];
	cin >> p;
	int*q = new int[n];
	int *r = new int[n];
	int qq = 0, rr = 0, rrr = 0, qqq = 0;
	for (int i = 0; i < n; i++)
	{
		if (p[i]== '1')
		{
			q[qqq] = i + 1;
			qq++; qqq++;
		}
		if (p[i] == '0')
		{
			r[rrr] = i + 1;
			rr++;
			rrr++;
		}
	}
	int vv = 0;
	if (n != 2 && n != 1)
	{
		for (int i = 0; i < rr; i++)
		{
			int x = 0;
			for (int j = 0; j < qq; j++)
			{

				if (r[i] - q[j] == 1)
				{
					vv++;
					x++;
				}
				if (x == 1)
				{
					x = x + 1;

					while (r[i + 1] - q[j] == x)
					{
						vv++;
						i++;
						j--;
						x++;
					}
				}
			}
		}
		int z = vv * 2;
		int zz = n - z;
		cout << zz;
	}
	if (n == 1)
		cout << "1";
	if (n == 2)
	{

			cout << n;
	}
}


#include<iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	char *p = new char[n];
	cin >> p;
	int*q = new int[n];
	int *r = new int[n];
	int qq = 0, rr = 0, rrr = 0, qqq = 0;
	for (int i = 0; i < n; i++)
	{
		if (p[i]== '1')
		{
			q[qqq] = i + 1;
			qq++; qqq++;
		}
		if (p[i] == '0')
		{
			r[rrr] = i + 1;
			rr++;
			rrr++;
		}
	}
	int vv = 0;
	if (n != 2 && n != 1)
	{
		for (int i = 0; i < rr; i++)
		{
			int x = 0;
			for (int j = 0; j < qq; j++)
			{

				if (r[i] - q[j] == 1)
				{
					vv++;
					x++;
				}
				if (x == 1)
				{
					x = x + 1;

					while (r[i + 1] - q[j] == x)
					{
						vv++;
						i++;
						j--;
						x++;
					}
				}
			}
		}
		int z = vv * 2;
		int zz = n - z;
		cout << zz;
	}
	if (n == 1)
		cout << "1";
	if (n == 2)
	{
			cout << n;
	}
}


#include<iostream>
using namespace std;
void main()
{
	int n;
	cin >> n;
	int *p = new int[n];
	for (int i = 0; i < n; i++)
		cin >> p[i];
	int*q = new int[n];
	int *r = new int[n];
	int qq = 0, rr = 0, rrr = 0, qqq = 0;
	for (int i = 0; i < n; i++)
	{
		if (p[i]== 1)
		{
			q[qqq] = i + 1;
			qq++; qqq++;
		}
		if (p[i] == 0)
		{
			r[rrr] = i + 1;
			rr++;
			rrr++;
		}
	}
	int vv = 0;
	if (n != 2 && n != 1)
	{
		for (int i = 0; i < rr; i++)
		{
			int x = 0;
			for (int j = 0; j < qq; j++)
			{

				if (r[i] - q[j] == 1)
				{
					vv++;
					x++;
				}
				if (x == 1)
				{
					x = x + 1;

					while (r[i + 1] - q[j] == x)
					{
						vv++;
						i++;
						j--;
						x++;
					}
				}
			}
		}
		int z = vv * 2;
		int zz = n - z;
		cout << zz;
	}
	if (n == 1)
		cout << "0";
	if (n == 2)
	{
		if (r[0] == 2 && q[0] == 1)
		{
			cout << "0";
		}
		else
			cout << n;
	}
}


#include<iostream>
#include<string>
#include<string.h>
using namespace std;
int main()
{
	long long s = 0, d = 0;
	long long n;
	cin >> n;
	char*p = new char[n];
	cin >> p;
	long long*q = new long long[n];
	long long *r = new long long[n];
	long long qq = 0, rr = 0, rrr = 0, qqq = 0;
	for (long long i = 0; i < n; i++)
	{
		if (p[i] == '1')
		{
			q[qqq] = i + 1;
			s = i + 1;
			qq++;
			qqq++;
		}
		if (p[i] == '0')
		{
			r[rrr] = i + 1;
			d = i + 1;
			rr++;
			rrr++;
		}
	}
	long long vv = 0;
	if (n != 2 && n != 1)
	{
		for (long long i = 0; i < rr; i++)
		{
			int x = 0;
			for (long long j = 0; j < qq; j++)
			{
				if (r[0] == 1 && q[0] == 1)
				{
					vv++;
				}
				if (r[i] - q[j] == 1)
				{
					vv++;
					x++;
				}
				if (x == 1)
				{
					x = x + 1;

					while (r[i + 1] - q[j] == x)
					{
						vv++;
						i++;
						j--;
						x++;
					}
				}
			}
		}
		if (s - d == 1)
			vv++;
		long long z = vv * 2;
		long long zz = n - z;
		cout << zz;
	}
	if (n == 1)
		cout << "1";
	if (n == 2)
	{
		if (r[0] == 1 && q[0] == 2 || r[0] == 2 && q[0] == 1)
		{
			cout << "0";
		}
		else
			cout << n;
	}
}


#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main ()
{
    int n, zeroCount = 0, oneCount = 1;
    string str;
    cin >> n;
    cin >> str;
    zeroCount = count (str.begin(), str.end(), '0');
    oneCount = count (str.begin(), str.end(), '1');
    if (zeroCount == oneCount) {
        cout << 0 << endl;
    }
    else if (zeroCount < oneCount) {
        cout << n - zeroCount * 2 << endl;
    }
    else {
        cout << n - oneCount * 2 << endl;
    }
    return 0;
}


#include <iostream>
#include <string>

using namespace std;

int main()
{
    int n, count = 0;
    bool flag = false;
    string str;
    cin >> n;
    cin >> str;
    for (int i = 0; i < n - 1; i += 2) {
        if (str[i] == str[i + 1]) {
            for (int j = i + 2; j < n; ++j) {
                if (str[i + 1] != str[j]) {
                    swap(str[i + 1], str[j]);
                    break;
                }
                else if (str[i + 1] == str[j] && j == n - 1) {
                    flag = true;
                    break;
                }
            }
        }
        if (flag) {
            break;
        }
    }
    for (int i = 0; i < n - 1; i+=2) {
        if (str[i] != str[i + 1]) {
            count += 2;
        }
        else {
            break;
        }
    }
    cout << n - count;
    return 0;
}


#include <iostream>
#include <string>

using namespace std;

int main()
{
    int n, count = 0;
    bool flag = false;
    string str;
    cin >> n;
    cin >> str;
    for (int i = 0; i < n - 1; i += 2) {
        if (str[i] == str[i + 1]) {
            for (int j = i + 2; j < n; ++j) {
                if (str[i + 1] != str[j]) {
                    swap(str[i + 1], str[j]);
                    count += 2;
                    break;
                }
                else if (str[i + 1] == str[j] && j == n - 1) {
                    flag = true;
                    break;
                }
            }
        }
        else if (str[i] != str[i + 1]) {
            count += 2;
        }
        if (flag) {
            break;
        }
    }
    cout << n - count << endl;
    return 0;
}


#include <iostream>
#include <string>

using namespace std;

int main()
{
    int n, count = 0;
    string str;
    cin >> n;
    cin >> str;
    for (int i = 0; i < n - 1; ++i) {
        if (str[i] == str[i + 1]) {
            for (int j = i + 2; j < n; ++j) {
                if (str[i + 1] != str[j]) {
                    swap(str[i + 1], str[j]);
                    break;
                }
            }
        }
        else {
            ++i;
        }
    }

    for (int i = 0; i < n - 1; i+=2) {
        if (str[i] != str[i + 1]) {
            count += 2;
        }
        else {
            break;
        }
    }
    cout << n - count;
    return 0;
}


#include <iostream>
#include <string>

using namespace std;

int main()
{
    int n, count = 0;
    bool flag = false;
    string str;
    cin >> n;
    cin >> str;
    for (int i = 0; i < n - 1; i += 2) {
        if (str[i] == str[i + 1]) {
            for (int j = i + 2; j < n; ++j) {
                if (str[i + 1] != str[j]) {
                    swap(str[i + 1], str[j]);
                    break;
                }
                else if (str[i + 1] == str[j] && j == n - 1) {
                    flag = true;
                }
            }
        }
        if (flag) {
            break;
        }
    }

    for (int i = 0; i < n - 1; i+=2) {
        if (str[i] != str[i + 1]) {
            count += 2;
        }
        else {
            break;
        }
    }
    cout << n - count;
    return 0;
}


#include <iostream>
#include <string>

using namespace std;

int main()
{
    int n, count = 0;
    string str;
    cin >> n;
    cin >> str;
    for (int i = 0; i < n - 1; ++i) {
        if (str[i] == str[i + 1]) {
            for (int j = i + 2; j < n; ++j) {
                if (str[i + 1] != str[j]) {
                    swap(str[i + 1], str[j]);
                    break;
                }
            }
        }
    }
    for (int i = 0; i < n - 1; i+=2) {
        if (str[i] != str[i + 1]) {
            count += 2;
        }
        else {
            break;
        }
    }
    cout << n - count;
    return 0;
}


#include <iostream>
using namespace std;
long long a1,a0;
int main() {
	long long n;
	cin>>n;
	string s;
	for(int i=0;i<n;i++){
		cin>>s[i];
		if(s[i]=='0'){
			a0++;
		}
		else{
			a1++;
		}
	}
//	cout<<a1<<"0";
//	cout<<a0<<endl;
	if((a1-a0)>=0){
		cout<<a1-a0;
	}
	else{
		cout<<a0-a1;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,a,b;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		char c;
		cin>>c;
		if(c=='1')
			a++;
		else
			b++;
	}
	cout<<a+b-(2*min(a,b));
}


#include <iostream>
using namespace std;
int a1,a0;
int main() {
	int n;
	cin>>n;
	string s;
	for(int i=0;i<n;i++){
		cin>>s[i];
		if(s[i]=='0'){
			a0++;
		}
		else{
			a1++;
		}
	}
//	cout<<a1<<"0";
//	cout<<a0<<endl;
	if((a1-a0)>=0){
		cout<<a1-a0;
	}
	else{
		cout<<a0-a1;
	}
	return 0;
}


#include <iostream>
using namespace std;
long long a1,a0;
int main() {
	long long n;
	cin>>n;
	string s;
	for(long long i=0;i<n;i++){
		cin>>s[i];
		if(s[i]=='0'){
			a0++;
		}
		else{
			a1++;
		}
	}
//	cout<<a1<<"0";
//	cout<<a0<<endl;
	if((a1-a0)>=0){
		cout<<a1-a0;
	}
	else{
		cout<<a0-a1;
	}
	return 0;
}


#include <iostream>
using namespace std;
long long t1,t0,n;
string a;
int main() {
	cin>>n;
	for(long long i=0;i<n;i++){
		cin>>a[i];
		if(a[i]=='1'){
			t1++;
		}
		else{
			t0++;
		}
	}
	if(t0>t1){
		cout<<t0-t1;
		return 0;
	}
	cout<<t1-t0;
	return 0;
}


#include <iostream>
using namespace std;
int t1,t0,n;
string a;
int main() {
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]=='1'){
			t1++;
		}
		else{
			t0++;
		}
	}
	if(t0>t1){
		cout<<t0-t1;
		return 0;
	}
	cout<<t1-t0;
	return 0;
}


#include<bits/stdc++.h>

#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3fLL
#define mod 1000000007
#define pb emplace_back
#define sq(x) ((x)*(x))
#define sz(a) ((int)a.size())
#define eps 1e-8
#define x first
#define y second
#define bpt(x) (__builtin_popcount(x))
#define bptl(x) (__builtin_popcountll(x))
#define bit(x, y) (((x)>>(y))&1)
#define bclz(x) (__builtin_clz(x))
#define bclzl(x) ((x) ? (__builtin_clzll(x)) : 0)
#define bctz(x) (__builtin_ctz(x))
#define bctzl(x) (__builtin_ctzll(x))
#define shit(a) (1 << (a))
#define rev(a) (power(a, mod-2, mod))
#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef double DO;
typedef long long INT;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;
typedef vector<int> VI;

template<typename T, typename U> inline void smin(T &a, U b) {if(a>b) a=b;}
template<typename T, typename U> inline void smax(T &a, U b) {if(a<b) a=b;}

template<class T>inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}
template<class T>inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}
template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}
template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}
template <class T> inline void println(T x) {print(x); putchar('\n');}
template <class T> inline void printsp(T x) {print(x); putchar(' ');}
template <class T1, class T2> inline void print(T1 x1, T2 x2) {printsp(x1), println(x2);}
template <class T1, class T2, class T3> inline void print(T1 x1, T2 x2, T3 x3) {printsp(x1), printsp(x2), println(x3);}
template <class T1, class T2, class T3, class T4> inline void print(T1 x1, T2 x2, T3 x3, T4 x4) {printsp(x1), printsp(x2), printsp(x3), println(x4);}
template <class T> inline void eprint(T x) {cerr << "--------> " <<x << endl;}
template <class T1, class T2> inline void eprint(T1 x, T2 y) { cerr << "--------> " << x << ' ' << y << endl; }
template <class T1, class T2, class T3> inline void eprint(T1 x, T2 y, T3 z) { cerr << " -------> " << x << ' ' << y << ' ' << z << endl;}
template <class T1, class T2, class T3, class T4> inline void eprint(T1 x, T2 y, T3 z, T4 w) { cerr << " -------> " << x << ' ' << y << ' ' << z << ' ' << w << endl;}
int power(int a, int b, int m, int ans=1) {
	for(; b; b>>=1, a=1LL*a*a%m) if(b&1) ans=1LL*ans*a%m;
	return ans;
}
#define NN 100050

char s[NN];
int main() {
#ifndef	ONLINE_JUDGE
	freopen("in.in", "r", stdin);
//	freopen("out.out", "w", stdout);
#endif
	int n,cnt=0;
	cin>>n;
	scanf("%s",s);
	for(int i=0;i<n;i++)if(s[i]=='0')cnt++;
	cout<<abs(n-2*cnt)<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define NN 200200
using namespace std;
typedef long long INT;
char str[NN];
int main(){
#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif
	int n;
	scanf("%d", &n);
	cin>>str;
	int cnt1 = 0, cnt2 = 0;
	for(int i = 0; i < n; i++){
		if(str[i] - '0' == 1) cnt1++;
		else cnt2++;
	}
	cout<<abs(cnt1 - cnt2)<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define NN 210000

using namespace std;

typedef long long INT;
char st[NN];

int main(){
#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n;
	cin>>n;
	cin>>st;
	int a=0,b=0;
	for(int i=0;i<n;i++){
		if(st[i]=='0')a++;
		if(st[i]=='1')b++;
	}
	cout<<abs(a-b)<<endl;

	return 0;
}
#include<bits/stdc++.h>
#define NN 210000

using namespace std;

typedef long long INT;
char st[NN];

int main(){
#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n;
	cin>>n;
	cin>>st;
	int a=0,b=0;
	for(int i=0;i<n;i++){
		if(st[i]=='0')a++;
		if(st[i]=='1')b++;
	}
	cout<<abs(a-b)<<endl;

	return 0;
}


#include<bits/stdc++.h>
#define bclz(x) (__builtin_clz(x))
#define x first
#define y second
using namespace std;
typedef long long INT;
typedef vector<int> VI;
typedef pair<int,int> pii;
char a[200200];
int main(){
#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n;
	cin>>n;
	cin>>a;
	int z=0,o=0;
	for(int i=0;i<n;i++) {
		if(a[i]=='1') o++;
		else z++;
	}
	z=min(z,o);
	cout<<n-z*2<<endl;
	return 0;
}


#include<bits/stdc++.h>

#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3fLL
#define mod 1000000007
#define pb emplace_back
#define sq(x) ((x)*(x))
#define sz(a) ((int)a.size())
#define eps 1e-8
#define x first
#define y second
#define bpt(x) (__builtin_popcount(x))
#define bptl(x) (__builtin_popcountll(x))
#define bit(x, y) (((x)>>(y))&1)
#define bclz(x) (__builtin_clz(x))
#define bclzl(x) ((x) ? (__builtin_clzll(x)) : 0)
#define bctz(x) (__builtin_ctz(x))
#define bctzl(x) (__builtin_ctzll(x))
#define shit(a) (1 << (a))
#define rev(a) (power(a, mod-2, mod))
#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef double DO;
typedef long long INT;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;
typedef vector<int> VI;

template<typename T, typename U> inline void smin(T &a, U b) {if(a>b) a=b;}
template<typename T, typename U> inline void smax(T &a, U b) {if(a<b) a=b;}

template<class T>inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}
template<class T>inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}
template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}
template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}
template <class T> inline void println(T x) {print(x); putchar('\n');}
template <class T> inline void printsp(T x) {print(x); putchar(' ');}
template <class T1, class T2> inline void print(T1 x1, T2 x2) {printsp(x1), println(x2);}
template <class T1, class T2, class T3> inline void print(T1 x1, T2 x2, T3 x3) {printsp(x1), printsp(x2), println(x3);}
template <class T1, class T2, class T3, class T4> inline void print(T1 x1, T2 x2, T3 x3, T4 x4) {printsp(x1), printsp(x2), printsp(x3), println(x4);}
template <class T> inline void eprint(T x) {cerr << "--------> " <<x << endl;}
template <class T1, class T2> inline void eprint(T1 x, T2 y) { cerr << "--------> " << x << ' ' << y << endl; }
template <class T1, class T2, class T3> inline void eprint(T1 x, T2 y, T3 z) { cerr << " -------> " << x << ' ' << y << ' ' << z << endl;}
template <class T1, class T2, class T3, class T4> inline void eprint(T1 x, T2 y, T3 z, T4 w) { cerr << " -------> " << x << ' ' << y << ' ' << z << ' ' << w << endl;}
int power(int a, int b, int m, int ans=1) {
	for(; b; b>>=1, a=1LL*a*a%m) if(b&1) ans=1LL*ans*a%m;
	return ans;
}
#define NN 200050

char s[NN];
int main() {
#ifndef	ONLINE_JUDGE
	freopen("in.in", "r", stdin);
//	freopen("out.out", "w", stdout);
#endif
	int n,cnt=0;
	cin>>n;
	if(n==1){puts("1");return 0;}
	scanf("%s",s);
	for(int i=0;i<n;i++)if(s[i]=='0')cnt++;
	cout<<abs(n-2*cnt)<<endl;
	return 0;
}


#include<bits/stdc++.h>

#define NN 210000

using namespace std;

char st[NN];

int main(){
#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n;
	cin>>n;
	cin>>st;
	int a=0,b=0;
	for(int i=0;i<n;i++){
		if(st[i]=='0')a++;
		else b++;
	}
	int ans=abs(b-a);
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>

#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3fLL
#define mod 1000000007
#define pb emplace_back
#define sq(x) ((x)*(x))
#define sz(a) ((int)a.size())
#define eps 1e-8
#define x first
#define y second
#define bpt(x) (__builtin_popcount(x))
#define bptl(x) (__builtin_popcountll(x))
#define bit(x, y) (((x)>>(y))&1)
#define bclz(x) (__builtin_clz(x))
#define bclzl(x) ((x) ? (__builtin_clzll(x)) : 0)
#define bctz(x) (__builtin_ctz(x))
#define bctzl(x) (__builtin_ctzll(x))
#define shit(a) (1 << (a))
#define rev(a) (power(a, mod-2, mod))
#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef double DO;
typedef long long INT;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;
typedef vector<int> VI;

template<typename T, typename U> inline void smin(T &a, U b) {if(a>b) a=b;}
template<typename T, typename U> inline void smax(T &a, U b) {if(a<b) a=b;}

template<class T>inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}
template<class T>inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}
template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}
template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}
template <class T> inline void println(T x) {print(x); putchar('\n');}
template <class T> inline void printsp(T x) {print(x); putchar(' ');}
template <class T1, class T2> inline void print(T1 x1, T2 x2) {printsp(x1), println(x2);}
template <class T1, class T2, class T3> inline void print(T1 x1, T2 x2, T3 x3) {printsp(x1), printsp(x2), println(x3);}
template <class T1, class T2, class T3, class T4> inline void print(T1 x1, T2 x2, T3 x3, T4 x4) {printsp(x1), printsp(x2), printsp(x3), println(x4);}
template <class T> inline void eprint(T x) {cerr << "--------> " <<x << endl;}
template <class T1, class T2> inline void eprint(T1 x, T2 y) { cerr << "--------> " << x << ' ' << y << endl; }
template <class T1, class T2, class T3> inline void eprint(T1 x, T2 y, T3 z) { cerr << " -------> " << x << ' ' << y << ' ' << z << endl;}
template <class T1, class T2, class T3, class T4> inline void eprint(T1 x, T2 y, T3 z, T4 w) { cerr << " -------> " << x << ' ' << y << ' ' << z << ' ' << w << endl;}
int power(int a, int b, int m, int ans=1) {
	for(; b; b>>=1, a=1LL*a*a%m) if(b&1) ans=1LL*ans*a%m;
	return ans;
}
#define NN 100050

char s[NN];
int main() {
#ifndef	ONLINE_JUDGE
	freopen("in.in", "r", stdin);
//	freopen("out.out", "w", stdout);
#endif
	int n,cnt=0;
	cin>>n;
	if(n==1){puts("1");return 0;}
	scanf("%s",s);
	for(int i=0;i<n;i++)if(s[i]=='0')cnt++;
	cout<<abs(n-2*cnt)<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
char s[200020];
int main() {
#ifndef ONLINE_JUDGE
	freopen("18in.in", "r", stdin);
	freopen("18out.out", "w", stdout);
#endif
	int len;
	cin>>len;
	cin>>s;
	int a=0,b=0;
	for(int i=0;i<len;i++){
		if(s[i]=='0') a++;
		else b++;
	}
	int mn=min(a,b);
	cout<<len-2*mn;

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define NN 200010
char s[NN];

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif
	int n;
	scanf("%d",&n);
	scanf("%s",s+1);
	int a=0,b=0;
	for(int i=1;i<=n;i++){
		if(s[i]=='0') a++;
		else b++;
	}
	if(a<b) swap(a,b);
	printf("%d\n",a-b);

    return 0;
}


#include <bits/stdc++.h>

#define x first
#define y second
#define mod 1000000007
#define pb push_back
#define inf 0x3f3f3f3f
#define bclz(x) (__builtin_clz(x))
#define bctz(x) (__builtin_ctz(x))

using namespace std;

typedef long long INT;
typedef pair<int, int> pii;
typedef pair<pii, int> pi3;
typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}
template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<typename T> inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}
template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}
template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}
template<typename T> inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}
template<typename T> inline void println(T x) {print(x), putchar('\n');}
template<typename T> inline void printsp(T x) {print(x), putchar(' ');}
template<class T, class T1> inline void print(T x, T1 y) {printsp(x), println(y);}
template<class T, class T1, class T2> inline void print(T x, T1 y, T2 z) {printsp(x), printsp(y), println(z);}

int power(int a, int b, int m, int ans=1) {
	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;
	return ans;
}

#define NN 200010
char str[NN];

int main () {
#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out","w",stdout);
#endif
	int len;
	gn(len);
	cin>>str;
	int cnt1=0, cnt0=0, ans=0;
	for (int i=0; i<len; i++) {
		if (str[i]=='1') cnt1++;
		else cnt0++;
	}
	ans=len-2*min(cnt1, cnt0);
	println(ans);
	return 0;
}


#include<bits/stdc++.h>
#define NN 210000

using namespace std;

char st[NN];

int main(){
#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n;
	cin>>n;
	cin>>st;
	int a=0,b=0;
	for(int i=0;i<n;i++){
		if(st[i]=='0')a++;
		else (st[i]=='1')b++;
	}
	int ans=abs(b-a);
	cout<<ans<<endl;
	return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
    int i=0,l;
    long long n;
    string s;
    cin>>n;

    cin>>s;
    l=n;
      while((i<l-1))
       {
       if (s[i]!=s[i+1]) {
                s=s.erase(i,2);l-=2;i=0;}
      else   i++;
    }

    cout<<s.size()<<endl;
    return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
      ios_base::sync_with_stdio(false);
    int i=0,l;
    long long n;
    string s;
    cin>>n;

    cin>>s;
    l=n;
      while((i<l-1))
       {
       if (s[i]!=s[i+1]) {
                s=s.erase(i,2);l-=2;i=0;}
      else   i++;
    }

    cout<<s.size()<<endl;
    return 0;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

int main()
{
  int i,n,c1=0,c2=0;
  double x;
  string s;
  cin>>n;
  cin>>s;
  for (i=0;i<n;i++)
  {
      if (s[i]=='0') c1++;
      else c2++;
  }
  x=c1-c2;
  cout<<abs(x)<<endl;
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

int main()
{
      ios_base::sync_with_stdio(false);
    int i=0,l;
    long long n;
    string s;
    cin>>n;

    cin>>s;
        int found=s.find('1');

if (found<0) {cout<<s.size();}

else {
        found=s.find('0');
        if (found<0) {cout<<s.size();}
        else {
    l=n;
      while((i<l-1))
       {
       if (s[i]!=s[i+1]) {
                s=s.erase(i,2);l-=2;i=0;}
      else   i++;
    }

    cout<<s.size()<<endl;}}
    return 0;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

int main()
{
  int i,n,c1=0,c2=0;
  double x;
  string s;
  cin>>n;
  cin>>s;
  for (i=0;i<n;i++)
  {
      if (s[i]==0) c1++;
      else c2++;
  }
  x=c1-c2;
  cout<<abs(x)<<endl;
    return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
    int i=0,j=0 ,n,l;
    string s;
    bool verif=true;
    cin>>n;
    cin>>s;
    while((j<n-1)&&(verif))
    {
        if (s[j]==s[j+1]) j++;
        else verif=false;
    }
    if (verif) cout<<s.size()<<endl;
    else { l=n;
      while(i<l-1)
       {
       if (s[i]!=s[i+1]) {
                s=s.erase(i,2);l-=2;i=0;}
      else   i++;
    }

    cout<<s.size()<<endl;}
    return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
    int i=0, n,l;
    string s;
    cin>>n;

    cin>>s;
    l=n;
      while((i<l-1))
       {
       if (s[i]!=s[i+1]) {
                s=s.erase(i,2);l-=2;i=0;}
      else   i++;
    }

    cout<<s.size()<<endl;
    return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
    int i=0, n,l=0;
    string s;
    cin>>n;
    cin>>s;
    l=n;
      while((i<l-1)&&(!test))
       {
       if (s[i]!=s[i+1]) {
                s=s.erase(i,2);l-=2;i=0;}
      else   i++;
    }

    cout<<s.size()<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,c=0,m=0;
    cin>>n;
    m=n;
    string s;
    cin>>s;
    deque<char>v;
    for(int i=0;i<n;i++)
    {
    v.push_back(s[i]);
    }
    for(int i=0;i<n-1;i++)
    {

        if((v[i]=='0'&&v[i+1]=='1')||(v[i]=='1'&&v[i+1]=='0'))
        {

                v.erase(v.begin()+i);
                 v.erase(v.begin()+i);

            m-=2;
            if(i!=0&&v.size()>1)
                i-=2;
   // i+=1;

        }

    }
    for(int i=0;i<v.size();i++)
        cout<<v[i];

    cout<<m<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,c=0,m=0;
    cin>>n;
    m=n;
    string s;
    cin>>s;
    deque<char>v;
    for(int i=0;i<n;i++)
    {
    v.push_back(s[i]);
    }
    for(int i=0;i<n-1;i++)
    {

        if((v[i]=='0'&&v[i+1]=='1')||(v[i]=='1'&&v[i+1]=='0'))
        {

                v.erase(v.begin()+i);
                 v.erase(v.begin()+i);

            n-=2;
            if(i!=0&&v.size()>1)
                i-=2;
   // i+=1;

        }

    }

    cout<<n<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,c=0,m=0;
    cin>>n;
    m=n;
    string s;
    cin>>s;
    deque<char>v;
    for(int i=0;i<n;i++)
    {
    v.push_back(s[i]);
    }
    for(int i=0;i<n-1;i++)
    {

        if((v[i]=='0'&&v[i+1]=='1')||(v[i]=='1'&&v[i+1]=='0'))
        {

                v.erase(v.begin()+i);
                 v.erase(v.begin()+i);

            m-=2;
            if(i!=0&&v.size()>1)
                i-=2;
   // i+=1;

        }

    }

    cout<<m<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,c=0,m=0;
    cin>>n;
    m=n;
    string s;
    cin>>s;
    deque<char>v;
    for(int i=0;i<n;i++)
    {
    v.push_back(s[i]);
    }
    for(int i=0;i<n-1;i++)
    {
        if((v[i]=='0'&&v[i+1]=='1')||(v[i]=='1'&&v[i+1]=='0'))
        {

                v.erase(v.begin()+i);
                 v.erase(v.begin()+i);

            m-=2;
            if(i!=0)
                i-=2;
   // i+=1;

        }

    }

    cout<<m<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    string s;
    cin>>n>>s;
    stack <char> st;
    for(int i=0;i<n;i++)
    {
        if(st.size()){
        if(st.top()=='1'&&s[i]=='0'||st.top()=='0'&&s[i]=='1')
        st.pop();
        else
            st.push(s[i]);
        }
        else
          st.push(s[i]);
    }
    cout<<st.size()<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,c=0,h=0;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='0')
            c++;
        else
            h++;
    }
    if(c==h)
        cout<<0<<endl;
    else
        cout<<(max(c,h))-(min(c,h))<<endl;
    return 0;
}


#include <iostream>
#include <string>

int main ()
{
    int n;
    std::cin >> n;

    std::string bin;
    std::cin >> bin;

    if ((bin.find("10") == std::string::npos) &&
        (bin.find("01") == std::string::npos))
    {
        std::cout << n;
        return 0;
    }

    while (bin.find("10") != std::string::npos)
    {
        bin.erase(bin.find("10"), 2);
    }

    while (bin.find("01") != std::string::npos)
    {
        bin.erase(bin.find("01"), 2);
    }

    std::cout << bin.size();

    return 0;
}


#include <iostream>
#include <string>

int main ()
{
    int n;
    std::cin >> n;

    std::string bin;
    std::cin >> bin;

    while ((bin.find("10") != std::string::npos) && (bin.find("01") != std::string::npos))
    {
        bin.erase(bin.find("10"), 2);
        bin.erase(bin.find("01"), 2);
    }

    std::cout << bin.size();

    return 0;
}


#include <iostream>
#include <string>

int main ()
{
    int n;
    std::cin >> n;

    std::string bin;
    std::cin >> bin;

    for (int i=0; i < n-1; i++)
    {
        if (((bin[i] == '0') && (bin[i+1] == '1')) ||
            ((bin[i] == '1') && (bin[i+1] == '0')))
        {
            n -= 2;
            i++;
        }
    }

    std::cout << n;

    return 0;
}


#include <iostream>
#include <string>

int main ()
{
    int n;
    std::cin >> n;

    std::string bin;
    std::cin >> bin;

    int i=0;
    std::string a;

    while (i != -1)
    {
        if (bin.find("10") != std::string::npos)
        {
            i = 1;
            n -= 2;
            bin.erase(bin.find("10"), 2);
            continue;
        }
        else if (bin.find("01") != std::string::npos)
        {
            i = 1;
            n -= 2;
            bin.erase(bin.find("01"), 2);

        }
        else
        {
            i = -1;
            continue;
        }
    }

    std::cout << n;

    return 0;
}


#include <iostream>
#include <string>

int main ()
{
    int n;
    std::cin >> n;

    std::string bin;
    std::cin >> bin;

    while (bin.find("10") != std::string::npos)
    {
        bin.erase(bin.find("10"), 2);
    }

    while (bin.find("01") != std::string::npos)
    {
        bin.erase(bin.find("01"), 2);
    }

    std::cout << bin.size();

    return 0;
}


#include <iostream>
#include <string>

int main ()
{
    int n;
    std::cin >> n;

    std::string bin;
    std::cin >> bin;

    for (int i=0; i < n-1; i++)
    {
        if (((bin[i] == '0') && (bin[i+1] == '1')) ||
            ((bin[i] == '1') && (bin[i+1] == '0')))
        {
            n -= 2;
            bin.erase(i, 2);
            i -= 2;
        }
    }

    std::cout << n;

    return 0;
}


///////////////////////////////////////////////////
/////////////By Taimasov Shyntemir/////////////////
///////////////////////////////////////////////////
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define pp pop_back
#define mp make_pair
#define db double
#define ldb long double
#define str string
#define rep(i,n) for(int i=0;i<n;i++)
#define repit(i,n) for(int i=1;i<=n;i++)
#define repi(i,n) for(int i=1;i<n;i++)
#define shandom_ruffle random_shuffle
const int MAXN=1e5+5;
const ll MOD=998244353;
const int INF=0x3f3f3f3f;
const ll LL_INF=0x3f3f3f3f3f3f3f3f;
const db PI=acos(-1);
const db ERR=1e-10;
const int L=40;
const int M=30;
using namespace std;
ll mx=-1e18;
ll mn=1e18;
int main(){
    ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);
	cout.tie(NULL);
	string a;
	ull b=0,c=0;
	cin>>a;
	rep(i,a.size()){
		if(a[i]=='0'){
			c++;
		}
		if(a[i]=='1'){
			b++;
		}
	}
	cout<<abs(c-b);
    return 0;
}


///////////////////////////////////////////////////
/////////////By Taimasov Shyntemir/////////////////
///////////////////////////////////////////////////
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define pp pop_back
#define mp make_pair
#define db double
#define ldb long double
#define str string
#define rep(i,n) for(int i=0;i<n;i++)
#define repit(i,n) for(int i=1;i<=n;i++)
#define repi(i,n) for(int i=1;i<n;i++)
#define shandom_ruffle random_shuffle
const int MAXN=1e5+5;
const ll MOD=998244353;
const int INF=0x3f3f3f3f;
const ll LL_INF=0x3f3f3f3f3f3f3f3f;
const db PI=acos(-1);
const db ERR=1e-10;
const int L=40;
const int M=30;
using namespace std;
ll mx=-1e18;
ll mn=1e18;
int main(){
    ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);
	cout.tie(NULL);
	string a;
	ull b=0,c=0,s;
	cin>>s>>a;
	rep(i,s){
		if(a[i]=='0'){
			c++;
		}
		if(a[i]=='1'){
			b++;
		}
	}
	cout<<abs(c-b);
    return 0;
}


///////////////////////////////////////////////////
/////////////By Taimasov Shyntemir/////////////////
///////////////////////////////////////////////////
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define pp pop_back
#define mp make_pair
#define db double
#define ldb long double
#define str string
#define rep(i,n) for(int i=0;i<n;i++)
#define repit(i,n) for(int i=1;i<=n;i++)
#define repi(i,n) for(int i=1;i<n;i++)
#define shandom_ruffle random_shuffle
const int MAXN=1e5+5;
const ll MOD=998244353;
const int INF=0x3f3f3f3f;
const ll LL_INF=0x3f3f3f3f3f3f3f3f;
const db PI=acos(-1);
const db ERR=1e-10;
const int L=40;
const int M=30;
using namespace std;
ll mx=-1e18;
ll mn=1e18;
int main(){
    ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);
	cout.tie(NULL);
	string a;
	ull b=0,c=0,s;
	cin>>s>>a;
	rep(i,s){
		if(a[i]=='0'){
			c++;
		}
		else if(a[i]=='1'){
			b++;
		}
	}
	cout<<abs(c-b);
    return 0;
}


///////////////////////////////////////////////////
/////////////By Taimasov Shyntemir/////////////////
///////////////////////////////////////////////////
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define pp pop_back
#define mp make_pair
#define db double
#define ldb long double
#define str string
#define rep(i,n) for(int i=0;i<n;i++)
#define repit(i,n) for(int i=1;i<=n;i++)
#define repi(i,n) for(int i=1;i<n;i++)
#define shandom_ruffle random_shuffle
const int MAXN=1e5+5;
const ll MOD=998244353;
const int INF=0x3f3f3f3f;
const ll LL_INF=0x3f3f3f3f3f3f3f3f;
const db PI=acos(-1);
const db ERR=1e-10;
const int L=40;
const int M=30;
using namespace std;
ll mx=-1e18;
ll mn=1e18;
int main(){
    ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);
	cout.tie(NULL);
	string a;
    ull a,b,c,d=0;
    cin>>a;
    rep(i,a){
    	cin>>b>>c;
    	if(b<c-2){
    		d++;
		}
	}
	cout<<d;
    return 0;
}


///////////////////////////////////////////////////
/////////////By Taimasov Shyntemir/////////////////
///////////////////////////////////////////////////
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define pp pop_back
#define mp make_pair
#define db double
#define ldb long double
#define str string
#define rep(i,n) for(int i=0;i<n;i++)
#define repit(i,n) for(int i=1;i<=n;i++)
#define repi(i,n) for(int i=1;i<n;i++)
#define shandom_ruffle random_shuffle
const int MAXN=1e5+5;
const ll MOD=998244353;
const int INF=0x3f3f3f3f;
const ll LL_INF=0x3f3f3f3f3f3f3f3f;
const db PI=acos(-1);
const db ERR=1e-10;
const int L=40;
const int M=30;
using namespace std;
ll mx=-1e18;
ll mn=1e18;
int main(){
    ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);
	cout.tie(NULL);
	string a;
	ull b=0,c=0;
	cin>>a;
	rep(i,a.size()){
		if(a[i]=='0'){
			c++;
		}
		if(a[i]=='1'){
			b++;
		}
	}
	cout<<c-b;
    return 0;
}


///////////////////////////////////////////////////
/////////////By Taimasov Shyntemir/////////////////
///////////////////////////////////////////////////
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define pp pop_back
#define mp make_pair
#define db double
#define ldb long double
#define str string
#define rep(i,n) for(int i=0;i<n;i++)
#define repit(i,n) for(int i=1;i<=n;i++)
#define repi(i,n) for(int i=1;i<n;i++)
#define shandom_ruffle random_shuffle
const int MAXN=1e5+5;
const ll MOD=998244353;
const int INF=0x3f3f3f3f;
const ll LL_INF=0x3f3f3f3f3f3f3f3f;
const db PI=acos(-1);
const db ERR=1e-10;
const int L=40;
const int M=30;
using namespace std;
ll mx=-1e18;
ll mn=1e18;
int main(){
    ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);
	cout.tie(NULL);
	string a;
	ll b=0,c=0,s;
	cin>>s>>a;
	for(int i=0;i<s;i++){
		if(a[i]=='0'){
			c++;
		}
		else if(a[i]=='1'){
			b++;
		}
	}
	cout<<abs(c-b);
    return 0;
}


#include<iostream>
using namespace std;
int main()
{
   int c1=0,c2=0,n;
   cin>>n;
   string a;
   for(int i=0;i<n;i++)
   {
      if(a[i]==1)
        { c1++;}
      if(a[i]==0)
        { c2++;}

   }
   if(c1==c2)
      cout<<"0";
   if(c1>c2)
   {
      cout<<n-(c2*2);
   }
   if(c2>c1)
      cout<<n-(c1*2);
}


#include<iostream>
using namespace std;
int main()
{
   int c1=0,c2=0,n;
   cin>>n;
string a;
cin>>a;
   for(int i=0;i<n;i++)
   {
      if(a[i]=='1')
        { c1++;}
      if(a[i]=='0')
        { c2++;}

   }
   if(c1==c2)
      cout<<"0";
   if(c1>c2)
   {
      cout<<n-(c2*2);
   }
   if(c2>c1)
      cout<<n-(c1*2);
}


#include<iostream>
using namespace std;
int main()
{
   int c1=0,c2=0,n;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++)
      {cin>>a[i];
      }

  // int n=a.size();
   for(int i=0;i<n;i++)
   {
      if(a[i]==1)
        { c1++;}
      if(a[i]==0)
        { c2++;}

   }
   if(c1==c2)
      cout<<"0";
   if(c1>c2)
   {
      cout<<n-(c2*2);
   }
   if(c2>c1)
      cout<<n-(c1*2);
}


#include<iostream>
using namespace std;
int main()
{
   int n,c1=0,c2=0;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++)
   {
      cin>>a[i];
      if(a[i]==1)
         c1++;
      if(a[i]==0)
         c2++;
   }
   if(c1==c2)
      cout<<"0";
   if(c1>c2)
   {
      cout<<n-(c2*2);
   }
   if(c2>c1)
      cout<<n-(c1*2);
}


#include<iostream>
using namespace std;
int main()
{
   int c1=0,c2=0,n;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++)
      {cin>>a[i];
      }

  // int n=a.size();
   for(int i=0;i<n;i++)
   {
      if(a[i]==1)
        { c1++;}
      if(a[i]==0)
        { c2++;}

   }
   for(int i=0;i<n;i++)
        cout<<a[i]<<endl;
   cout<<c1<<" "<<c2<<endl;
   if(c1==c2)
      cout<<"0";
   if(c1>c2)
   {
      cout<<n-(c2*2);
   }
   if(c2>c1)
      cout<<n-(c1*2);
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,count1=0;
	cin>>n;
int ar[n];
for(int i=0;i<n;i++)
{
	cin>>ar[i];
}
for(int i=0;i<n;i++)
{
	if(ar[i]==0)
	{
		count1++;
	}
	else
	{
		count1--;
	}
	cout<<abs(count1);
}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,count1=0;
	cin>>n;
int ar[n];
for(int i=0;i<n;i++)
{
	cin>>ar[i];
}
for(int i=0;i<n;i++)
{
	if(ar[i]==0)
	{
		count1++;
	}
	else
	{
		count1--;
	}

}
	cout<<abs(count1);
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,count1=0;
	cin>>n;
int ar[n];
for(int i=0;i<n;i++)
{
	cin>>a[i];
}
for(int i=0;i<n;i++)
{
	if(ar[i]==0)
	{
		count1++;
	}
	else
	{
		count1--;
	}
	cout<<abs(count1);
}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,count1=0;
	cin>>n;
int ar[n];
for(int i=0;i<n;i++)
{
	if(ar[i]==0)
	{
		count1++;
	}
	else
	{
		count1--;
	}
	cout<<abs(count1);
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,count1=0;
	cin>>n;
int ar[n];
for(int i=0;i<n;i++)
{
	if(a[i]==0)
	{
		count1++;
	}
	else
	{
		count1--;
	}
	cout<<abs(count1);
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,count1=0,count0=0;
	cin>>n;
int ar[n];
for(int i=0;i<n;i++)
{
	cin>>ar[i];
}
for(int i=0;i<n;i++)
{
	if(ar[i]==0)
	{
		count0++;
	}
	else if(ar[i]==1)
	{
		count1++;
	}
}
cout<<abs(count1-count0);

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,count1=0;
	cin>>n;
string s;
cin>>s;
for(int i=0;i<n;i++)
{
	if(s[i]==0)
	{
		count1++;
	}
	else
	{
		count1--;
	}

}
	cout<<abs(count1);
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,count1=0;
	cin>>n;
char ar[n];
for(int i=0;i<n;i++)
{
	cin>>ar[i];
}
for(int i=0;i<n;i++)
{
	if(ar[i]==0)
	{
		count1++;
	}
	else
	{
		count1--;
	}

}
	cout<<abs(count1);
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<math.h>
#include<cmath>
#include<set>
#include<stack>
#include<string>
#include<cstdlib>
#define ll long long
#define eps 1e-5
using namespace std;
const int inf=0x3fffffff;
const int maxn=110000;
int n,x;
int c[maxn];
int main()
{
	cin>>n>>x;
	for(int i=0;i<n;++i)
		cin>>c[i];
	sort(c,c+n);
	ll sum=0;
	for(int i=0;i<n;++i)
	{
		sum+=x*c[i];
		if(x>1)
			x--;
	}
	printf("%lld\n", sum);
	return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<math.h>
#include<cmath>
#include<set>
#include<stack>
#include<string>
#include<cstdlib>
#define ll long long
#define eps 1e-5
using namespace std;
const int inf=0x3fffffff;
const int maxn=110000;
llt n,x;
ll c[maxn];
int main()
{
	cin>>n>>x;
	for(int i=0;i<n;++i)
		cin>>c[i];
	sort(c,c+n);
	ll sum=0;
	for(int i=0;i<n;++i)
	{
		sum+=x*c[i];
		if(x>1)
			x--;
	}
	printf("%lld\n", sum);
	return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<math.h>
#include<cmath>
#include<set>
#include<stack>
#include<string>
#include<cstdlib>
#define ll long long
#define eps 1e-5
using namespace std;
const int inf=0x3fffffff;
const int maxn=110000;
int n,x;
int c[maxn];
int main()
{
	cin>>n>>x;
	for(int i=0;i<n;++i)
		cin>>c[i];
	sort(c,c+n);
	ll sum=0;
	for(int i=0;i<n;++i)
	{
		sum+=x*c[i];
		if(x>=1)
			x--;
	}
	printf("%lld\n", sum);
	return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<math.h>
#include<cmath>
#include<set>
#include<stack>
#include<string>
#include<cstdlib>
#define ll long long
#define eps 1e-5
using namespace std;
const int inf=0x3fffffff;
const int maxn=110000;
ll n,x;
ll c[maxn];
int main()
{
	cin>>n>>x;
	for(int i=0;i<n;++i)
		cin>>c[i];
	sort(c,c+n);
	ll sum=0;
	for(int i=0;i<n;++i)
	{
		sum+=x*c[i];
		if(x>1)
			x--;
	}
	printf("%lld\n", sum);
	return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<math.h>
#include<cmath>
#include<set>
#include<stack>
#include<string>
#include<cstdlib>
#define ll long long
#define eps 1e-5
using namespace std;
const int inf=0x3fffffff;
const int maxn=11000;
int n,x;
int c[maxn];
int main()
{
	cin>>n>>x;
	for(int i=0;i<n;++i)
		cin>>c[i];
	sort(c,c+n);
	ll sum=0;
	for(int i=0;i<n;++i)
	{
		sum+=x*c[i];
		if(x!=1)
			x--;
	}
	printf("%lld\n", sum);
	return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<math.h>
#include<cmath>
#include<set>
#include<stack>
#include<string>
#include<cstdlib>
#define ll long long
#define eps 1e-5
using namespace std;
const int inf=0x3fffffff;
const int maxn=11000;
int n,x;
int c[maxn];
int main()
{
	cin>>n>>x;
	for(int i=0;i<n;++i)
		cin>>c[i];
	sort(c,c+n);
	ll sum=0;
	for(int i=0;i<n;++i)
	{
		sum+=x*c[i];
		if(x>1)
			x--;
	}
	printf("%lld\n", sum);
	return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int inf=0x3fffffff;
int n,x;
int c[11000];
int main()
{
	while(scanf("%d%d",&n,&x)!=EOF)
	{
		for(int i=0;i<n;++i)
			cin>>c[i];
		sort(c,c+n);
		long long sum=0;
		for(int i=0;i<n;++i)
		{
			sum+=x*c[i];
			if(x>1)
			  x--;
		}
		printf("%lld\n",sum);
	}
	return 0;
}


#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main()
{
    int n,x,i,j,k;
    int t[10003];
    while(scanf("%d %d",&n,&x)==2){
        for(i=0;i<n;i++)scanf("%d",&t[i]);
        sort(t,t+n);

        int sum=0;
        for(i=0;i<n;i++){
                //cout<<t[i]<<endl;
            sum+=(t[i]*x);
            x--;
        }
        cout<<sum<<endl;
    }
    return 0;
}


#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
#include<stdio.h>
using namespace std;
 int t[100005];
int main()
{
    int n,x,i,j,k;

    while(scanf("%d %d",&n,&x)==2){
        for(i=0;i<n;i++)scanf("%d",&t[i]);
        sort(t,t+n);

        unsigned long long  sum=0;
        for(i=0;i<n;i++){
                //cout<<t[i]<<endl;
            sum+=(t[i]*x);
            if(x>1)x--;
        }
        cout<<sum<<endl;
    }
    return 0;
}


#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
#include<stdio.h>
using namespace std;
 long long int t[100005];
int main()
{
    int n,x,i,j,k;

    while(scanf("%d %d",&n,&x)==2){
        for(i=0;i<n;i++)scanf("%i64d",&t[i]);
        sort(t,t+n);

        unsigned long long  sum=0;
        for(i=0;i<n;i++){
                //cout<<t[i]<<endl;
            sum+=(t[i]*x);
            if(x>1)x--;
        }
        cout<<sum<<endl;
    }
    return 0;
}


#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
#include<stdio.h>
using namespace std;
 int t[100005];
int main()
{
    int n,x,i,j,k;

    while(scanf("%d %d",&n,&x)==2){
        for(i=0;i<n;i++)scanf("%d",&t[i]);
        sort(t,t+n);

        long long int sum=0;
        for(i=0;i<n;i++){
                //cout<<t[i]<<endl;
            sum+=(t[i]*x);
            if(x>1)x--;
        }
        cout<<sum<<endl;
    }
    return 0;
}


#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
#include<stdio.h>
using namespace std;
 int t[100005];
int main()
{
    int n,x,i,j,k;

    while(scanf("%d %d",&n,&x)==2){
        for(i=0;i<n;i++)scanf("%d",&t[i]);
        sort(t,t+n);

        long long  sum=0;
        for(i=0;i<n;i++){
                //cout<<t[i]<<endl;
            sum+=(t[i]*x);
            if(x>1)x--;
        }
        cout<<sum<<endl;
    }
    return 0;
}


#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main()
{
    int n,x,i,j,k;
    int t[10003];
    while(scanf("%d %d",&n,&x)==2){
        for(i=0;i<n;i++)scanf("%d",&t[i]);
        sort(t,t+n);

        long long int sum=0;
        for(i=0;i<n;i++){
                //cout<<t[i]<<endl;
            sum+=(t[i]*x);
            if(x>1)x--;
        }
        cout<<sum<<endl;
    }
    return 0;
}


#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
#include<stdio.h>
using namespace std;
 int t[10005];
int main()
{
    int n,x,i,j,k;

    while(scanf("%d %d",&n,&x)==2){
        for(i=0;i<n;i++)scanf("%d",&t[i]);
        sort(t,t+n);

        long long int sum=0;
        for(i=0;i<n;i++){
                //cout<<t[i]<<endl;
            sum+=(t[i]*x);
            if(x>1)x--;
        }
        cout<<sum<<endl;
    }
    return 0;
}


#include <cstdio>
#include <vector>

using namespace std;

template<typename t> class Node{
public :
    t key;
    Node *left, *right;
    bool color;
    Node(t key, bool color) : key(key),left(NULL), right(NULL), color(color){}
};

template<typename t> class llrbbst{
public:
    llrbbst():root(NULL){}
    void put(t key)
    {
        root = put(root, key);
    }

    t *inorder()
    {
        t *temp = new t[100001];
        int n = 0;
        inorder(root, temp, n);
        return temp;
    }
private:
    static const bool RED = true;
    static const bool BLACK = false;
    Node<t> *root;

    void inorder(Node<t> *node, t *v, int &n)
    {
        if(node == NULL)return;
        inorder(node->left, v, n);
        v[n] = node->key;
        ++n;
        inorder(node->right, v, n);
    }

    Node<t> *put(Node<t> *node, t key)
    {
        if(node == NULL)return new Node<t>(key, RED);
        if(key > node->key){
            node->right = put(node->right, key);
        }
        else /*if(key < node->key)*/{
            node->left = put(node->left, key);
        }/*
        else {
            node->key = key;
        }
        */
        if(isRed(node->right) && !isRed(node->left)){
            node = lRotate(node);
        }
        if(isRed(node->left) && isRed(node->left->left)){
            node = rRotate(node);
        }
        if(isRed(node->right) && isRed(node->left)){
            flipColor(node);
        }
        return node;
    }

    Node<t> *lRotate(Node<t> *node)
    {
        Node<t> *r = node->right;
        Node<t> *temp = r->left;
        r->left = node;
        node->right = temp;
        r->color = node->color;
        node->color = RED;
        return r;
    }

    Node<t> *rRotate(Node<t> *node)
    {
        Node<t> *l = node->left;
        Node<t> *temp = l->right;
        l->right = node;
        node->left = temp;
        l->color = node->color;
        node->color = RED;
        return l;
    }
    void flipColor(Node<t> *node)
    {
        if (node->color == RED || node->left->color != RED || node->right->color != RED) {
            return;
        }
        node->left->color = BLACK;
        node->right->color = BLACK;
        node->color = RED;
    }
    bool isRed(Node<t> *node)
    {
        if(node == NULL)return false;
        return node->color == RED;
    }
};

int main()
{
    int n,x;
    scanf("%d%d", &n, &x);
    llrbbst<int> *temp = new llrbbst<int>();
    for(int i=0;i<n;i++){
        int a;
        scanf("%d", &a);
        temp->put(a);
    }
    int *v = temp->inorder();
    long long ans = 0;
    for(int i=0;i<n;++i){
        ans += v[i] * (long long) x;
        if(x!=1)--x;
    }
    printf("%I64d", ans);

    return 0;
}


#include <cstdio>
#include <vector>

using namespace std;

template<typename t> class Node{
public :
    t key;
    Node *left, *right;
    bool color;
    Node(t key, bool color) : key(key),left(NULL), right(NULL), color(color){}
};

template<typename t> class llrbbst{
public:
    llrbbst():root(NULL){}
    void put(t key)
    {
        root = put(root, key);
    }

    vector<t> *inorder()
    {
        vector<t> *temp = new vector<t>();
        inorder(root, temp);
        return temp;
    }
private:
    static const bool RED = true;
    static const bool BLACK = false;
    Node<t> *root;

    void inorder(Node<t> *node, vector<t> *v)
    {
        if(node == NULL)return;
        inorder(node->left, v);
        v->push_back(node->key);
        inorder(node->right, v);
    }

    Node<t> *put(Node<t> *node, t key)
    {
        if(node == NULL)return new Node<t>(key, RED);
        if(key > node->key){
            node->right = put(node->right, key);
        }
        else /*if(key < node->key)*/{
            node->left = put(node->left, key);
        }/*
        else {
            node->key = key;
        }
        */
        if(isRed(node->right) && !isRed(node->left)){
            node = lRotate(node);
        }
        if(isRed(node->left) && isRed(node->left->left)){
            node = rRotate(node);
        }
        if(isRed(node->right) && isRed(node->left)){
            flipColor(node);
        }
        return node;
    }

    Node<t> *lRotate(Node<t> *node)
    {
        Node<t> *r = node->right;
        Node<t> *temp = r->left;
        r->left = node;
        node->right = temp;
        r->color = node->color;
        node->color = RED;
        return r;
    }

    Node<t> *rRotate(Node<t> *node)
    {
        Node<t> *l = node->left;
        Node<t> *temp = l->right;
        l->right = node;
        node->left = temp;
        l->color = node->color;
        node->color = RED;
        return l;
    }
    void flipColor(Node<t> *node)
    {
        if (node->color == RED || node->left->color != RED || node->right->color != RED) {
            return;
        }
        node->left->color = BLACK;
        node->right->color = BLACK;
        node->color = RED;
    }
    bool isRed(Node<t> *node)
    {
        if(node == NULL)return false;
        return node->color == RED;
    }
};

int main()
{
    int n,x;
    scanf("%d%d", &n, &x);
    llrbbst<int> *temp = new llrbbst<int>();
    for(int i=0;i<n;i++){
        int a;
        scanf("%d", &a);
        temp->put(a);
    }
    vector<int> *v = temp->inorder();

    vector<int>::iterator i;
    long long ans = 0;
    for(i=v->begin();i!=v->end();++i){
        ans += *i * (long long) x;
        if(x!=1)--x;
    }
    printf("%I64d", ans);

    return 0;
}


#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

template<typename t> class Node{
public :
    t key;
    Node *left, *right;
    bool color;
    Node(t key, bool color) : key(key),left(NULL), right(NULL), color(color){}
};

template<typename t> class llrbbst{
public:
    llrbbst():root(NULL){}
    void put(t key)
    {
        root = put(root, key);
    }

    t *inorder()
    {
        t *temp = new t[100001];
        int n = 0;
        inorder(root, temp, n);
        return temp;
    }
private:
    static const bool RED = true;
    static const bool BLACK = false;
    Node<t> *root;

    void inorder(Node<t> *node, t *v, int &n)
    {
        if(node == NULL)return;
        inorder(node->left, v, n);
        v[n] = node->key;
        ++n;
        inorder(node->right, v, n);
    }

    Node<t> *put(Node<t> *node, t key)
    {
        if(node == NULL)return new Node<t>(key, RED);
        if(key > node->key){
            node->right = put(node->right, key);
        }
        else /*if(key < node->key)*/{
            node->left = put(node->left, key);
        }/*
        else {
            node->key = key;
        }
        */
        if(isRed(node->right) && !isRed(node->left)){
            node = lRotate(node);
        }
        if(isRed(node->left) && isRed(node->left->left)){
            node = rRotate(node);
        }
        if(isRed(node->right) && isRed(node->left)){
            flipColor(node);
        }
        return node;
    }

    Node<t> *lRotate(Node<t> *node)
    {
        Node<t> *r = node->right;
        Node<t> *temp = r->left;
        r->left = node;
        node->right = temp;
        r->color = node->color;
        node->color = RED;
        return r;
    }

    Node<t> *rRotate(Node<t> *node)
    {
        Node<t> *l = node->left;
        Node<t> *temp = l->right;
        l->right = node;
        node->left = temp;
        l->color = node->color;
        node->color = RED;
        return l;
    }
    void flipColor(Node<t> *node)
    {
        if (node->color == RED || node->left->color != RED || node->right->color != RED) {
            return;
        }
        node->left->color = BLACK;
        node->right->color = BLACK;
        node->color = RED;
    }
    bool isRed(Node<t> *node)
    {
        if(node == NULL)return false;
        return node->color == RED;
    }
};

int main()
{
    int n,x;
    scanf("%d%d", &n, &x);
    llrbbst<int> *temp = new llrbbst<int>();
    int *v = new int[n];
    for(int i=0;i<n;i++){
        int a;
        scanf("%d", &a);
        if(n==100000)v[i]=a;
        else temp->put(a);
    }
    if(n==100000)sort(v,v+n);
    else v = temp->inorder();
    long long ans = 0;
    for(int i=0;i<n;++i){
        ans += v[i] * (long long) x;
        if(x!=1)--x;
    }
    printf("%I64d", ans);

    return 0;
}


#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

template<typename t> class Node{
public :
    t key;
    Node *left, *right;
    bool color;
    Node(t key, bool color) : key(key),left(NULL), right(NULL), color(color){}
};

template<typename t> class llrbbst{
public:
    llrbbst():root(NULL){}
    void put(t key)
    {
        root = put(root, key);
    }

    t *inorder()
    {
        t *temp = new t[100001];
        int n = 0;
        inorder(root, temp, n);
        return temp;
    }
private:
    static const bool RED = true;
    static const bool BLACK = false;
    Node<t> *root;

    void inorder(Node<t> *node, t *v, int &n)
    {
        if(node == NULL)return;
        inorder(node->left, v, n);
        v[n] = node->key;
        ++n;
        inorder(node->right, v, n);
    }

    Node<t> *put(Node<t> *node, t key)
    {
        if(node == NULL)return new Node<t>(key, RED);
        if(key > node->key){
            node->right = put(node->right, key);
        }
        else /*if(key < node->key)*/{
            node->left = put(node->left, key);
        }/*
        else {
            node->key = key;
        }
        */
        if(isRed(node->right) && !isRed(node->left)){
            node = lRotate(node);
        }
        if(isRed(node->left) && isRed(node->left->left)){
            node = rRotate(node);
        }
        if(isRed(node->right) && isRed(node->left)){
            flipColor(node);
        }
        return node;
    }

    Node<t> *lRotate(Node<t> *node)
    {
        Node<t> *r = node->right;
        Node<t> *temp = r->left;
        r->left = node;
        node->right = temp;
        r->color = node->color;
        node->color = RED;
        return r;
    }

    Node<t> *rRotate(Node<t> *node)
    {
        Node<t> *l = node->left;
        Node<t> *temp = l->right;
        l->right = node;
        node->left = temp;
        l->color = node->color;
        node->color = RED;
        return l;
    }
    void flipColor(Node<t> *node)
    {
        if (node->color == RED || node->left->color != RED || node->right->color != RED) {
            return;
        }
        node->left->color = BLACK;
        node->right->color = BLACK;
        node->color = RED;
    }
    bool isRed(Node<t> *node)
    {
        if(node == NULL)return false;
        return node->color == RED;
    }
};

int main()
{
    int n,x;
    scanf("%d%d", &n, &x);
    llrbbst<int> *temp = new llrbbst<int>();
    int *v = new int[n];
    for(int i=0;i<n;i++){
        int a;
        scanf("%d", &a);
        if(n<100000)v[i]=a;
        else temp->put(a);
    }
    if(n<100000)sort(v,v+n);
    else v = temp->inorder();
    long long ans = 0;
    for(int i=0;i<n;++i){
        ans += v[i] * (long long) x;
        if(x!=1)--x;
    }
    printf("%I64d", ans);

    return 0;
}


#include <cstdio>
#include <vector>
#include <set>

using namespace std;

template<typename t> class Node{
public :
    t key;
    Node *left, *right;
    bool color;
    Node(t key, bool color) : key(key),left(NULL), right(NULL), color(color){}
};

template<typename t> class llrbbst{
public:
    llrbbst():root(NULL){}
    void put(t key)
    {
        root = put(root, key);
    }

    t *inorder(int &x, long long &ans)
    {
        inorder(root, x, ans);
        return NULL;
    }
private:
    static const bool RED = true;
    static const bool BLACK = false;
    Node<t> *root;

    void inorder(Node<t> *node, int &x, long long &ans)
    {
        if(node == NULL)return;
        inorder(node->left, x,ans);
        ans += node->key * (long long) x;
        if(x!=1)--x;
        inorder(node->right, x, ans);
    }

    Node<t> *put(Node<t> *node, t key)
    {
        if(node == NULL)return new Node<t>(key, RED);
        if(key > node->key){
            node->right = put(node->right, key);
        }
        else /*if(key < node->key)*/{
            node->left = put(node->left, key);
        }/*
        else {
            node->key = key;
        }
        */
        if(isRed(node->right) && !isRed(node->left)){
            node = lRotate(node);
        }
        if(isRed(node->left) && isRed(node->left->left)){
            node = rRotate(node);
        }
        if(isRed(node->right) && isRed(node->left)){
            flipColor(node);
        }
        return node;
    }

    Node<t> *lRotate(Node<t> *node)
    {
        Node<t> *r = node->right;
        Node<t> *temp = r->left;
        r->left = node;
        node->right = temp;
        r->color = node->color;
        node->color = RED;
        return r;
    }

    Node<t> *rRotate(Node<t> *node)
    {
        Node<t> *l = node->left;
        Node<t> *temp = l->right;
        l->right = node;
        node->left = temp;
        l->color = node->color;
        node->color = RED;
        return l;
    }
    void flipColor(Node<t> *node)
    {
        if (node->color == RED || node->left->color != RED || node->right->color != RED) {
            return;
        }
        node->left->color = BLACK;
        node->right->color = BLACK;
        node->color = RED;
    }
    bool isRed(Node<t> *node)
    {
        if(node == NULL)return false;
        return node->color == RED;
    }
};

int main()
{
    int n,x;
    scanf("%d%d", &n, &x);
    //llrbbst<int> *temp = new llrbbst<int>();
    //int *v = new int[n];
    multiset<int> *_s = new multiset<int>();
    multiset<int> &s = *_s;
    for(int i=0;i<n;i++){
        int a;
        scanf("%d", &a);
        //if(n<80000)v[i]=a;
        //temp->put(a);
        s.insert(a);
    }
   // if(n<80000)sort(v,v+n);
    long long ans = 0;
    //v = temp->inorder(x, ans);
    for(multiset<int>::iterator i=s.begin();i!=s.end();++i){
        ans += *i * (long long) x;
        if(x!=1)--x;
    }
    printf("%I64d", ans);

    return 0;
}


#include <cstdio>
#include <vector>

using namespace std;

template<typename t> class Node{
public :
    t key;
    Node *left, *right;
    bool color;
    Node(t key, bool color) : key(key),left(NULL), right(NULL), color(color){}
};

template<typename t> class llrbbst{
public:
    llrbbst():root(NULL){}
    void put(t key)
    {
        root = put(root, key);
    }

    vector<t> *inorder()
    {
        vector<t> *temp = new vector<t>(100000);
        inorder(root, temp);
        return temp;
    }
private:
    static const bool RED = true;
    static const bool BLACK = false;
    Node<t> *root;

    void inorder(Node<t> *node, vector<t> *v)
    {
        if(node == NULL)return;
        inorder(node->left, v);
        v->push_back(node->key);
        inorder(node->right, v);
    }

    Node<t> *put(Node<t> *node, t key)
    {
        if(node == NULL)return new Node<t>(key, RED);
        if(key > node->key){
            node->right = put(node->right, key);
        }
        else /*if(key < node->key)*/{
            node->left = put(node->left, key);
        }/*
        else {
            node->key = key;
        }
        */
        if(isRed(node->right) && !isRed(node->left)){
            node = lRotate(node);
        }
        if(isRed(node->left) && isRed(node->left->left)){
            node = rRotate(node);
        }
        if(isRed(node->right) && isRed(node->left)){
            flipColor(node);
        }
        return node;
    }

    Node<t> *lRotate(Node<t> *node)
    {
        Node<t> *r = node->right;
        Node<t> *temp = r->left;
        r->left = node;
        node->right = temp;
        r->color = node->color;
        node->color = RED;
        return r;
    }

    Node<t> *rRotate(Node<t> *node)
    {
        Node<t> *l = node->left;
        Node<t> *temp = l->right;
        l->right = node;
        node->left = temp;
        l->color = node->color;
        node->color = RED;
        return l;
    }
    void flipColor(Node<t> *node)
    {
        if (node->color == RED || node->left->color != RED || node->right->color != RED) {
            return;
        }
        node->left->color = BLACK;
        node->right->color = BLACK;
        node->color = RED;
    }
    bool isRed(Node<t> *node)
    {
        if(node == NULL)return false;
        return node->color == RED;
    }
};

int main()
{
    int n,x;
    scanf("%d%d", &n, &x);
    llrbbst<int> *temp = new llrbbst<int>();
    for(int i=0;i<n;i++){
        int a;
        scanf("%d", &a);
        temp->put(a);
    }
    vector<int> *v = temp->inorder();

    vector<int>::iterator i;
    long long ans = 0;
    for(i=v->begin();i!=v->end();++i){
        ans += *i * (long long) x;
        if(x!=1)--x;
    }
    printf("%I64d", ans);

    return 0;
}


#include <iostream>
#include <vector>

using namespace std;

template<typename t> class Node{
public :
    t key;
    Node *left, *right;
    bool color;
    Node(t key, bool color) : key(key),left(NULL), right(NULL), color(color){}
};

template<typename t> class llrbbst{
public:
    llrbbst():root(NULL){}
    void put(t key)
    {
        root = put(root, key);
    }

    vector<t> *inorder()
    {
        vector<t> *temp = new vector<t>();
        inorder(root, temp);
        return temp;
    }
private:
    static const bool RED = true;
    static const bool BLACK = false;
    Node<t> *root;

    void inorder(Node<t> *node, vector<t> *v)
    {
        if(node == NULL)return;
        inorder(node->left, v);
        v->push_back(node->key);
        inorder(node->right, v);
    }

    Node<t> *put(Node<t> *node, t key)
    {
        if(node == NULL)return new Node<t>(key, RED);
        if(key > node->key){
            node->right = put(node->right, key);
        }
        else /*if(key < node->key)*/{
            node->left = put(node->left, key);
        }/*
        else {
            node->key = key;
        }
        */
        if(isRed(node->right) && !isRed(node->left)){
            node = lRotate(node);
        }
        if(isRed(node->left) && isRed(node->left->left)){
            node = rRotate(node);
        }
        if(isRed(node->right) && isRed(node->left)){
            flipColor(node);
        }
        return node;
    }

    Node<t> *lRotate(Node<t> *node)
    {
        Node<t> *r = node->right;
        Node<t> *temp = r->left;
        r->left = node;
        node->right = temp;
        r->color = node->color;
        node->color = RED;
        return r;
    }

    Node<t> *rRotate(Node<t> *node)
    {
        Node<t> *l = node->left;
        Node<t> *temp = l->right;
        l->right = node;
        node->left = temp;
        l->color = node->color;
        node->color = RED;
        return l;
    }
    void flipColor(Node<t> *node)
    {
        if (node->color == RED || node->left->color != RED || node->right->color != RED) {
            return;
        }
        node->left->color = BLACK;
        node->right->color = BLACK;
        node->color = RED;
    }
    bool isRed(Node<t> *node)
    {
        if(node == NULL)return false;
        return node->color == RED;
    }
};

int main()
{
    int n,x;
    cin >> n >> x;
    llrbbst<int> *temp = new llrbbst<int>();
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        temp->put(a);
    }
    vector<int> *v = temp->inorder();

    vector<int>::iterator i;
    long long ans = 0;
    for(i=v->begin();i!=v->end();++i){
        ans += *i * (long long) x;
        if(x!=1)--x;
    }
    cout << ans;

    return 0;
}


#include <cstdio>
#include <vector>

using namespace std;

template<typename t> class Node{
public :
    t key;
    Node *left, *right;
    bool color;
    Node(t key, bool color) : key(key),left(NULL), right(NULL), color(color){}
};

template<typename t> class llrbbst{
public:
    llrbbst():root(NULL){}
    void put(t key)
    {
        root = put(root, key);
    }

    vector<t> *inorder()
    {
        vector<t> *temp = new vector<t>(100000);
        int n = 0;
        inorder(root, temp, n);
        return temp;
    }
private:
    static const bool RED = true;
    static const bool BLACK = false;
    Node<t> *root;

    void inorder(Node<t> *node, vector<t> *v, int &n)
    {
        if(node == NULL)return;
        inorder(node->left, v, n);
        (*v)[n] = node->key;
        ++n;
        inorder(node->right, v, n);
    }

    Node<t> *put(Node<t> *node, t key)
    {
        if(node == NULL)return new Node<t>(key, RED);
        if(key > node->key){
            node->right = put(node->right, key);
        }
        else /*if(key < node->key)*/{
            node->left = put(node->left, key);
        }/*
        else {
            node->key = key;
        }
        */
        if(isRed(node->right) && !isRed(node->left)){
            node = lRotate(node);
        }
        if(isRed(node->left) && isRed(node->left->left)){
            node = rRotate(node);
        }
        if(isRed(node->right) && isRed(node->left)){
            flipColor(node);
        }
        return node;
    }

    Node<t> *lRotate(Node<t> *node)
    {
        Node<t> *r = node->right;
        Node<t> *temp = r->left;
        r->left = node;
        node->right = temp;
        r->color = node->color;
        node->color = RED;
        return r;
    }

    Node<t> *rRotate(Node<t> *node)
    {
        Node<t> *l = node->left;
        Node<t> *temp = l->right;
        l->right = node;
        node->left = temp;
        l->color = node->color;
        node->color = RED;
        return l;
    }
    void flipColor(Node<t> *node)
    {
        if (node->color == RED || node->left->color != RED || node->right->color != RED) {
            return;
        }
        node->left->color = BLACK;
        node->right->color = BLACK;
        node->color = RED;
    }
    bool isRed(Node<t> *node)
    {
        if(node == NULL)return false;
        return node->color == RED;
    }
};

int main()
{
    int n,x;
    scanf("%d%d", &n, &x);
    llrbbst<int> *temp = new llrbbst<int>();
    for(int i=0;i<n;i++){
        int a;
        scanf("%d", &a);
        temp->put(a);
    }
    vector<int> *v = temp->inorder();
    vector<int>::iterator i;
    long long ans = 0;
    for(i=v->begin();i-v->begin() < n;++i){
        ans += *i * (long long) x;
        if(x!=1)--x;
    }
    printf("%I64d", ans);

    return 0;
}


#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

template<typename t> class Node{
public :
    t key;
    Node *left, *right;
    bool color;
    Node(t key, bool color) : key(key),left(NULL), right(NULL), color(color){}
};

template<typename t> class llrbbst{
public:
    llrbbst():root(NULL){}
    void put(t key)
    {
        root = put(root, key);
    }

    t *inorder(int &x, long long &ans)
    {
        inorder(root, x, ans);
        return NULL;
    }
private:
    static const bool RED = true;
    static const bool BLACK = false;
    Node<t> *root;

    void inorder(Node<t> *node, int &x, long long &ans)
    {
        if(node == NULL)return;
        inorder(node->left, x,ans);
        ans += node->key * (long long) x;
        if(x!=1)--x;
        inorder(node->right, x, ans);
    }

    Node<t> *put(Node<t> *node, t key)
    {
        if(node == NULL)return new Node<t>(key, RED);
        if(key > node->key){
            node->right = put(node->right, key);
        }
        else /*if(key < node->key)*/{
            node->left = put(node->left, key);
        }/*
        else {
            node->key = key;
        }
        */
        if(isRed(node->right) && !isRed(node->left)){
            node = lRotate(node);
        }
        if(isRed(node->left) && isRed(node->left->left)){
            node = rRotate(node);
        }
        if(isRed(node->right) && isRed(node->left)){
            flipColor(node);
        }
        return node;
    }

    Node<t> *lRotate(Node<t> *node)
    {
        Node<t> *r = node->right;
        Node<t> *temp = r->left;
        r->left = node;
        node->right = temp;
        r->color = node->color;
        node->color = RED;
        return r;
    }

    Node<t> *rRotate(Node<t> *node)
    {
        Node<t> *l = node->left;
        Node<t> *temp = l->right;
        l->right = node;
        node->left = temp;
        l->color = node->color;
        node->color = RED;
        return l;
    }
    void flipColor(Node<t> *node)
    {
        if (node->color == RED || node->left->color != RED || node->right->color != RED) {
            return;
        }
        node->left->color = BLACK;
        node->right->color = BLACK;
        node->color = RED;
    }
    bool isRed(Node<t> *node)
    {
        if(node == NULL)return false;
        return node->color == RED;
    }
};

int main()
{
    int n,x;
    scanf("%d%d", &n, &x);
    llrbbst<int> *temp = new llrbbst<int>();
    int *v = new int[n];
    for(int i=0;i<n;i++){
        int a;
        scanf("%d", &a);
        //if(n<80000)v[i]=a;
        temp->put(a);
    }
   // if(n<80000)sort(v,v+n);
    long long ans = 0;
    v = temp->inorder(x, ans);
 /*   for(int i=0;i<n;++i){
        ans += v[i] * (long long) x;
        if(x!=1)--x;
    }
   */ printf("%I64d", ans);

    return 0;
}


#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

template<typename t> class Node{
public :
    t key;
    Node *left, *right;
    bool color;
    Node(t key, bool color) : key(key),left(NULL), right(NULL), color(color){}
};

template<typename t> class llrbbst{
public:
    llrbbst():root(NULL){}
    void put(t key)
    {
        root = put(root, key);
    }

    t *inorder(int &x, long long &ans)
    {
        inorder(root, x, ans);
        return NULL;
    }
private:
    static const bool RED = true;
    static const bool BLACK = false;
    Node<t> *root;

    void inorder(Node<t> *node, int &x, long long &ans)
    {
        if(node == NULL)return;
        inorder(node->left, x,ans);
        ans += node->key * (long long) x;
        --x;
        inorder(node->right, x, ans);
    }

    Node<t> *put(Node<t> *node, t key)
    {
        if(node == NULL)return new Node<t>(key, RED);
        if(key > node->key){
            node->right = put(node->right, key);
        }
        else /*if(key < node->key)*/{
            node->left = put(node->left, key);
        }/*
        else {
            node->key = key;
        }
        */
        if(isRed(node->right) && !isRed(node->left)){
            node = lRotate(node);
        }
        if(isRed(node->left) && isRed(node->left->left)){
            node = rRotate(node);
        }
        if(isRed(node->right) && isRed(node->left)){
            flipColor(node);
        }
        return node;
    }

    Node<t> *lRotate(Node<t> *node)
    {
        Node<t> *r = node->right;
        Node<t> *temp = r->left;
        r->left = node;
        node->right = temp;
        r->color = node->color;
        node->color = RED;
        return r;
    }

    Node<t> *rRotate(Node<t> *node)
    {
        Node<t> *l = node->left;
        Node<t> *temp = l->right;
        l->right = node;
        node->left = temp;
        l->color = node->color;
        node->color = RED;
        return l;
    }
    void flipColor(Node<t> *node)
    {
        if (node->color == RED || node->left->color != RED || node->right->color != RED) {
            return;
        }
        node->left->color = BLACK;
        node->right->color = BLACK;
        node->color = RED;
    }
    bool isRed(Node<t> *node)
    {
        if(node == NULL)return false;
        return node->color == RED;
    }
};

int main()
{
    int n,x;
    scanf("%d%d", &n, &x);
    llrbbst<int> *temp = new llrbbst<int>();
    int *v = new int[n];
    for(int i=0;i<n;i++){
        int a;
        scanf("%d", &a);
        //if(n<80000)v[i]=a;
        temp->put(a);
    }
   // if(n<80000)sort(v,v+n);
    long long ans = 0;
    v = temp->inorder(x, ans);
 /*   for(int i=0;i<n;++i){
        ans += v[i] * (long long) x;
        if(x!=1)--x;
    }
   */ printf("%I64d", ans);

    return 0;
}


#include <iostream>
#include <vector>

using namespace std;

template<typename t> class Node{
public :
    t key;
    Node *left, *right;
    bool color;
    Node(t key, bool color) : key(key),left(NULL), right(NULL), color(color){}
};

template<typename t> class llrbbst{
public:
    llrbbst():root(NULL){}
    void put(t key)
    {
        root = put(root, key);
    }

    vector<t> *inorder()
    {
        vector<t> *temp = new vector<t>();
        inorder(root, temp);
        return temp;
    }
private:
    static const bool RED = true;
    static const bool BLACK = false;
    Node<t> *root;

    void inorder(Node<t> *node, vector<t> *v)
    {
        if(node == NULL)return;
        inorder(node->left, v);
        v->push_back(node->key);
        inorder(node->right, v);
    }

    Node<t> *put(Node<t> *node, t key)
    {
        if(node == NULL)return new Node<t>(key, RED);
        if(key > node->key){
            node->right = put(node->right, key);
        }
        else /*if(key < node->key)*/{
            node->left = put(node->left, key);
        }/*
        else {
            node->key = key;
        }
        */
        if(isRed(node->right) && !isRed(node->left)){
            node = lRotate(node);
        }
        if(isRed(node->left) && isRed(node->left->left)){
            node = rRotate(node);
        }
        if(isRed(node->right) && isRed(node->left)){
            flipColor(node);
        }
        return node;
    }

    Node<t> *lRotate(Node<t> *node)
    {
        Node<t> *r = node->right;
        Node<t> *temp = r->left;
        r->left = node;
        node->right = temp;
        r->color = node->color;
        node->color = RED;
        return r;
    }

    Node<t> *rRotate(Node<t> *node)
    {
        Node<t> *l = node->left;
        Node<t> *temp = l->right;
        l->right = node;
        node->left = temp;
        l->color = node->color;
        node->color = RED;
        return l;
    }
    void flipColor(Node<t> *node)
    {
        if (node->color == RED || node->left->color != RED || node->right->color != RED) {
            return;
        }
        node->left->color = BLACK;
        node->right->color = BLACK;
        node->color = RED;
    }
    bool isRed(Node<t> *node)
    {
        if(node == NULL)return false;
        return node->color == RED;
    }
};

int main()
{
    ios_base::sync_with_stdio(false);
    int n,x;
    cin >> n >> x;
    llrbbst<int> *temp = new llrbbst<int>();
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        temp->put(a);
    }
    vector<int> *v = temp->inorder();

    vector<int>::iterator i;
    long long ans = 0;
    for(i=v->begin();i!=v->end();++i){
        ans += *i * (long long) x;
        if(x!=1)--x;
    }
    cout << ans;

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

int n, x, c[int(1e6)+10];
int ans;

int main () {
    /*#ifdef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
  		freopen("output.txt", "w", stdout);
	#endif*/

	scanf("%d%d", &n, &x);

	for(int i = 1; i <= n; i++) {
		scanf("%d", &c[i]);
	}
	sort(c+1, c+1+n);
	for(int i = 1; i <= n; i++) {
		ans+= c[i] * x;
		if(x != 1) x--;
	}
	printf("%d", ans);

   	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

int n, x, c[int(1e7)];
long long ans;

int main () {
    /*#ifdef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
  		freopen("output.txt", "w", stdout);
	#endif*/

	scanf("%d%d", &n, &x);

	for(int i = 1; i <= n; i++) {
		scanf("%d", &c[i]);
	}
	sort(c+1, c+1+n);
	for(int i = 1; i <= n; i++) {
		ans+= c[i] * x;
		if(x != 1) x--;
	}
	printf("%d", ans);

   	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

long long int n, x, c[int(1e6) + 10];
unsigned long long ans;

int main () {
    /*#ifdef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
  		freopen("output.txt", "w", stdout);
	#endif*/

	scanf("%I64d%I64d", &n, &x);

	for(int i = 1; i <= n; i++) {
		scanf("%I64d", &c[i]);
	}
	sort(c+1, c+1+n);
	for(int i = 1; i <= n; i++) {
		ans+= c[i] * x;
		if(x != 1) x--;
	}
	printf("%I64d", ans);

   	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

int n, x, c[int(1e6)];
long long ans;

int main () {
    /*#ifdef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
  		freopen("output.txt", "w", stdout);
	#endif*/

	scanf("%d%d", &n, &x);

	for(int i = 1; i <= n; i++) {
		scanf("%d", &c[i]);
	}
	sort(c+1, c+1+n);
	for(int i = 1; i <= n; i++) {
		ans+= c[i] * x;
		if(x) x--;
	}
	printf("%d", ans);

   	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

int n, x, c[int(1e6)];
long long ans;

int main () {
    #ifdef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
  		freopen("output.txt", "w", stdout);
	#endif

	scanf("%d%d", &n, &x);

	for(int i = 1; i <= n; i++) {
		scanf("%d", &c[i]);
	}
	sort(c+1, c+1+n);
	for(int i = 1; i <= n; i++) {
		ans+= c[i] * (x--);
		if(!x) x++;
	}
	cout << ans;

   	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

int n, x, c[int(1e6)];
unsigned long long ans;

int main () {
    /*#ifdef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
  		freopen("output.txt", "w", stdout);
	#endif*/

	scanf("%d%d", &n, &x);

	for(int i = 1; i <= n; i++) {
		scanf("%d", &c[i]);
	}
	sort(c+1, c+1+n);
	for(int i = 1; i <= n; i++) {
		ans+= c[i] * x;
		if(x != 1) x--;
	}
	printf("%d", ans);

   	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

int n, x, c[int(1e6)];
long long ans;

int main () {
    /*#ifdef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
  		freopen("output.txt", "w", stdout);
	#endif*/

	scanf("%d%d", &n, &x);

	for(int i = 1; i <= n; i++) {
		scanf("%d", &c[i]);
	}
	sort(c+1, c+1+n);
	for(int i = 1; i <= n; i++) {
		ans+= c[i] * (x--);
		if(!x) x++;
	}
	cout << ans;

   	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include <queue>
#include<string>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll;
typedef vector <int> vi;
#define fr(i,n) for(i=0;i<n;i++)
#define scn(n) scanf("%d",&n)
#define prt(n) printf("%d",n)
#define prtn(n) printf("%d\n",n)

int main(void)
{
int i,x,n;

scn(n);
//int a[n];
scn(x);
vi a(n,0);
fr(i,n)
scn(a[i]);

unsigned long long sum=0;
sort(a.begin(),a.end());
for(i=0;i<a.size();i++)
{
    sum=sum+(a[i]*x);
    if(x!=1)
    x=x-1;
}
cout<<sum;

}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include <queue>
#include<string>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll;
typedef vector <int> vi;
#define fr(i,n) for(i=0;i<n;i++)
#define scn(n) scanf("%d",&n)
#define prt(n) printf("%d",n)
#define prtn(n) printf("%d\n",n)

int main(void)
{
int i,x,n;

scn(n);
scn(x);
long long a[n];
fr(i,n)
cin>>a[i];

unsigned long long sum=0;
sort(a,a+n);
for(i=0;i<n;i++)
{
    sum=sum+(a[i]*x);
    if(x>1)
    x=x-1;
}
cout<<sum;

}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include <queue>
#include<string>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll;
typedef vector <int> vi;
#define fr(i,n) for(i=0;i<n;i++)
#define scn(n) scanf("%d",&n)
#define prt(n) printf("%d",n)
#define prtn(n) printf("%d\n",n)

int main(void)
{
int i,x,n;

scn(n);
//int a[n];
scn(x);
vi a(n,0);
fr(i,n)
scn(a[i]);

long double sum=0;
sort(a.begin(),a.end());
for(i=0;i<a.size();i++)
{
    sum=sum+(a[i]*x);
    if(x!=1)
    x=x-1;
}
cout<<sum;

}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include <queue>
#include<string>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll;
typedef vector <int> vi;
#define fr(i,n) for(i=0;i<n;i++)
#define scn(n) scanf("%d",&n)
#define prt(n) printf("%d",n)
#define prtn(n) printf("%d\n",n)

int main(void)
{
int i,x,n;

scn(n);
//int a[n];
scn(x);
int a[1000000];
fr(i,n)
scn(a[i]);

unsigned long long sum=0;
sort(a,a+n);
for(i=0;i<n;i++)
{
    sum=sum+(a[i]*x);
    if(x>1)
    x=x-1;
}
cout<<sum;

}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include <queue>
#include<string>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll;
typedef vector <int> vi;
#define fr(i,n) for(i=0;i<n;i++)
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%I64d",&n);
#define prt(n) printf("%d",n)
#define prtll(n) printf("%I64d",n);
#define prtn(n) printf("%d\n",n)

int main(void)
{
int i,x,n;

scn(n);
scn(x);
long long a[n];
fr(i,n)
scanf("%I64d",&a[i]);

unsigned long long sum=0;
sort(a,a+n);
for(i=0;i<n;i++)
{
    sum=sum+(a[i]*x);
    if(x>1)
    x=x-1;
}
prtll(sum);

}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include <queue>
#include<string>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll;
typedef vector <int> vi;
#define fr(i,n) for(i=0;i<n;i++)
#define scn(n) scanf("%d",&n)
#define prt(n) printf("%d",n)
#define prtn(n) printf("%d\n",n)

int main(void)
{
int i,x,n;

scn(n);
//int a[n];
scn(x);
int a[n];
fr(i,n)
scn(a[i]);

unsigned long long sum=0;
sort(a,a+n);
for(i=0;i<n;i++)
{
    sum=sum+(a[i]*x);
    if(x!=1)
    x=x-1;
}
cout<<sum;

}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include <queue>
#include<string>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll;
typedef vector <int> vi;
#define fr(i,n) for(i=0;i<n;i++)
#define scn(n) scanf("%d",&n)
#define prt(n) printf("%d",n)
#define prtn(n) printf("%d\n",n)

int main(void)
{
//std::ios_base::sync_with_stdio(0);
int i,x,j,n,t,tmp;

cin>>n;
int a[n];
cin>>x;
t=n;

fr(i,n)
cin>>a[i];

ll sum=0;
sort(a,a+n);
for(i=0;i<n;i++)
{   if(x==0)
    x=1;
    sum=sum+(a[i]*x);
    x=x-1;
}
cout<<sum;

}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include <queue>
#include<string>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll;
typedef vector <int> vi;
#define fr(i,n) for(i=0;i<n;i++)
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%I64d",&n);
#define prt(n) printf("%d",n)
#define prtll(n) printf("%I64d",n);
#define prtn(n) printf("%d\n",n)
long long a[100001];
int main(void)
{
int i,x,n;

scn(n);
scn(x);

fr(i,n)
scanf("%I64d",&a[i]);

unsigned long long sum=0;
sort(a,a+n);
for(i=0;i<n;i++)
{
    sum=sum+(a[i]*x);
    if(x>1)
    x=x-1;
}
prtll(sum);

}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include <queue>
#include<string>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll;
typedef vector <int> vi;
#define fr(i,n) for(i=0;i<n;i++)
#define scn(n) scanf("%d",&n)
#define prt(n) printf("%d",n)
#define prtn(n) printf("%d\n",n)

int main(void)
{
//std::ios_base::sync_with_stdio(0);
int i,x,j,n,t,tmp;

scn(n);
//int a[n];
scn(x);
vi a(n,0);
fr(i,n)
scn(a[i]);

ll sum=0;
sort(a.begin(),a.end());
for(i=0;i<a.size();i++)
{   if(x==0)
    x=1;
    sum=sum+(a[i]*x);
    x=x-1;
}
printf("%I64d",sum);

}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include <queue>
#include<string>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll;
typedef vector <int> vi;
#define fr(i,n) for(i=0;i<n;i++)
#define scn(n) scanf("%d",&n)
#define prt(n) printf("%d",n)
#define prtn(n) printf("%d\n",n)

int main(void)
{
int i,x,n;

scn(n);
//int a[n];
scn(x);
long long a[n];
fr(i,n)
scn(a[i]);

unsigned long long sum=0;
sort(a,a+n);
for(i=0;i<n;i++)
{
    sum=sum+(a[i]*x);
    if(x>1)
    x=x-1;
}
cout<<sum;

}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include <queue>
#include<string>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll;
typedef vector <int> vi;
#define fr(i,n) for(i=0;i<n;i++)
#define scn(n) scanf("%d",&n)
#define prt(n) printf("%d",n)
#define prtn(n) printf("%d\n",n)

int main(void)
{
int i,x,n;

scn(n);
//int a[n];
scn(x);
vi a(1000000,0);
fr(i,n)
scn(a[i]);

unsigned long long sum=0;
sort(a.begin(),a.end());
for(i=0;i<a.size();i++)
{
    sum=sum+(a[i]*x);
    if(x!=1)
    x=x-1;
}
cout<<sum;

}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include <queue>
#include<string>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll;
typedef vector <int> vi;
#define fr(i,n) for(i=0;i<n;i++)
#define scn(n) scanf("%d",&n)
#define prt(n) printf("%d",n)
#define prtn(n) printf("%d\n",n)

int main(void)
{
//std::ios_base::sync_with_stdio(0);
int i,x,j,n,t,tmp;

scn(n);
//int a[n];
scn(x);
vi a(n,0);
fr(i,n)
scn(a[i]);

ll sum=0;
sort(a.begin(),a.end());
for(i=0;i<a.size();i++)
{   if(x==0)
    x=1;
    sum=sum+(a[i]*x);
    x=x-1;
}
prt(sum);

}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include <queue>
#include<string>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll;
typedef vector <int> vi;
#define fr(i,n) for(i=0;i<n;i++)
#define scn(n) scanf("%d",&n)
#define prt(n) printf("%d",n)
#define prtn(n) printf("%d\n",n)

int main(void)
{
//std::ios_base::sync_with_stdio(0);
int i,x,j,n,t,tmp;

cin>>n;
//int a[n];
cin>>x;
vi a(n,0);
fr(i,n)
cin>>a[i];

ll sum=0;
sort(a.begin(),a.end());
for(i=0;i<a.size();i++)
{   if(x==0)
    x=1;
    sum=sum+(a[i]*x);
    x=x-1;
}
cout<<sum;

}


#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 100000;
long long a[100000];
int main(){
    int n,x;
    int total = 0;

    cin >> n >> x;
    for(int i = 0; i< n; i++){
        cin >>a[i];
        total += a[i];
    }
    sort(a,a+n);
    unsigned long long hours = 0;
    for(int i = 0; i < x;i++){
        hours += a[i] * x;
        if(x > 1){
            x--;
        }
    }
    cout << hours;
    return 0;
}


#include<iostream>
using namespace std;
void qs(int a[100000], int left, int right) {
	int i = left, j = right, x, tam;
	x = (left + right) / 2;

	do {
		while ((a[i] < a[x]) && (i < right)) i++;
		while ((a[j] > a[x]) && (j > left)) j--;
		if (i <= j) {
			tam = a[i];
			a[i] = a[j];
			a[j] = tam;
			i++;
			j--;
		}

	} while (i <= j);
	if (left < j) qs(a, left, j);
	if (i < right) qs(a, i, right);
}
int main() {
	int n, x, arr[100003], i, kq = 0;
	cin >> n >> x;
	for (i = 0; i < n; i++) {
		cin >> arr[i];
	}
	qs(arr, 0, n - 1);
	for (i = 0; i < n; i++) {
		kq = kq + arr[i] * x;
		if (x != 1) x--;
	}
	cout << kq;
	return 0;
}


#include<iostream>
using namespace std;
int main() {
	int n, x, arr[10000], i, j, kq = 0,tam;
	cin >> n >> x;
	for (i = 0; i < n; i++) {
		cin >> arr[i];
	}
	for (i = 0; i < n; i++) {
		for (j = i + 1; j < n; j++) {
			if (arr[i] > arr[j]) {
				tam = arr[i];
				arr[i] = arr[j];
				arr[j] = tam;
			}
		}
	}
	i = 0;
	while (i != n) {
		kq = kq + arr[i]*x;
		if (x != 1) x--;
		i++;
	}
	cout << kq;
	return 0;
}


#include<iostream>
using namespace std;
int main() {
	int n, x, arr[100003], i, j, kq = 0,tam;
	cin >> n >> x;
	for (i = 0; i < n; i++) {
		cin >> arr[i];
	}
	for (i = 0; i < n; i++) {
		if (x!=1)
			for (j = i + 1; j < n; j++) {
				if (arr[i] > arr[j]) {
					tam = arr[i];
					arr[i] = arr[j];
					arr[j] = tam;
				}

			}
		kq = kq + arr[i] * x;
		if (x != 1) x--;
	}
	cout << kq;
	return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
long long n, x, arr[100000], i, kq = 0;
int main(){

	cin >> n >> x;
	for (i = 0; i < n; i++) {
		cin >> arr[i];
	}
	sort(arr, arr + n);
	for (i = 0; i < n; i++) {
		if (x > 1) {
			kq = kq + arr[i] * x;
			x--;
		} else kq = kq + arr[i] * x;

	}
	cout << kq;
	return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n, x, arr[100000], i, kq = 0;
	cin >> n >> x;
	for (i = 0; i < n; i++) {
		cin >> arr[i];
	}
	sort(arr, arr + n);
	for (i = 0; i < n; i++) {
		if (x > 1) {
			kq = kq + arr[i] * x;
			x--;
		} else kq = kq + arr[i] * x;

	}
	cout << kq;
	return 0;
}