#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

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

    double frac_sum = 0.0;
    int num_int = 0;
    for(int i = 0; i < 2*n; ++i) {
        double x;
        cin >> x;

        frac_sum += x - floor(x);

        if(fabs(x - (int)x) < 1e-5)
            ++num_int;
    }

    double ans = 1e10;
    for(int i = 0; i < min(n, 2*n - num_int); ++i)
        ans = min(ans, fabs(i - frac_sum));

    cout << fixed << setprecision(3) << ans;

    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <algorithm>
#include <complex>
using namespace std;
#define pb push_back
#define mp make_pair
#define point complex <double>
#define xx real()
#define yy imag()

const int MAXN = 20005;
int p[MAXN];

int main(){
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	int n, i, j, k, top, lim, a, b, ans = 0, cur;
	cin >> n;
	top = 0;
	for(i = 0; i < 2 * n; i++){
		scanf("%d.%d", &a, &b);
		if (b){
			p[top++] = b;
		}
	}
	lim = 2 * n - top;
	ans = 2 * 1000 * n;
	for(i = 0; i <= lim; i++){
		if (lim - i > n || i > n)
			continue;
		cur = 0;
		for(j = 0; j < n - i; j++){
			cur += p[j];
		}
		for(k = 0; k < n - (lim - i); k++, j++){
			cur += p[j] - 1000;
		}
		if (abs(cur) < ans){
			ans = abs(cur);
		}
	}
	printf("%d.", ans / 1000);
	a = ans % 1000;
	printf("%03d", a);
}


#include <iostream>
#include <stdio.h>
#include <math.h>
#include <vector>
#include <deque>
#include <utility>
#include <cassert>
#include <memory.h>
#include <map>
#include <string>
#include <string.h>
#include <algorithm>
#include <set>

using namespace std;

#define mp make_pair
#define pb push_back
#define li long long

li P = 1e9 + 9;

double a[10005];

double mod(double x){
	if(x < 0) return -x;
	else
		return x;
}

double minn(double a, double b){
	if(mod(a) <= mod(b)) return a;
	else
		return b;
}

int main(){
	//freopen("holy.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	cout.setf(ios::fixed);
	cout.precision(3);
	li n;
	cin >> n;
	li i;
	li r = 0;
	double S = 0;

	for(i = 0; i < 2 * n; i++){
		cin >> a[i];
		li c = a[i] / 1;
		double C = a[i] - c;
		if(C == 0)
			r++;
		S += C;
	}
	double mn = 100000000;
	double ans = 0;
	li k = 0;
	for(i = max(k, r - n); i <= min(n, r); i++){
		mn = minn(mn, S - (n - i));
	}
	cout << mn;
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <math.h>
#include <vector>
#include <deque>
#include <utility>
#include <cassert>
#include <memory.h>
#include <map>
#include <string>
#include <string.h>
#include <algorithm>
#include <set>

using namespace std;

#define mp make_pair
#define pb push_back
#define li long long

li P = 1e9 + 9;

double a[10005];

double mod(double x){
	if(x < 0) return -x;
	else
		return x;
}

double minn(double a, double b){
	if(mod(a) <= mod(b)) return mod(a);
	else
		return mod(b);
}

int main(){
	//freopen("holy.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	cout.setf(ios::fixed);
	cout.precision(3);
	li n;
	cin >> n;
	li i;
	li r = 0;
	double S = 0;

	for(i = 0; i < 2 * n; i++){
		cin >> a[i];
		li c = a[i] / 1;
		double C = a[i] - c;
		if(C == 0)
			r++;
		S += C;
	}
	double mn = 100000000;
	double ans = 0;
	li k = 0;
	for(i = max(k, r - n); i <= min(n, r); i++){
		mn = minn(mn, S - (n - i));
	}
	cout << mn;
	return 0;
}


#include <iostream>
using namespace std;

int main()
{
    int n;
    int sum=0;
    char p[20];
    cin>>n;
    for(int i=0;i<n*2;i++)
    {
            cin>>p;
            int j;
            for(j=0;p[j];j++);
            sum+=p[j-1]-48;
            sum+=(p[j-2]-48)*10;
            sum+=(p[j-3]-48)*100;//cout<<sum<<endl;
            sum%=1000;
    }
    cout<<"0.";
    if(sum<500)
    cout<<sum<<endl;
    else
    cout<<1000-sum<<endl;
    //system("PAUSE");
    return 0;
}


#include <iostream>
using namespace std;

int main()
{
    int n,count=0;
    int sum=0;
    char p[20];
    cin>>n;
    for(int i=0;i<n*2;i++)
    {
            cin>>p;
            int j;
            for(j=0;p[j];j++);
            int sum1=0;
            sum1+=p[j-1]-48;
            sum1+=(p[j-2]-48)*10;
            sum1+=(p[j-3]-48)*100;//cout<<sum<<endl;
            sum+=sum1;
            if(sum1==0)
            count++;
    }
    int min=100000000;
    int j=n-count;
    if(j<0)
    j=0;
    j*=1000;
    for(int i=0;i<=count;i++)
    {
            if(min>abs(i*1000+j-sum))
            min=abs(i*1000+j-sum);
            }
    printf("%4.3f\n",min/1000.0);
    //system("PAUSE");
    return 0;
}


#include <iostream>
using namespace std;

int main(int argc, char *argv[])
{
    int n;
    double sum;
    double d;
    int p[4000];
    cin>>n;
    for(int i=0;i<n*2;i++)
    {
            cin>>d;
            sum+=d;
    }
    double d1=sum-int(sum);
    d1*=1000;
    cout<<"0.";
    if(d1<500)
    cout<<d1<<endl;
    else
    cout<<1000-d1<<endl;
    system("PAUSE");
    return 0;
}


#include <iostream>
using namespace std;

int main()
{
    int n;
    int sum=0;
    char p[20];
    cin>>n;
    for(int i=0;i<n*2;i++)
    {
            cin>>p;
            int j;
            for(j=0;p[j];j++);
            sum+=p[j-1]-48;
            sum+=(p[j-2]-48)*10;
            sum+=(p[j-3]-48)*100;//cout<<sum<<endl;
            sum%=1000;
    }
    if(sum>=500)
    sum=1000-sum;
    printf("%4.3f",sum/1000.0);
    //system("PAUSE");
    return 0;
}


#include <iostream>
using namespace std;

int main()
{
    int n,count=0;
    int sum=0;
    char p[20];
    cin>>n;
    for(int i=0;i<n*2;i++)
    {
            cin>>p;
            int j;
            for(j=0;p[j];j++);
            int sum1=0;
            sum1+=p[j-1]-48;
            sum1+=(p[j-2]-48)*10;
            sum1+=(p[j-3]-48)*100;//cout<<sum<<endl;
            sum+=sum1;
            if(sum1==0)
            count++;
    }
    int min=100000000;
    int j=n-count;
    if(j<0)
    j=0;
    j*=1000;
    for(int i=0;i<=count;i++)
    {
            if(min>abs(i*1000+j-sum))
            min=abs(i*1000+j-sum);
            }
    printf("%4.3f\n",min/1000.0);
    system("PAUSE");
    return 0;
}


#include <iostream>
using namespace std;

int main()
{
    int n,count=0;
    int sum=0;
    char p[20];
    cin>>n;
    for(int i=0;i<n*2;i++)
    {
            cin>>p;
            int j;
            for(j=0;p[j];j++);
            int sum1=0;
            sum1+=p[j-1]-48;
            sum1+=(p[j-2]-48)*10;
            sum1+=(p[j-3]-48)*100;//cout<<sum<<endl;
            sum+=sum1;
            if(sum1==0)
            count++;
    }
    int min=100000000;
    int j=n-count;
    if(j<0)
    j=0;
    j*=1000;
    for(int i=0;i<=count;i++)
    {
            if(min>abs(i*1000+j-sum))
            min=abs(i*1000+j-sum);
            }
    printf("%4.3f\n",min/1000.0);
    system("PAUSE");
    return 0;//
}


#include <iostream>
using namespace std;

int main()
{
    int n,a=0;
    int sum=0;
    char p[20];
    cin>>n;
    for(int i=0;i<n*2;i++)
    {
            cin>>p;
            int j;
            for(j=0;p[j];j++);
            sum+=p[j-1]-48;
            sum+=(p[j-2]-48)*10;
            sum+=(p[j-3]-48)*100;//cout<<sum<<endl;
            if(sum>=1000)
            {
                         sum-=1000;
                         a=1;
                         }
    }
    if(sum>=500&&a==0)
    sum=1000-sum;
    printf("%4.3f",sum/1000.0);
    //system("PAUSE");
    return 0;
}
#include <iostream>
using namespace std;

int main()
{
    int n;
    int sum=0;
    char p[20];
    cin>>n;
    for(int i=0;i<n*2;i++)
    {
            cin>>p;
            int j;
            for(j=0;p[j];j++);
            sum+=p[j-1]-48;
            sum+=(p[j-2]-48)*10;
            sum+=(p[j-3]-48)*100;//cout<<sum<<endl;
            sum%=1000;
    }
    if(sum>=500)
    sum=1000-sum;
    printf("%4.3f",sum/1000.0);
    //system("PAUSE");
    return 0;
}


#include <iostream>
using namespace std;

int main(int argc, char *argv[])
{
    int n;
    double sum;
    double d;
    int p[4000];
    cin>>n;
    for(int i=0;i<n*2;i++)
    {
            cin>>d;
            sum+=d;
    }
    double d1=sum-int(sum);
    d1*=1000;
    cout<<"0.";
    if(d1<500)
    cout<<d1<<endl;
    else
    cout<<1000-d1<<endl;
    //system("PAUSE");
    return 0;
}


#include <iostream>
#include <vector>
#include <stdio.h>
using namespace std;

int n;
long double sum=0;
long double sum2=0;
int nm=0;
long double dd;
int main(){
    cin>>n;
    for(int i=0;i<2*n;i++){
        cin>>dd;
        sum+=(dd);
        sum2+=ceil(dd);
        if(floor(dd)==ceil(dd)){
            nm++;
        }
    }
    long double sol=1000000000;
    for(int i=0;i<=nm;i++){
        sol=min(sol,abs(sum2-(n-i)-sum));
    }
    cout<<fixed;
    cout.precision(3);
    cout<<sol<<endl;
}


#include <iostream>
#include <vector>
#include <stdio.h>
using namespace std;

int n;
long double sum=0;
int nm=0;
long double dd;
int main(){
    cin>>n;
    for(int i=0;i<2*n;i++){
        cin>>dd;
        sum+=(dd);
        if(floor(dd)==ceil(dd)){
            nm++;
        }
    }
    long double sol=1000000000;
    for(int i=0;i<=nm;i++){
        sol=min(sol,abs(2*n-(n-i)-sum));
    }
    cout<<fixed;
    cout.precision(3);
    cout<<sol<<endl;
}


#include <iostream>
#include <vector>
#include <stdio.h>
using namespace std;

int n;
long double sum=0;
int nm=0;
long double dd;
int main(){
    cin>>n;
    for(int i=0;i<2*n;i++){
        cin>>dd;
        sum+=(dd);
        if(floor(dd)!=ceil(dd)){
            nm++;
        }
    }
    long double sol=1000000000;
    nm=min(nm,n);
    sol=min(sol,abs(2*n-nm-sum));

    if(2*n-((int)(sum))<=nm){
        sol=min(sol,abs(sum-(int)(sum)));
    }

    if(2*n-((int)(sum+1))<=nm){
        sol=min(sol,abs(sum-(int)(sum+1)));
    }
    cout<<fixed;
    cout.precision(3);
    cout<<sol<<endl;
}


#pragma comment(linker, "/STACK:64777216")
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<string>
#include<sstream>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<memory.h>
#include<ctime>
#include<cassert>

#define pb push_back
#define sz(a) (int)a.size()
#define bs binary_search
#define np next_permutation
#define mp make_pair
#define all(a) a.begin(),a.end()
#define read(a) scanf("%d", &a)
#define writeln(a) printf("%d\n", a);
#define forn(i, n) for (int i = 0; i < n; ++i)
#define forv(i, v) for (int i = 0; i < sz(v); ++i)
#define forsint(it, s) for (set<int>::iterator it = s.begin(); it != s.end(); ++it)
#define _(a, b) memset(a, b, sizeof a)

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

template<class T> inline T sqr(T x) { return x * x; }

const double pi = acos(-1.0), eps = 1e-9, e = exp(1.0);
const int INF = 1000 * 1000 * 1000, MAXN = 100005, MOD = 9999997;

void prepare(string s) {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt","w",stdout);
#else
    if (sz(s) != 0) {
        freopen((s + ".in").c_str(), "r", stdin);
        freopen((s + ".out").c_str(), "w", stdout);
    }
#endif
}

int n, cnt = 0, sum2 = 0;
double a[4005], sum = 0.0, ans = (double)INF;

void solve()
{
    cin >> n;
    forn (i, 2*n) {
        cin >> a[i];
        sum += a[i] - (int)a[i];
        if (a[i] - (int)a[i] != 0.0) {
            cnt++;
            sum2++;
        }
    }
    int col = min(n, n * 2 - cnt);
    ans = min(ans, abs((double)sum2 - sum));
    forn (i, col) {
        sum2--;
        ans = min(ans, abs((double)sum2 - sum));
    }
    printf("%.3lf", ans);
}

int main()
{
    prepare("");

    solve();

    return 0;
}


#pragma comment(linker, "/STACK:64777216")
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<string>
#include<sstream>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<memory.h>
#include<ctime>
#include<cassert>

#define pb push_back
#define sz(a) (int)a.size()
#define bs binary_search
#define np next_permutation
#define mp make_pair
#define all(a) a.begin(),a.end()
#define read(a) scanf("%d", &a)
#define writeln(a) printf("%d\n", a);
#define forn(i, n) for (int i = 0; i < n; ++i)
#define forv(i, v) for (int i = 0; i < sz(v); ++i)
#define forsint(it, s) for (set<int>::iterator it = s.begin(); it != s.end(); ++it)
#define _(a, b) memset(a, b, sizeof a)

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

template<class T> inline T sqr(T x) { return x * x; }

const double pi = acos(-1.0), eps = 1e-9, e = exp(1.0);
const int INF = 1000 * 1000 * 1000, MAXN = 100005, MOD = 9999997;

void prepare(string s) {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt","w",stdout);
#else
    if (sz(s) != 0) {
        freopen((s + ".in").c_str(), "r", stdin);
        freopen((s + ".out").c_str(), "w", stdout);
    }
#endif
}

int n, cnt = 0, sum2 = 0;
double a[4005], sum = 0.0, ans = (double)INF;

void solve()
{
	cin >> n;
	forn (i, 2*n) {
		cin >> a[i];
		sum += a[i] - (int)a[i];
		if (a[i] - (int)a[i] != 0.0) {
			cnt++;
			sum2++;
		}
	}
	int col = min(n, n * 2 - (2 * n - cnt));
	int MIN;
	MIN = max(0, n - (2 * n - cnt));
	for (int i = MIN; i <= col; i++) {
		ans = min(ans, abs((double)(sum2 - i) - sum));
	}
	printf("%.3lf", ans);
}

int main()
{
    prepare("");

    solve();

    return 0;
}


#include <ctime>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
using namespace std;

#define MP make_pair
#define FILL(a,v) memset(a,v,sizeof(a))
#define INF 1000000000
const double PI = acos(-1.0);
const double EPS = 1e-7;

vector<pair<double,double> > a;

int main()
{

	int n;
	cin>>n;
	n*=2;

	double res=0;
	int cnt=0;

	for (int i=0; i<n; i++){
		double x;
		cin>>x;

		double d1,d2;
		d1=x-(int)(x+EPS);

		if (d1<EPS) cnt++;
		else {
			res+=d1;
		}
	}

	int c = n-cnt;
	int m=n/2;

	while(res>0.5 && c>0 && m>0){
		res-=1;
		c--;
		m--;
	}

	m-=cnt;

	if (m>0) res-=m;

	printf("%.3f\n",res);

}


#include <ctime>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
using namespace std;

#define MP make_pair
#define FILL(a,v) memset(a,v,sizeof(a))
#define INF 1000000000
const double PI = acos(-1.0);
const double EPS = 1e-7;

vector<pair<double,double> > a;

int main()
{

	int n;
	cin>>n;
	n*=2;

	double res=0;
	int cnt=0;

	for (int i=0; i<n; i++){
		double x;
		cin>>x;

		double d1,d2;
		d1=x-(int)x;

		if (d1<EPS) cnt++;
		else {
			res+=d1;
		}
	}

	int c = n-cnt;
	int m=n/2;

	while(res>0.5 && c>0 && m>0){
		res-=1;
		c--;
	}

	m-=cnt;

	if (m>0) res-=m;

	printf("%.3f\n",res);

}


#include <ctime>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
using namespace std;

#define MP make_pair
#define FILL(a,v) memset(a,v,sizeof(a))
#define INF 1000000000
const double PI = acos(-1.0);
const double EPS = 1e-7;

vector<pair<double,double> > a;

int main()
{

	int n;
	cin>>n;
	n*=2;

	double res=0;
	int cnt=0;

	for (int i=0; i<n; i++){
		double x;
		cin>>x;

		double d1,d2;
		d1=x-(int)(x+EPS);

		if (d1<EPS) cnt++;
		else {
			res+=d1;
		}
	}

	int c = n-cnt;
	int m=n/2;

	while(res>0.5 && c>0 && m>0){
		res-=1;
		c--;
		m--;
	}

	m-=cnt;

	if (m>0) res-=m;

	printf("%.3f\n",abs(res));

}


#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <stdio.h>
#include <string.h>
#include <assert.h>

using namespace std;
static const double EPS = 1e-9;
int ROUND(double x) { return (int)(x+0.5); }
bool ISINT(double x) { return fabs(ROUND(x)-x)<=EPS; }
bool ISEQUAL(double x,double y) { return fabs(x-y)<=EPS*max(1.0,max(fabs(x),fabs(y))); }
double SQSUM(double x,double y) { return x*x+y*y; }
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }
#define PI	(acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0]))
#define NG (-1)
#define BIG (987654321)
#define SZ(a) ((int)((a).size()))
#define SQ(a) ((a)*(a))
typedef long long ll;
typedef unsigned long long ull;

#define FOR(v,i) for(__typeof((v).begin())i=(v).begin();i!=(v).end();++i)
// BEGIN CUT HERE
#undef FOR
#define FOR(v,i) for(auto i=(v).begin();i!=(v).end();++i)
// END CUT HERE

#if 0
// B
int main()
{
	int n;
	cin >> n;
	vector <int> p(n);

	int hanten = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> p[i];
	}

	for (int i = 0; i < n; i++)
	{
		for (int k = i+1; k < n; k++)
		{
			if(p[i]>p[k])
			{
				hanten++;
			}
		}
	}

	int ans = (hanten/2)*4 + (hanten%2);

	cout << ans << endl;
}

#else
// A
int main()
{
	int n;
	cin >> n;
	string s;
	vector <int> b;
	int num0 = 0;

	for (int i = 0; i < 2*n; i++)
	{
		cin >> s;
		int len = SZ(s);
		int tmp = (s[len-3]-'0')*100+(s[len-2]-'0')*10+(s[len-1]-'0')*1;

		if(tmp==0)
		{
			num0++;
		}
		else
		{
			b.push_back(tmp);
		}
	}

	sort(b.begin(),b.end());

	int best = BIG;
	for(int forward=0;forward<=num0;forward++)
	{
		vector <int> a;
		for (int i = 0; i < forward; i++)
		{
			a.push_back(0);
		}

		for (int i = 0; i < SZ(b); i++)
		{
			a.push_back(b[i]);
		}

		int backward = num0-forward;
		for (int i = 0; i < backward; i++)
		{
			a.push_back(1000);
		}

		int sum = 0;
		for (int i = 0; i < n; i++)
		{
			sum += a[i];
			sum += a[2*n-i-1]-1000;
		}

		best = min(best,abs(sum));
	}

	int up1000 = best/1000;

	string  ans;
	stringstream ss;
	ss << up1000;
	ss >> ans;
	ans += ".";
	ans += string(1,'0'+(best/100)%10);
	ans += string(1,'0'+(best/10)%10);
	ans += string(1,'0'+(best/1)%10);

	cout << ans << endl;
}
#endif


#include <stdio.h>
#include <algorithm>

using namespace std;

int n;

int main()
{
	scanf("%d",&n);
	int res = 0;
	for(int i = 0; i < 2*n; i++) {
		double val;
		scanf("%lf",&val);
		val *= 1000;
		int ival = (int)(val + 0.5);
		int down = ival%1000;
		res += down;
		res %= 1000;
	}
	printf("0.%03d\n",res);
	return 0;
}


#include <stdio.h>
#include <algorithm>

using namespace std;

int n;

int main()
{
	scanf("%d",&n);
	int res = 0;
	int non = 0;
	for(int i = 0; i < 2*n; i++) {
		double val;
		scanf("%lf",&val);
		val *= 1000;
		int ival = (int)(val + 0.5);
		int down = ival%1000;
		res += down;
		if (down == 0) {
			non ++;
		}
	}
	if (non >= n) {
		res %= 1000;
		if (res >= 500)
			res = 1000 - res;
	} else {
		res -= 1000 * (n-non);
		if (non) {
			if (res >= 1000 * non) {
				res -= 1000 * non;
			} else if (res >= 0) {
				res %= 1000;
				if (res >= 500)
					res = 1000 - res;
			}
		}
	}
	if (res < 0) res = -res;
	printf("%.3f\n",(double)res/1000.0);
	return 0;
}


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

int main(void){
    int N, M, n, m, temp, NZ, Pp = 0;
    double P=0, p, mi=99999.0;
    cin >> N;
    N *= 2;
    cout << fixed << setprecision(3);
    for(n=0;n<N;n++){
        cin >> p;
        temp = ((int)(p*10000))%10000;
        if(temp<0)
            temp += 10000;
        if(temp%10>=5)
            temp = temp/10+1;
        else
            temp = temp/10;
        if(temp>0)
            NZ++;
        P += p;
        Pp += (int)p;
    }
    m=NZ-N/2;
    M=NZ;
    if(m<0)
        m=0;
    if(M>N/2)
        M=N/2;
    m+=Pp;
    M+=Pp;
    for(n=m;n<=M;n++){
        p = n-P;
        if(p<0)
            p = -p;
        if(p<mi)
            mi = p;
    }
    cout << mi;
}


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

int main(void){
    short N, temp, NZ;
    int Pp = 0, n, m, M;
    double P=0, p, min=99999.0;
    cin >> N;
    N *= 2;
    cout << fixed << setprecision(3);
    for(n=0;n<N;n++){
        cin >> p;
        temp = ((int)(p*10000))%10000;
        if(temp<0)
            temp += 10000;
        if(temp%10>=5)
            temp = temp/10+1;
        else
            temp = temp/10;
        if(temp>0)
            NZ++;
        P += p;
        Pp += (int)p;
    }
    m=NZ-N/2;
    M=NZ;
    if(m<0)
        m=0;
    if(M>N/2)
        M=N/2;
    m+=Pp;
    M+=Pp;
    for(n=m;n<=M;n++){
        p = n-P;
        if(p<0)
            p = -p;
        if(p<min)
            min = p;
    }
    cout << min;
}


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

int main(void){
    int N, M, n, m, temp, NZ=0, Pp=0;
    double P=0, p, mi=99999.0;
    cin >> N;
    N *= 2;
    cout << fixed << setprecision(3);
    for(n=0;n<N;n++){
        cin >> p;
        temp = ((int)(p*10000))%10000;
        if(temp<0)
            temp += 10000;
        if(temp%10>=5)
            temp = temp/10+1;
        else
            temp = temp/10;
        if(temp>0)
            NZ++;
        P += p;
        Pp += (int)p;
    }
    m=NZ-N/2;
    M=NZ;
    if(m<0)
        m=0;
    if(M>N/2)
        M=N/2;
    m+=Pp;
    M+=Pp;
    for(n=m;n<=M;n++){
        p = n-P;
        if(p<0)
            p = -p;
        if(p<mi)
            mi = p;
    }
    cout << mi;
}


#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <fstream>
#include <map>
#include <stack>
#include <queue>
#include <stdio.h>
#include <stdlib.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const int maxint = 1000*1000*1000;
#pragma comment(linker,"/STACK:268435456")

int i,j,n,zeros;
double a[4009],sum,ans1,ans2;

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	cin>>n;
	n*=2;
	for (i=0;i<n;i++)
	{
		cin>>a[i];
		a[i] = a[i] - (int)a[i];
		if (a[i]==0.)
			zeros++;
		sum += a[i];
	}

	ans1 = min((int)sum,n-zeros);
	if (sum==(int)sum)
		ans2 = ans1;
	else
		ans2 = min((int)sum+1,n-zeros);

	if (fabs(sum-(double)ans1)>fabs(sum-(double)ans2))
	{
		printf("%.3lf",fabs(sum-ans2));
	}
	else
	{
		printf("%.3lf",fabs(sum-ans1));
	}

    return 0;
}


#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <fstream>
#include <map>
#include <stack>
#include <queue>
#include <stdio.h>
#include <stdlib.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const int maxint = 1000*1000*1000;
#pragma comment(linker,"/STACK:268435456")

int i,j,n,zeros,cur;
double a[4009],sum,ans;

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	cin>>n;
	n*=2;
	for (i=0;i<n;i++)
	{
		cin>>a[i];
		a[i] = a[i] - (int)a[i];
		if (a[i]==0.)
			zeros++;
		sum += a[i];
	}

	cur = (n - zeros*2) / 2;
	ans = fabs(sum-cur);
	while (zeros!=0)
	{
		cur++;
		ans = min(ans,fabs(cur-sum));
		zeros--;
	}
	printf("%.3lf",ans);

    return 0;
}


#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <sstream>
#include <set>
#include <map>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <deque>
using namespace std;

#define ll long long
#define pi pair<int,int>
#define pll pair<ll,ll>
#define pii pair<int,pi>
#define X first
#define Y second
#define pb push_back
#define ab(x) ((x)<0?(-(x)):(x))
#define xx(x) ((x)*(x))
#define mp make_pair
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define vpi vector<pi>
#define vpll vector<pll>
#define ALL(x) (x).begin(),(x).end()
#define Max (1<<30)
#define LLMax (1ll<<60)
template<class T>string ToString(T t){stringstream s;s<<t;return s.str();}
template<class T>void ToOther(T&t,string a){stringstream s(a);s>>t;}

int n;
int a[4004];
int d[4004][4004];

void ckmin(int &r,int t){
	if( ab(r) > ab(t) )r = t;
}

int go(int x,int cnt){
	if( x == n ){
		if( cnt == n/2 )return 0;
		return Max;
	}

	int &r= d[x][cnt];
	if( r != -1 )return r; r = Max;

	if( a[x] == 0 ){
		ckmin( r , go(x+1,cnt+1) );
		ckmin( r , go(x+1,cnt) );
	}else{
		ckmin( r , go(x+1,cnt+1) + 1000 - a[x] );
		ckmin( r , go(x+1,cnt) - a[x] );
	}
	return r;
}
int main(){
	scanf("%d",&n);n*=2;

	for(int i = 0 ; i< n ;i ++ ){
		int t; scanf("%d.%d",&t,a+i);
	}

	memset(d,-1,sizeof(d));

	int g = go(0,0);

	printf("0.%03d",ab(g));
}


#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <sstream>
#include <set>
#include <map>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <deque>
using namespace std;

#define ll long long
#define pi pair<int,int>
#define pll pair<ll,ll>
#define pii pair<int,pi>
#define X first
#define Y second
#define pb push_back
#define ab(x) ((x)<0?(-(x)):(x))
#define xx(x) ((x)*(x))
#define mp make_pair
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define vpi vector<pi>
#define vpll vector<pll>
#define ALL(x) (x).begin(),(x).end()
#define Max (1<<30)
#define LLMax (1ll<<60)
template<class T>string ToString(T t){stringstream s;s<<t;return s.str();}
template<class T>void ToOther(T&t,string a){stringstream s(a);s>>t;}

int n;
int a[4004];
int d[4004][4004];

void ckmin(int &r,int t){
	if( ab(r) > ab(t) )r = t;
}

int go(int x,int cnt){
	if( x == n ){
		if( cnt == n/2 )return 0;
		return Max;
	}

	int &r= d[x][cnt];
	if( r != -1 )return r; r = Max;

	if( a[x] == 0 ){
		ckmin( r , go(x+1,cnt+1) );
		ckmin( r , go(x+1,cnt) );
	}else{
		ckmin( r , go(x+1,cnt+1) + 1000 - a[x] );
		ckmin( r , go(x+1,cnt) - a[x] );
	}
	return r;
}
int main(){
	scanf("%d",&n);n*=2;

	for(int i = 0 ; i< n ;i ++ ){
		int t; scanf("%d.%d",&t,a+i);
	}

	memset(d,-1,sizeof(d));

	int g = go(0,0);

	printf("%d.%03d",ab(g)/1000,ab(g)%1000);
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <sstream>
#include <utility>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>
#include <ctime>
#include <assert.h>
#include <string.h>
#include <limits>
using namespace std;

#define INF 100000000
#define PI 3.1415926535897932384626433832795
#define PI_HALF 1.570796327
#define EPS 1e-9

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair< int, int > PII;
typedef pair< LL, LL > PLL;
typedef vector< int > VI;
typedef vector< LL > VLL;
typedef vector< string > VS;
typedef vector< PII > VPII;
typedef vector< PLL > VPLL;

#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define SZ(c) (int)(c).size()
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort( ALL( c ) )
#define SORT_(c,f) sort( ALL( c ), f )
#define FILL(x,v) memset( x, v, sizeof( x ) );

#define REP(i,n) for ( int i = 0, max_ = (n); i < max_; ++i )
#define REPD(i,n) for ( int i = (n) - 1; i >= 0; --i )
#define FOR(i,a,b) for ( int i = (a), max_ = (b); i < max_; ++i )
#define FORD(i,a,b) for ( int i = (a) - 1, min_ = (b); i >= min_; --i )

int Max ( int a, int b ) { return ( ( (b-a) >> (32-1) ) & (a^b) ) ^ b; }
int Min ( int a, int b ) { return ( ( (b-a) >> (32-1) ) & (a^b) ) ^ a; }
LL GCD ( LL a, LL b ) { return b != 0 ? GCD(b, a % b) : a; }
LL LCM ( LL a, LL b ) { return a*(b / GCD(a,b)); }
LL Pow ( LL n, LL e ) { if ( e == 0 ) return 1; if ( e == 1 ) return n; else if ( e & 1 ) { LL t = Pow(n,e/2); return n*t*t; } else { LL t = Pow(n,e/2); return t*t; } }

int main ()
{
    int N, sum = 0, c = 0;
    scanf( "%d", &N );
    REP(i,2*N)
    {
        int a, b;
        scanf( "%d.%d", &a, &b );
        sum += b;
        if ( b > 0 ) ++c;
    }

    int res = INF;
    int zero = 2*N - c;
    int min = std::max( 0, (2*N - 2*zero) / 2 );
    int max = std::min( N,  c - (zero&1) );
    FOR(i,min,max+1)
        res = std::min( res, abs( sum - 1000 * i ) );

    printf( "%d.%.3d\n", res/1000, res % 1000 );

    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <sstream>
#include <utility>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>
#include <ctime>
#include <assert.h>
#include <string.h>
#include <limits>
using namespace std;

#define INF 100000000
#define PI 3.1415926535897932384626433832795
#define PI_HALF 1.570796327
#define EPS 1e-9

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair< int, int > PII;
typedef pair< LL, LL > PLL;
typedef vector< int > VI;
typedef vector< LL > VLL;
typedef vector< string > VS;
typedef vector< PII > VPII;
typedef vector< PLL > VPLL;

#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define SZ(c) (int)(c).size()
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort( ALL( c ) )
#define SORT_(c,f) sort( ALL( c ), f )
#define FILL(x,v) memset( x, v, sizeof( x ) );

#define REP(i,n) for ( int i = 0, max_ = (n); i < max_; ++i )
#define REPD(i,n) for ( int i = (n) - 1; i >= 0; --i )
#define FOR(i,a,b) for ( int i = (a), max_ = (b); i < max_; ++i )
#define FORD(i,a,b) for ( int i = (a) - 1, min_ = (b); i >= min_; --i )

int Max ( int a, int b ) { return ( ( (b-a) >> (32-1) ) & (a^b) ) ^ b; }
int Min ( int a, int b ) { return ( ( (b-a) >> (32-1) ) & (a^b) ) ^ a; }
LL GCD ( LL a, LL b ) { return b != 0 ? GCD(b, a % b) : a; }
LL LCM ( LL a, LL b ) { return a*(b / GCD(a,b)); }
LL Pow ( LL n, LL e ) { if ( e == 0 ) return 1; if ( e == 1 ) return n; else if ( e & 1 ) { LL t = Pow(n,e/2); return n*t*t; } else { LL t = Pow(n,e/2); return t*t; } }

int main ()
{
    int N, sum = 0, c = 0;
    scanf( "%d", &N );
    REP(i,2*N)
    {
        int a, b;
        scanf( "%d.%d", &a, &b );
        sum += b;
        if ( b > 0 ) ++c;
    }

    int res = INF;
    int zero = 2*N - c;
    int min = std::max( 0, (2*N - 2*zero) / 2 );
    int max = std::min( N, zero + (2*N - 2*zero) / 2 );
    FOR(i,min,max+1)
        res = std::min( res, abs( sum - 1000 * i ) );

    printf( "%d.%.3d\n", res/1000, res % 1000 );

    return 0;
}


#pragma comment(linker, "/STACK:100000000000000")
#include <stdio.h>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string.h>
#include <cctype>
#include <cassert>
#include <ctime>
#define mp make_pair
#define pb push_back
#define lo int
#define li long long int
#define db double
#define FOR(i, n) for(lo i = 0; i < (n); i++)
#define pi 3.14159265358979323
#define eps 0.0001
#define MN 251
using namespace std;
const lo INF= 2e8;

db take_down(db a)
{
    return db(a- (lo) a);
}
db take_up(db a)
{
     db dr = (db(a - (lo) a));
       if(dr > eps)
       {
           dr = 1 - dr;
       }
    return dr;
}
int main()
{
#ifdef _DEBUG
   freopen("input.txt", "r", stdin);
#endif
   //freopen("chess.in", "r", stdin);
   //freopen("chess.out", "w", stdout);
   lo n;
   cin >> n;
   vector<db>op(2 * n);
   for(lo i = 0; i <2 *  n; i++)
   {
       cin >> op[i];
   }
   sort(op.begin(), op.end());
   db r = 0;
   for(lo i = 0; i < n; i++)
   {
         r -= take_down(op[i]);
   }
   for(lo i = n; i < 2 * n; i++)
   {
       r += take_up(op[i]);
   }
   for(lo i = 0; i < n; i++)
   {
       for(lo j = n; j < 2 * n; j++)
       {
           db old = -take_down(op[i]) + take_up(op[j]);
           db delta = take_up(op[i]) - take_down(op[j]);
           if(abs(r) > abs(r - old + delta))
           {
               r = r - old + delta;
               swap(op[i], op[j]);
               i--;
               break;
           }
       }
   }
   cout <<fixed << setprecision(3)<< abs(r);
}


#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    double a;
    int sum = 0;
    int cnt=  0;
    for(int i = 0; i < 2*n; i++) {
        scanf("%lf",&a);
        a*=1000;
        int num = a;
        num%=1000;

        sum += num;
        if(num) cnt++;
    }
    int ans = 1<<30;
    for(int i=max(0,cnt-n); i <= min(cnt,n); i++)
    {
        ans = min(ans,abs(sum-1000*i));
    }
    printf("%d.%03d\n",ans/1000,ans%1000);
    return 0;
}


#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    double a;
    int sum = 0;
    int cnt=  0;
    for(int i = 0; i < 2*n; i++) {
        scanf("%lf",&a);
        a*=1000;
        int num = a;
        num%=1000;

        sum += num;
        if(num) cnt++;
    }
    int ans = 1000000000;
    for(int i=max(0,cnt-n); i < min(cnt,n); i++)
    {
        ans = min(ans,sum-1000*i);
    }
    printf("%d.%03d\n",ans/1000,ans%1000);
    return 0;
}


#include <cstdio>
#include <cmath>
#include <algorithm>
int main()
{
    int n;
    scanf("%d",&n);
    int a,b;
    int sum = 0;
    int cnt=  0;
    for(int i = 0; i < 2*n; i++) {
        scanf("%d.%d",&a,&b);
        sum += b;
        if(b) cnt++;
    }
    int ans = 1<<30;
    for(int i=std::max(0,cnt-n); i <= std::min(cnt,n); i++)
    {
        ans = std::min(ans,abs(sum-1000*i));
    }
    printf("%d.%03d\n",ans/1000,ans%1000);
    return 0;
}


#include <cstdio>
#include <cmath>
#include <algorithm>
int main()
{
    int n;
    scanf("%d",&n);
    int a,b;
    int sum = 0;
    int cnt=  0;
    for(int i = 0; i < 2*n; i++) {
        scanf("%d.%d",&a,&b);
        sum += a;
        if(b) cnt++;
    }
    int ans = 1<<30;
    for(int i=std::max(0,cnt-n); i <= std::min(cnt,n); i++)
    {
        ans = std::min(ans,abs(sum-1000*i));
    }
    printf("%d.%03d\n",ans/1000,ans%1000);
    return 0;
}


#include <cstdio>
#include <algorithm>
int main()
{
    int n;
    scanf("%d",&n);
    double a;
    int sum = 0;
    for(int i = 0; i < 2*n; i++) {
        scanf("%lf",&a);
        a*=1000;
        int num = a;
        num%=1000;
        sum += num;
    }
    printf("0.%d\n",min(1000-sum%1000,sum%1000));
    return 0;
}


#include <cstdio>
#include <algorithm>
int main()
{
    int n;
    scanf("%d",&n);
    double a;
    int sum = 0;
    for(int i = 0; i < 2*n; i++) {
        scanf("%lf",&a);
        a*=1000;
        int num = a;
        num%=1000;
        sum += num;
    }
    printf("0.%d\n",std::min(1000-sum%1000,sum%1000));
    return 0;
}


#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    double a;
    int sum = 0;
    int cnt=  0;
    for(int i = 0; i < 2*n; i++) {
        scanf("%lf",&a);
        a*=1000;
        int num = a;
        num%=1000;

        sum += num;
        if(num) cnt++;
    }
    int ans = 1000000000;
    for(int i=max(0,cnt-n); i <= min(cnt,n); i++)
    {
        ans = min(ans,abs(sum-1000*i));
    }
    printf("%d.%03d\n",ans/1000,ans%1000);
    return 0;
}


#include <cstdio>
#include <cmath>
#include <algorithm>
int main()
{
    int n;
    scanf("%d",&n);
    int a,b;
    int sum = 0;
    int cnt=  0;
    for(int i = 0; i < 2*n; i++) {
        scanf("%d.%d",&a,&b);
        sum += a;
        if(b) cnt++;
    }
    int ans = 1<<30;
    for(int i=std::max(0,cnt-n); i <= std::min(cnt,n); i++)
    {
        ans = min(ans,abs(sum-1000*i));
    }
    printf("%d.%03d\n",ans/1000,ans%1000);
    return 0;
}


#include <cstdio>
int main()
{
    int n;
    scanf("%d",&n);
    double a;
    int sum = 0;
    for(int i = 0; i < 2*n; i++) {
        scanf("%lf",&a);
        a*=1000;
        int num = a;
        num%=1000;
        sum += num;
    }
    printf("0.%d\n",sum%1000);
    return 0;
}


#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <iomanip>

using namespace std;

int dp[4001][2001];

int main()
{
#ifdef LOCAL
   freopen( "input.txt", "rt", stdin );
   freopen( "output.txt", "wt", stdout );
#endif
	int n, cnt = 0;
	double sum1 = 0, sum2 = 0;
	cin >> n;
	vector<int> a;
	for (int i = 0; i < n*2; i++)
	{
		double t;
		cin >> t;
		if (int(t*1000+0.5)%1000 == 0)
			continue;
		cnt++;
		sum1 += int(t);
		sum2 += t;
	}
	double min = 2000000;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
		{
			if (i + j == cnt && 2*n-cnt + i >= n && 2*n-cnt + j >= n)
			{
				if (abs(sum1 + j - sum2) < min)
					min = abs(sum1 + j - sum2);
			}
		}
	cout << fixed << setprecision(3) << min;
}


#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <iomanip>

using namespace std;

int dp[4001][2001];

int main()
{
#ifdef LOCAL
   freopen( "input.txt", "rt", stdin );
   freopen( "output.txt", "wt", stdout );
#endif
	int n, cnt = 0;
	double sum1 = 0, sum2 = 0;
	cin >> n;
	vector<int> a;
	for (int i = 0; i < n*2; i++)
	{
		double t;
		cin >> t;
		if (int(t*1000+0.5)%1000 == 0)
			continue;
		cnt++;
		sum1 += int(t);
		sum2 += t;
	}
	double min = 2000000;
	for (int i = 0; i <= cnt; i++)
		for (int j = 0; j <= cnt; j++)
		{
			if (i + j == cnt && 2*n-cnt + i >= n && 2*n-cnt + j >= n)
			{
				if (abs(sum1 + j - sum2) < min)
					min = abs(sum1 + j - sum2);
			}
		}
	cout << fixed << setprecision(3) << min;
}


#include <iostream>
#include <cstring>
#include <vector>
#include <cmath>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cstring>
#include <set>

using namespace std;

long long a[4500];

long long sum = 0;

int main()
{
	long long n;
	cin >> n;
	n = 2 * n;
	int zero_count = 0;
	for (int i = 0; i < n; i++)
	{
		double x;
		cin >> x;
		a[i] = x * 1000;
		a[i] %= 1000;
		if (a[i] == 0)
			zero_count++;
		sum += a[i];
	}

	long long ans = 10000000000000LL;

	int k = (n - zero_count);

	for (int i = 0; i <= k; i++)
	{
		int want_to_paste_zeros = n / 2 - i;
		if (zero_count - want_to_paste_zeros < 0)
			continue;
		if (llabs(i * 1000 - sum) < ans)
		{
			ans = llabs(i * 1000 - sum);
		}
	}
	printf("%I64d.%03I64d", ans / 1000, ans % 1000);
	return 0;
}


#include <iostream>
#include <cstring>
#include <vector>
#include <cmath>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cstring>
#include <set>

using namespace std;

long long a[4500];

long long sum = 0;

int main()
{
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	long long n;
	cin >> n;
	n = 2 * n;
	int zero_count = 0;
	for (int i = 0; i < n; i++)
	{
		double x;
		cin >> x;
		a[i] = x * 1000;
		a[i] %= 1000;
		if (a[i] == 0)
			zero_count++;
		sum += a[i];
	}

	long long ans = 10000000000000LL;

	int k = (n - zero_count);

	for (int i = 0; i <= k; i++)
	{
		int want_to_paste_zeros = n / 2 - i;
		if (zero_count - want_to_paste_zeros < 0)
			continue;
		if (llabs(i * 1000 - sum) < ans)
		{
			ans = llabs(i * 1000 - sum);
		}
	}
	printf("%I64d.%03I64d", ans / 1000, ans % 1000);
	return 0;
}


#include <iostream>
#include <cstring>
#include <vector>
#include <cmath>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cstring>
#include <set>

using namespace std;

double a[4500];

const double EPS = 1e-9;

double sum = 0;

int main()
{
	long long n;
	cin >> n;
	n = 2 * n;
	int zero_count = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		a[i] -= (double)((long long)(a[i]));
		if (fabs(a[i]) < EPS)
			zero_count++;
		sum += a[i];
	}

	double ans = 100000000;
	for (int i = 0; i <= zero_count; i++)
	{
		int cur_ones = (n - i) / 2;
		if (fabs(cur_ones - sum) < ans)
		{
			ans = fabs(cur_ones - sum);
		}
		if ((n - i) % 2 != 0)
			cur_ones = (n - i) / 2 + 1;
		if (fabs(cur_ones - sum) < ans)
		{
			ans = fabs(cur_ones - sum);
		}
	}
	printf("%.3lf", ans);
	return 0;
}


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

int main()
{
    int n, a,b,leftopen=0,rightopen=0,seconds=0;
    vector<int> arr1;
    vector<int> arr2;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >>a>>b;
        arr1.push_back(a);
        arr2.push_back(b);
    }
    for(int i=0;i<n;i++)
    {
        if(arr1[i]==1){leftopen++;}
        if(arr2[i]==1){rightopen++;}
    }if(leftopen>rightopen){seconds=(n-leftopen+rightopen);}
    else if(rightopen>leftopen){seconds=(n-rightopen+leftopen);}
    cout << seconds;
    return 0;
}


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

int main()
{
    int n, a,b,leftopen=0,rightopen=0,seconds=0;
    vector<int> arr1;
    vector<int> arr2;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >>a>>b;
        arr1.push_back(a);
        arr2.push_back(b);
    }
    for(int i=0;i<n;i++)
    {
        if(arr1[i]==1){leftopen++;}
        if(arr2[i]==1){rightopen++;}
    }if((leftopen>rightopen)&&leftopen!=n){seconds=(n-leftopen+rightopen);}
    else if((rightopen>leftopen)&&rightopen!=n){seconds=(n-rightopen+leftopen);}
    else if(rightopen==n){seconds=n-leftopen;}
    else if(leftopen==n){seconds=n-rightopen;}
    cout << seconds;
    return 0;
}


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

int main()
{
    int n, a,b,leftopen=0,rightopen=0,seconds=0;
    vector<int> arr1;
    vector<int> arr2;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >>a>>b;
        arr1.push_back(a);
        arr2.push_back(b);
    }
    for(int i=0;i<n;i++)
    {
        if(arr1[i]==1){leftopen++;}
        if(arr2[i]==1){rightopen++;}
    }if(leftopen>=rightopen){seconds=(n-leftopen+rightopen);}
    else{seconds=(n-rightopen+leftopen);}
    cout << seconds<< endl;
    return 0;
}


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

int main()
{
    int n, a,b,lzero=0,lone=0,rzero=0,rone=0,seconds=0;
    vector<int> arr1;
    vector<int> arr2;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >>a>>b;
        arr1.push_back(a);
        arr2.push_back(b);
    }
    for(int i=0;i<n;i++)
    {
        if(arr1[i]==1){lone++;}else{lzero++;}
        if(arr2[i]==1){rone++;}else{rzero++;}
    }if(lone>=lzero){seconds+=lzero;}
    else{seconds+=lone;}
    if(rone>=rzero){seconds+=rzero;}
    else{seconds+=rone;}
    cout << seconds;
    return 0;
}


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

int main()
{
    int n, a,b,leftopen=0,rightopen=0,seconds=0;
    vector<int> arr1;
    vector<int> arr2;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >>a>>b;
        arr1.push_back(a);
        arr2.push_back(b);
    }
    for(int i=0;i<n;i++)
    {
        if(arr1[i]==1){leftopen++;}
        if(arr2[i]==1){rightopen++;}
    }if(left>=right){seconds+=(n-leftopen+rightopen);}
    else{seconds+=(n-rightopen+leftopen);}
    cout << seconds<< endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

void solve()
{
	int n,open,close;
	int openCount = 0,closeCount = 0;
	cin>> n;
	for(int i=0;i<n;i++){
		cin>> open >> close;
		openCount+=open;
		closeCount+=close;
	}
	if(closeCount > openCount){
		cout<<(n-closeCount)+openCount<<"\n";
	}
	else if (openCount < closeCount){
		cout<<(n-openCount)+closeCount<<"\n";
	}
	else{
		cout<<"0"<<"\n";
	}
}
int main()
{
	solve();
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

void solve()
{
	int n,open,close;
	int openCount = 0,closeCount = 0;
	cin>> n;
	for(int i=0;i<n;i++){
		cin>> open >> close;
		openCount+=open;
		closeCount+=close;
	}
	if(closeCount > openCount){
		cout<<(n-closeCount)+openCount<<"\n";
	}
	else{
		cout<<(n-openCount)+closeCount<<"\n";
}
}
int main()
{
	solve();
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

void solve()
{
	int n,open,close;
	int openCount = 0,closeCount = 0;
	cin>> n;
	for(int i=0;i<n;i++){
		cin>> open >> close;
		openCount+=open;
		closeCount+=close;
	}
	if(closeCount >= openCount){
		cout<<(n-closeCount)+openCount<<"\n";
	}
	else{
		cout<<(n-openCount)+closeCount<<"\n";
}
}
int main()
{
	solve();
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

int findMin(int a,int b)
{
	if (a <= b){
		return a;
	}
	else{
		return b;
	}
}

void solve()
{
	int n,open,close;
	int openCount = 0,closeCount = 0;
	cin>> n;
	for(int i=0;i<n;i++){
		cin>> open >> close;
		openCount+=open;
		closeCount+=close;
	}
	cout<<findMin(n-openCount,openCount) + findMin(n-closeCount,closeCount)<<"\n";

}
int main()
{
	solve();
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,c1=0,c2=0;
   cin>>n;
   for(int i=0;i<n;i++)
   {
       int l,r;
       cin>>l>>r;
       if(l==0)c1++;
       if(r==0)c2++;
   }
   cout<<min(c1,n-c1)+min(c2,n-c2);
   return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,c1=0,c2=0;
   cin>>n;
   while(n--)
   {
       int l,r;
       cin>>l>>r;
       if(l==0)c1++;
       else c2++;
       if(r==0)c2++;
       else c1++;
   }
   cout<<min(c1,c2);
   return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,c1,c2;
   cin>>n;
   while(n--)
   {
       int l,r;
       cin>>l>>r;
       if(l==0)c1++;
       else c2++;
       if(r==0)c2++;
       else c1++;
   }
   cout<<min(c1,c2);
   return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,c1=0,c2=0;
   cin>>n;
   while(n--)
   {
       int l,r;
       cin>>l>>r;
       if(l==0)c1++;
       else c2++;
       if(r==0)c2++;
       else c1++;
   }
   if(c1==c2)cout<<0;
   else cout<<min(c1,c2);
   return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,c1=0,c2=0;
   cin>>n;
   while(n--)
   {
       int l,r;
       cin>>l>>r;
       if(l==0)c1++;
       if(r==0)c2++;
   }

   int m=min(c1,n-c1)+min(c2,n-c2);
   cout<<m;
   return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,c1=0,c2=0;
   cin>>n;
   while(n--)
   {
       int l,r;
       cin>>l>>r;
       if(l==0)c1++;
       if(r==0)c2++;
   }
   cout<<min(c1,n-c1)+min(c2,n-c2);
   return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,c1,c2;
   cin>>n;
   while(n--)
   {
       int l,r;
       cin>>l>>r;
       if(l==0)c1++;
       else c2++;
       if(r==0)c2++;
       else c1++;
   }
   c1=min(c1,c2);
   cout<<c1;
   return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int l,r;
    for(int i=0;i<5;i++)
    {
        cin>>l;
        cin>>r;
        l+=l;
        r+=r;
    }
    cout<<min(l,n-l)+min(r,n-r);
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int l[n],r[n];
    for(int i=0;i<5;i++)
    {
        cin>>l[i];
        cin>>r[i];
    }
    cout<<(*min_element(l,l+n))+(*min_element(r,r+n));
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n
    int l[n],r[n];
    for(int i=0;i<n;i++)
    {
        cin>>l[i];
        cin>>r[i];
    }
    cout<<(*min_element(l,l+n))+(*min_element(r,r+n));
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int l=0,r=0;
    for(int i=1;i<=n*2;i++)
    {
        int temp;
        cin>>temp;
        if(i%2==0) r+=temp;
        else l+=temp;
    }
    cout<<l<<" "<<r<<endl;
    cout<<min(l,n-l)+min(r,n-r);
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int l=0,r=0;
    for(int i=1;i<=n*2;i++)
    {
        int temp;
        cin>>temp;
        if(i%2==0) r+=temp;
        else l+=temp;
    }
    cout<<min(l,n-l)+min(r,n-r);
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int l[n],r[n];
    for(int i=0;i<n;i++)
    {
        cin>>l[i];
        cin>>r[i];
    }
    cout<<(*min_element(l,l+n))+(*min_element(r,r+n));
}


#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;

int main()
{
   ll n,l,r,i,c=0,d=0,p=0,q=0,sum=0;
   cin>>n;

   for(i=1; i<=n; i++)
   {
       cin>>l;
       if(l==0)c++;
       else d++;

       cin>>r;
       if(r==0)p++;
       else q++;

   }
   if(c<=d)sum+=c;
   if(d<=c)sum+=d;
   if(p<=q)sum+=p;
   if(q<=p)sum+=q;

   cout<<sum;

    return 0;
}


#include <iostream>
using namespace std;
int min(int a,int b){
    return a>b?b:a;
}
int main() {
    int n;
    cin>>n;
    int left[10001],right[10001];
    for(int i=0;i<n;i++){
        cin>>left[i]>>right[i];
    }
    int c=0,d=0,p=0,q=0;
    for(int i=0;i<n;i++){
        if(right[i]==1){
            d++;
        }else{
            c++;
        }
    }
    int r=min(d,c);
    for(int i=0;i<n;i++){
        if(left[i]==1){
            q;
        }else{
            p++;
        }
    }
    r+=min(q,p);
    cout<<r;
	return 0;
}


#include <iostream>
using namespace std;
int min(int a,int b){
    return a>b?b:a;
}
int main() {
    int n;
    cin>>n;
    int left[10001],right[10001];
    for(int i=0;i<n;i++){
        cin>>left[i]>>right[i];
    }
    int r0=0,r1=0,l0=0,l1=0;
    for(int i=0;i<n;i++){
        if(right[i]==1){
            r1++;
        }else{
            r0++;
        }
    }
    int red=min(r1,r0);
    for(int i=0;i<n;i++){
        if(left[i]==1){
            l1++;
        }else{
            l0++;
        }
    }
    red+=min(l1,l0);
    cout<<red;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;

int main()
{
   ll n,l,r,i,c=0;
   cin>>n;
   for(i=1; i<=n; i++)
   {
       cin>>l;
       if(l==1)c++;
       cin>>r;
       if(r==0)c++;

   }
   cout<<c;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long n,r,l,sumr,suml,res,pr,pl,fr=1,fl=1;
int main()
{
	cin>>n;
	cin>>pr>>pl;
	sumr=pr;suml=pl;
	for(int i=1;i<n;i++)
	{
		cin>>r>>l;
		if(pr!=r&&fr)
			fr=0;
		if(pl!=l&&fl)
			fl=0;
		sumr+=r;
		suml+=l;
		pr=r;
		pl=l;
	}
	if(fl&&fr){
		cout<<"0"<<endl;
		return 0;
	}
	if(n!=max(sumr,suml)&&sumr!=suml){
		res=n-max(sumr,suml);
		res+=min(sumr,suml);
	}
	else if(sumr==suml)
	{
		res=2*(n-sumr);
	}
	else
	{
		res=n-min(sumr,suml);
	}
	cout<<res<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,ls,rs,c=0;
	cin>>n;
	int l[n],r[n];
	for(int i=0;i<n;i++)
	{
		cin>>l[i]>>r[i];
	}
	ls=accumulate(l,l+n,0);
	rs=accumulate(r,r+n,0);
	if(ls>(n/2))
		c+=(n-ls)
	else
		c+=ls;
	if(rs>=(n/2))
		c+=(n-rs);
	else
		c+=rs;

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,ls,rs,c=0;
	cin>>n;
	int l[n],r[n];
	for(int i=0;i<n;i++)
	{
		cin>>l[i]>>r[i];
	}
	ls=accumulate(l,l+n,0);
	rs=accumulate(r,r+n,0);
	if(ls>(n/2))
		c+=(n-ls);
	else
		c+=ls;
	if(rs>(n/2))
		c+=(n-rs);
	else
		c+=rs;

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,ls,rs,c=0;
	cin>>n;
	int l[n],r[n];
	for(int i=0;i<n;i++)
	{
		cin>>l[i]>>r[i];
	}
	ls=accumulate(l,l+n,0);
	rs=accumulate(r,r+n,0);
	if(ls>(n/2))
		c+=(n-ls)
	else
		c+=ls;
	if(rs>(n/2))
		c+=(n-rs)
	else
		c+=rs;

}


#include<bits/stdc++.h>
using namespace std;
long long n,r,l,sumr,suml,res;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>r>>l;
		sumr+=r;
		suml+=l;
	}
	res=n-max(sumr,suml);
	res+=min(sumr,suml);
	cout<<res<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long n,r,l,sumr,suml,res,pr,pl,fr=1,fl=1;
int main()
{
	cin>>n;
	cin>>pr>>pl;
	sumr=pr;suml=pl;
	for(int i=1;i<n;i++)
	{
		cin>>r>>l;
		if(pr!=r&&fr)
			fr=0;
		if(pl!=l&&fl)
			fl=0;
		sumr+=r;
		suml+=l;
		pr=r;
		pl=l;
	}
	if(fl&&fr){
		cout<<"0"<<endl;
		return 0;
	}
	res=n-max(sumr,suml);
	res+=min(sumr,suml);
	cout<<res<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,ls,rs,c=0;
	cin>>n;
	int l[n],r[n];
	for(int i=0;i<n;i++)
	{
		cin>>l[i]>>r[i];
	}
	ls=accumulate(l,l+n,0);
	rs=accumulate(r,r+n,0);
	if(ls>(n/2))
		c+=(n-ls);
	else
		c+=ls;
	if(rs>=(n/2))
		c+=(n-rs);
	else
		c+=rs;

}


#include<bits/stdc++.h>
using namespace std;
long long n,r,l,sumr,suml,res,pr,pl,fr=1,fl=1;
int main()
{
	cin>>n;
	cin>>pr>>pl;
	sumr=pr;suml=pl;
	for(int i=1;i<n;i++)
	{
		cin>>r>>l;
		if(pr!=r&&fr)
			fr=0;
		if(pl!=l&&fl)
			fl=0;
		sumr+=r;
		suml+=l;
		pr=r;
		pl=l;
	}
	if(fl&&fr){
		cout<<"0"<<endl;
		return 0;
	}
	if(n!=max(sumr,suml)){
		res=n-max(sumr,suml);
		res+=min(sumr,suml);
	}
	else
	{
		res=n-min(sumr,suml);
	}
	cout<<res<<endl;
	return 0;
}


#include <iostream>
using namespace std;

int main() {
	int n,l,r,sl=0,sr=0;
	cin >> n;
	int i,t;
	for(i=0;i<n;i++) {
		cin >> l >> r;
		sl=sl+l;
		sr=sr+r;
	}
	sr=n-sr;
	t=sl+sr;
	if(t<(n)) cout <<t;
	else cout << ((n*2)-t);
	return 0;
}


#include <iostream>
using namespace std;

int main() {
	int n,l,r,sl=0,sr=0;
	cin >> n;
	int i,t;
	for(i=0;i<n;i++) {
		cin >> l >> r;
		sl=sl+l;
		sr=sr+r;
	}
	// cout <<sl << " " <<sr<<"\n";
	sr=n-sr;
	t=sl+sr;
	if(t<(2*n)) cout <<t;
	else cout << ((n*2)-t);
	return 0;
}


#include <iostream>
using namespace std;

int main() {
	int n,l,r,sl=0,sr=0;
	cin >> n;
	int i,t;
	for(i=0;i<n;i++) {
		cin >> l >> r;
		sl=sl+l;
		sr=sr+r;
	}
	t=0;
	if(sl<=n/2) t=t+sl;
	else t=t+n-sl;
	if(sr<=n/2) t=t+sr;
	else t=t+n-sr;
	cout << t;
	return 0;
}


#include <iostream>
using namespace std;

int main() {
	int n,l,r,sl=0,sr=0;
	cin >> n;
	int i,t;
	for(i=0;i<n;i++) {
		cin >> l >> r;
		sl=sl+l;
		sr=sr+r;
	}
	// cout <<sl << " " <<sr<<"\n";
	sr=n-sr;
	t=sl+sr;
	if(t<(n)) cout <<t;
	else cout << ((n*2)-t);
	return 0;
}


#include <iostream>
using namespace std;

int main() {
	int n,l,r,sl=0,sr=0;
	cin >> n;
	int i,t;
	for(i=0;i<n;i++) {
		cin >> l >> r;
		sl=sl+l;
		sr=sr+r;
	}
	cout <<sl << " " <<sr<<"\n";
	sr=n-sr;
	t=sl+sr;
	if(t<(2*n)) cout <<t;
	else cout << ((n*2)-t);
	return 0;
}


#include<bits/stdc++.h>
#include<algorithm>
#define ll long long int
#define ull unsigned long long int
using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
ull n;
cin>>n;
ull l[n]={0},r[n]={0};
for(ull i=0;i<n;i++)
	cin>>l[i]>>r[i];
ull l_0=0,l_1=0,r_1=0,r_0=0;
for(ull i=0;i<n;i++)
{
	if(l[i]==1)
		l_1++;
	else
		l_0++;
	if(r[i]==1)
		r_1++;
	else
		r_0++;
}
	if(r_0==0&&l_0==0||r_1==0&&l_1==0)
		cout<<"0";
	else if(r_0==n||r_1==n||l_1==n||l_0==n)
	{
		if(r_0==n)
			cout<<n-l_1;
		else if(r_1==n)
			cout<<n-l_0;
		else if(l_0==n)
			cout<<n-r_1;
		else
			cout<<n-r_0;
	}
	else if(r_0<r_1)
		cout<<n-l_0+n-r_1;
	else if(r_1<r_0)
		cout<<n-l_1+n-r_0;
	else
	{
		if(r_0==r_1)
		{
			if(l_0==l_1)
				cout<<n;
			if(l_0>l_1)
			{
				cout<<n-l_0+n-r_1;
			}
			else
				cout<<n-l_1+n-r_0;
		}
		else if(l_0==l_1)
		{
			if(r_0==r_1)
				cout<<n;
			if(r_0>r_1)
				cout<<n-l_0+n-l_1;
			else
				cout<<n-r_1+n-l_0;
		}
	}

return 0;
}


#include<bits/stdc++.h>
#include<algorithm>
#define ll long long int
#define ull unsigned long long int
using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
ull n;
cin>>n;
ull l[n]={0},r[n]={0};
for(ull i=0;i<n;i++)
	cin>>l[i]>>r[i];
ull l_0=0,l_1=0,r_1=0,r_0=0;
for(ull i=0;i<n;i++)
{
	if(l[i]==1)
		l_1++;
	else
		l_0++;
	if(r[i]==1)
		r_1++;
	else
		r_0++;
}
	if(r_0==0&&l_0==0||r_1==0&&l_1==0)
		cout<<"0";
	else if(r_0<r_1)
		cout<<n-l_0+n-r_1;
	else if(r_1<r_0)
		cout<<n-l_1+n-r_0;
	else
	{
		if(r_0==r_1)
		{
			if(l_0==l_1)
				cout<<n;
			if(l_0>l_1)
			{
				cout<<n-l_0+n-r_1;
			}
			else
				cout<<n-l_1+n-r_0;
		}
		else if(l_0==l_1)
		{
			if(r_0==r_1)
				cout<<n;
			if(r_0>r_1)
				cout<<r-l_0+n-l_1;
			else
				cout<<n-r_1+n-l_0;
		}
	}

return 0;
}


#include<bits/stdc++.h>
#include<algorithm>
#define ll long long int
#define ull unsigned long long int
using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
ull n;
cin>>n;
ull l[n]={0},r[n]={0};
for(ull i=0;i<n;i++)
	cin>>l[i]>>r[i];
ull l_0=0,l_1=0,r_1=0,r_0=0;
for(ull i=0;i<n;i++)
{
	if(l[i]==1)
		l_1++;
	else
		l_0++;
	if(r[i]==1)
		r_1++;
	else
		r_0++;
}
	if(r_0==0&&l_0==0||r_1==0&&l_1==0||r_0==n&&l_1==n||r_1==n&&l_0==n)
		cout<<"0";
	else if(r_0==n||r_1==n||l_1==n||l_0==n)
	{
		if(r_0==n)
			cout<<n-l_0;
		else if(r_1==n)
			cout<<n-l_1;
		else if(l_0==n)
			cout<<n-r_0;
		else
			cout<<n-r_1;
	}
	else if(r_1==l_1&&l_0==r_0)
	{
	if(r_0<r_1)
		cout<<n-l_1+n-r_1;
	else if(r_1<r_0)
		cout<<n-l_0+n-r_0;
	}
	else if(r_0<r_1)
		cout<<n-l_0+n-r_1;
	else if(r_1<r_0)
		cout<<n-l_1+n-r_0;
	else
	{
		if(r_0==r_1)
		{
			if(l_0==l_1)
				cout<<n;
			else if(l_0>l_1)
			{
				cout<<n-l_0+n-r_1;
			}
			else
				cout<<n-l_1+n-r_0;
		}
		else if(l_0==l_1)
		{
			if(r_0==r_1)
				cout<<n;
			else if(r_0>r_1)
				cout<<n-l_0+n-l_1;
			else
				cout<<n-r_1+n-l_0;
		}
	}

return 0;
}


#include<bits/stdc++.h>
#include<algorithm>
#define ll long long int
#define ull unsigned long long int
using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
ull n;
cin>>n;
ull l[n]={0},r[n]={0};
for(ull i=0;i<n;i++)
	cin>>l[i]>>r[i];
ull l_0=0,l_1=0,r_1=0,r_0=0;
for(ull i=0;i<n;i++)
{
	if(l[i]==1)
		l_1++;
	else
		l_0++;
	if(r[i]==1)
		r_1++;
	else
		r_0++;
}
	if(r_0==0&&l_0==0||r_1==0&&l_1==0)
		cout<<"0";
	else if(r_0==n||r_1==n||l_1==n||l_0==n)
	{
		if(r_0==n)
			cout<<n-l_1;
		else if(r_1==n)
			cout<<n-l_0;
		else if(l_0==n)
			cout<<n-r_1;
		else
			cout<<n-r_0;
	}
	else if(r_1==l_1&&l_0==r_0)
	{
	if(r_0<r_1)
		cout<<n-l_1+n-r_1;
	else if(r_1<r_0)
		cout<<n-l_0+n-r_0;
	}
	else if(r_0<r_1)
		cout<<n-l_0+n-r_1;
	else if(r_1<r_0)
		cout<<n-l_1+n-r_0;
	else
	{
		if(r_0==r_1)
		{
			if(l_0==l_1)
				cout<<n;
			else if(l_0>l_1)
			{
				cout<<n-l_0+n-r_1;
			}
			else
				cout<<n-l_1+n-r_0;
		}
		else if(l_0==l_1)
		{
			if(r_0==r_1)
				cout<<n;
			else if(r_0>r_1)
				cout<<n-l_0+n-l_1;
			else
				cout<<n-r_1+n-l_0;
		}
	}

return 0;
}


#include<bits/stdc++.h>
#include<algorithm>
#define ll long long int
#define ull unsigned long long int
using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
ull n;
cin>>n;
ull l[n]={0},r[n]={0};
for(ull i=0;i<n;i++)
	cin>>l[i]>>r[i];
ull l_0=0,l_1=0,r_1=0,r_0=0;
for(ull i=0;i<n;i++)
{
	if(l[i]==1)
		l_1++;
	else
		l_0++;
	if(r[i]==1)
		r_1++;
	else
		r_0++;
}
	if(r_0==0&&l_0==0||r_1==0&&l_1==0)
		cout<<"0";
	else if(r_0==n||r_1==n||l_1==n||l_0==n)
	{

		if(r_0==n)
			cout<<n-l_1;
		else if(r_1==n)
			cout<<n-l_1;
		else if(l_0==n)
			cout<<n-r_1;
		else
			cout<<n-r_1;
	}
	else if(r_0<r_1)
		cout<<n-l_1+n-r_1;
	else if(r_1<r_0)
		cout<<n-l_0+n-r_0;
	else
	{

		if(r_0==r_1)
		{
			if(l_0==l_1)
				cout<<n;
			else if(l_0>l_1)
			{
				cout<<n-l_0+n-r_1;
			}
			else
				cout<<n-l_1+n-r_0;
		}
		else if(l_0==l_1)
		{
			if(r_0==r_1)
				cout<<n;
			else if(r_0>r_1)
				cout<<n-l_0+n-l_1;
			else
				cout<<n-r_1+n-l_0;
		}
	}

return 0;
}


#include<bits/stdc++.h>
#include<algorithm>
#define ll long long int
#define ull unsigned long long int
using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
ull n;
cin>>n;
ull l[n]={0},r[n]={0};
for(ull i=0;i<n;i++)
	cin>>l[i]>>r[i];
ull l_0=0,l_1=0,r_1=0,r_0=0;
for(ull i=0;i<n;i++)
{
	if(l[i]==1)
		l_1++;
	else
		l_0++;
	if(r[i]==1)
		r_1++;
	else
		r_0++;
}
	if(r_0==0&&l_0==0||r_1==0&&l_1==0)
		cout<<"0";
	else if(r_0==n||r_1==n||l_1==n||l_0==n)
	{
		if(r_0==n)
			cout<<n-l_1;
		else if(r_1==n)
			cout<<n-l_1;
		else if(l_0==n)
			cout<<n-r_1;
		else
			cout<<n-r_1;
	}
	else if(r_0<r_1)
		cout<<n-l_0+n-r_1;
	else if(r_1<r_0)
		cout<<n-l_1+n-r_0;
	else
	{
		if(r_0==r_1)
		{
			if(l_0==l_1)
				cout<<n;
			if(l_0>l_1)
			{
				cout<<n-l_0+n-r_1;
			}
			else
				cout<<n-l_1+n-r_0;
		}
		else if(l_0==l_1)
		{
			if(r_0==r_1)
				cout<<n;
			if(r_0>r_1)
				cout<<n-l_0+n-l_1;
			else
				cout<<n-r_1+n-l_0;
		}
	}

return 0;
}


#include<bits/stdc++.h>
#include<algorithm>
#define ll long long int
#define ull unsigned long long int
using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
ull n;
cin>>n;
ull l[n]={0},r[n]={0};
for(ull i=0;i<n;i++)
	cin>>l[i]>>r[i];
ull l_0=0,l_1=0,r_1=0,r_0=0;
for(ull i=0;i<n;i++)
{
	if(l[i]==1)
		l_1++;
	else
		l_0++;
	if(r[i]==1)
		r_1++;
	else
		r_0++;
}
	if(r_0==0&&l_0==0||r_1==0&&l_1==0)
		cout<<"0";
	else if(r_0==n||r_1==n||l_1==n||l_0==n)
	{
		if(r_0==n)
			cout<<n-l_0;
		else if(r_1==n)
			cout<<n-l_1;
		else if(l_0==n)
			cout<<n-r_0;
		else
			cout<<n-r_1;
	}
	else if(r_1==l_1&&l_0==r_0)
	{
	if(r_0<r_1)
		cout<<n-l_1+n-r_1;
	else if(r_1<r_0)
		cout<<n-l_0+n-r_0;
	}
	else if(r_0<r_1)
		cout<<n-l_0+n-r_1;
	else if(r_1<r_0)
		cout<<n-l_1+n-r_0;
	else
	{
		if(r_0==r_1)
		{
			if(l_0==l_1)
				cout<<n;
			else if(l_0>l_1)
			{
				cout<<n-l_0+n-r_1;
			}
			else
				cout<<n-l_1+n-r_0;
		}
		else if(l_0==l_1)
		{
			if(r_0==r_1)
				cout<<n;
			else if(r_0>r_1)
				cout<<n-l_0+n-l_1;
			else
				cout<<n-r_1+n-l_0;
		}
	}

return 0;
}


#include<bits/stdc++.h>
#include<algorithm>
#define ll long long int
#define ull unsigned long long int
using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
ull n;
cin>>n;
ull l[n]={0},r[n]={0};
for(ull i=0;i<n;i++)
	cin>>l[i]>>r[i];
ull l_0=0,l_1=0,r_1=0,r_0=0;
for(ull i=0;i<n;i++)
{
	if(l[i]==1)
		l_1++;
	else
		l_0++;
	if(r[i]==1)
		r_1++;
	else
		r_0++;
}
	if(r_0<r_1)
		cout<<n-l_0+n-r_1;
	else if(r_1<r_0)
		cout<<n-l_1+n-r_0;
	else
	{
		if(r_0==r_1)
		{
			if(l_0==l_1)
				cout<<n;
			if(l_0>l_1)
			{
				cout<<n-l_0+n-r_1;
			}
			else
				cout<<n-l_1+n-r_0;
		}
		else if(l_0==l_1)
		{
			if(r_0==r_1)
				cout<<n;
			if(r_0>r_1)
				cout<<r-l_0+n-l_1;
			else
				cout<<n-r_1+n-l_0;
		}
	}

return 0;
}


#include <bits/stdc++.h>
#define int long long
#define ll long long
#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

signed main()
{
    int n;
    cin >> n;
    vector<pair<int, int>> v(n);
    rep(i, 0, n)
    {
        int a, b;
        cin >> a >> b;
        v[i] = {a, b};
    }
    int x = 0;
    rep(i, 0, n)
    {
        if (v[i].first == 1)
            x++;
        if (v[i].second == 0)
            x++;
    }
    int y = 0;
    rep(i, 0, n)
    {
        if (v[i].first == 0)
            y++;
        if (v[i].second == 1)
            y++;
    }
    int a = 0;
    rep(i, 0, n)
    {
        if (v[i].first == 1)
            a++;
        if (v[i].second == 1)
            a++;
    }
    int b = 0;
    rep(i, 0, n)
    {
        if (v[i].first == 1)
            b++;
        if (v[i].second == 1)
            b++;
    }
    cout << min({x, y, a, b});
    return 0;
}


#include <bits/stdc++.h>
#define int long long
#define ll long long
#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

signed main()
{
    int n;
    cin >> n;
    vector<pair<int, int>> v(n);
    rep(i, 0, n)
    {
        int a, b;
        cin >> a >> b;
        v[i] = {a, b};
    }
    int x = 0;
    rep(i, 0, n)
    {
        if (v[i].first == 1)
            x++;
        if (v[i].second == 0)
            x++;
    }
    int y = 0;
    rep(i, 0, n)
    {
        if (v[i].first == 0)
            y++;
        if (v[i].second == 1)
            y++;
    }
    int a = 0;
    rep(i, 0, n)
    {
        if (v[i].first == 0)
            a++;
        if (v[i].second == 0)
            a++;
    }
    int b = 0;
    rep(i, 0, n)
    {
        if (v[i].first == 1)
            b++;
        if (v[i].second == 1)
            b++;
    }
    cout << min({x, y, a, b});
    return 0;
}


#include <bits/stdc++.h>
#define int long long
#define ll long long
#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

signed main()
{
    int n;
    cin >> n;
    int left0 = 0, right0 = 0, left1 = 0, right1 = 0;
    rep(i, 0, n)
    {
        int a, b;
        cin >> a >> b;
        if (a == 0)
            left0++;
        else left1++;
        if (b == 0)
            right0++;
        else right1++;
    }
    cout << min(left0, left1) + min(right0, right1);
    return 0;
}


#include <bits/stdc++.h>
#define int long long
#define ll long long
#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

signed main()
{
    int n;
    cin >> n;
    vector<pair<int, int>> v(n);
    rep(i, 0, n)
    {
        int a, b;
        cin >> a >> b;
        v[i] = {a, b};
    }
    int x = 0;
    rep(i, 0, n)
    {
        if (v[i].first == 1)
            x++;
        if (v[i].second == 0)
            x++;
    }
    int y = 0;
    rep(i, 0, n)
    {
        if (v[i].first == 0)
            y++;
        if (v[i].second == 1)
            y++;
    }
    cout << min(x, y);
    return 0;
}


#include <bits/stdc++.h>
#define int long long
#define ll long long
#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

signed main()
{
    int n;
    cin >> n;
    int left0 = 0, right0 = 0, left1 = 0, right1 = 1;
    rep(i, 0, n)
    {
        int a, b;
        cin >> a >> b;
        if (a == 0)
            left0++;
        else left1++;
        if (b == 0)
            right0++;
        else right1++;
    }
    cout << min(left0, left1) + min(right0, right1);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    int counta=0;
    int countb=0;
    int j=0;
    while(n--){
        int a[n],b[n];
        cin>>a[j]>>b[j];
        if(a[j]==0){
            counta++;
        }
        if(b[j]==0){
            countb++;
        }
        j++;
    }
    int temp=0;
    if(counta>countb){
      temp+=n-counta;
    }
    else{
        temp+=n-countb;
    }
    cout<<abs(temp);

}


#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    int q=n;
    int counta0=0;
    int countb0=0;
    while(n--){
        int x,y;
        cin>>x>>y;
        if(x==0){
            counta0++;
        }
        if(y==0){
            countb0++;
        }

    }
    int temp=0;
    int counta1;
    int countb1;
    counta1=abs(q-counta0);
    countb1=abs(q-countb0);
    // cout<<counta0<<" "<<counta1<<endl;
    // cout<<countb0<<" "<<countb1<<endl;
    if(counta0>countb0){
        temp=temp+counta1+countb0;
    }

     if(counta0<=countb0){
        temp=temp+counta0+countb1;
    }
    cout<<temp;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    int q=n;
    int counta0=0;
    int countb0=0;
    while(n--){
        int x,y;
        cin>>x>>y;
        if(x==0){
            counta0++;
        }
        if(y==0){
            countb0++;
        }

    }
    int temp=0;
    int counta1;
    int countb1;
    counta1=abs(q-counta0);
    countb1=abs(q-countb0);
    // cout<<counta0<<" "<<counta1<<endl;
    // cout<<countb0<<" "<<countb1<<endl;
    if(counta0>countb0){
        temp=temp+counta1+countb0;
    }

     if(counta0<countb0){

        temp=temp+counta0+countb1;
    }
    if(counta0==countb0){
        if(counta1==0&&countb1==0){
            cout<<0;
            return 0;
        }
    }
    cout<<temp;
}


#include <iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int l_count0=0,l_count1=0,R_count0=0,R_count1=0;
int l,r;
for(int i=0;i<n;i++)
{
cin>>l>>r;
if(l==0)
  {
    l_count0++;
  }
else
  {
    l_count1++;
   }
if(r==0)
   {
    R_count0++;
   }
else
  {
    R_count1++;
  }
}
int ans=min(l_count0,l_count1)+min(R_count0,R_count1);
cout<<ans;

return 0;
}


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

void solve(){
    vector<int> right = {};
    vector<int> left = {};
    int n, l, r;
    cin >> n;
    const int t = n;
    while(n--){
        cin >> l >> r;
        if(r == 1){
            right.push_back(1);
        }
        if(l == 1){
            left.push_back(1);
        }
    }

    if(t - right.size() > t - left.size()){
        cout << t - left.size() + right.size();
    }else{
        cout << t - right.size() + left.size();
    }
}

int main(int argc, char const *argv[])
{
    solve();
    return 0;
}


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

void solve(){
    vector<int> right = {};
    vector<int> left = {};
    int n, l, r;
    cin >> n;
    const int t = n;
    while(n--){
        cin >> l >> r;
        if(r == 1){
            right.push_back(1);
        }
        if(l == 1){
            left.push_back(1);
        }
    }
    int total = 0;
    if(t - right.size() <= t/2){
        total +=  t - right.size();
    }else{
        total += right.size();
    }

    if(t - left.size() <= t/2){
        total += t - left.size();
    }else{
        total += left.size();
        }
        cout << left.size() << " " << right.size() << endl;
        cout << total;
}

int main(int argc, char const *argv[])
{
    solve();
    return 0;
}


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

void solve(){
    vector<int> right = {};
    vector<int> left = {};
    int n, l, r;
    cin >> n;
    const int t = n;
    while(n--){
        cin >> l >> r;
        if(r == 1){
            right.push_back(1);
        }
        if(l == 1){
            left.push_back(1);
        }
    }
    int total = 0;
    if(t - right.size() <= t/2){
        total +=  t - right.size();
    }else{
        total += right.size();
    }

    if(t - left.size() <= t/2){
        total += t - left.size();
    }else{
        total += left.size();
        }
//        cout << left.size() << " " << right.size() << endl;
        cout << total;
}

int main(int argc, char const *argv[])
{
    solve();
    return 0;
}


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

void solve(){
    vector<int> right = {};
    vector<int> left = {};
    int n, l, r;
    cin >> n;
    const int t = n;
    while(n--){
        cin >> l >> r;
        if(r == 1){
            right.push_back(1);
        }
        if(l == 1){
            left.push_back(1);
        }
    }
    int total = 0;
    if(t - right.size() < t/2){
        total +=  t - right.size();
    }else{
        total += right.size();
    }

    if(t - left.size() < t/2){
        total += t - left.size();
    }else{
        total += left.size();
        }
        cout << total;
}

int main(int argc, char const *argv[])
{
    solve();
    return 0;
}


#include<iostream>
using namespace std;
int main()
{
int n, right[1000], left[1000],count=0;
cin>>n;
for(int i=0;i<n;i++)
{
    cin>>left[i]>>right[i];
    if(left[i]==1)
{
        count++;
}
    if(right[i]==0)
{
        count++;
}
}
cout<<count;
}


#include<iostream>
using namespace std;
#include<algorithm>
int main()
{
int n, right[1000], left[1000],l0=0,l1=0,r0=0,r1=0,count;
cin>>n;
for(int i=0;i<n;i++)
{
    cin>>left[i]>>right[i];
    if(left[i]==1)
{
        l1++;
}
    else
    {
        l0++;
    }
    if(right[i]==0)
{
        r0++;
}
    else
    {
        r1++;
    }
}
count=min(l1,l0);
count+=min(r0,r1);
cout<<count;
}


#include<iostream>
using namespace std;
#include<algorithm>
int main()
{
int n, right[10000], left[10000],l0=0,l1=0,r0=0,r1=0,count;
cin>>n;
for(int i=0;i<n;i++)
{
    cin>>left[i]>>right[i];
    if(left[i]==1)
{
        l1++;
}
    else
    {
        l0++;
    }
    if(right[i]==0)
{
        r0++;
}
    else
    {
        r1++;
    }
}
count=min(l1,l0);
count+=min(r0,r1);
cout<<count;
}


#include <iostream>
using namespace std;

int main() {
    int n,count=0,m;
    cin>>n;
    for(int i=0;i<2*n;i++)
    {
        cin>>m;
        if(i%2==0 && m==1)
        {
            count++;
        }
        else if(i%2!=0 && m==0)
        {
         count++;
        }
    }
cout<<count;
}


#include <bits/stdc++.h>

using namespace std;

int first_operation(int f, int arr_l[], int arr_r[]) {
    int left_ct = 0, right_ct = 0;
    for(int q = 0; q < f; q++) {
        if(arr_l[q] == 1) {
            left_ct++;
        }
    }
    for(int q = 0; q < f; q++) {
        if(arr_r[q] == 0) {
            right_ct++;
        }
    }

    int res = left_ct + right_ct;
    return res;

}

int second_operation(int f, int arr_l[], int arr_r[]) {
    int left_ct = 0, right_ct = 0;
    for(int q = 0; q < f; q++) {
        if(arr_l[q] == 0) {
            left_ct++;
        }
    }
    for(int q = 0; q < f; q++) {
        if(arr_r[q] == 1) {
            right_ct++;
        }
    }

    int res = left_ct + right_ct;
    return res;

}

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);

    unordered_map<int, int> mp_left;
    unordered_map<int, int> mp_right;

    int n, t = 0;
    cin >> n;
    int x;
    int arr_left[n];
    int arr_right[n];
    int arr_all[n*2];

    for(int i = 0; i < n*2; i++) {
        cin >> x;
        arr_all[i] = x;
    }

    for(int i = 0; i < n; i++) {
        arr_left[i] = arr_all[i*2];
    }

    for(int i = 0; i < n; i++) {
        arr_right[i] = arr_all[2*i + 1];
    }

    for(int e = 0; e < n; e++) {
        mp_left[arr_left[e]]++;
    }

    for(int e = 0; e < n; e++) {
        mp_right[arr_right[e]]++;
    }

    if(mp_left[0] > mp_right[0]) {
        t += first_operation(n, arr_left, arr_right);
        cout << t;
    } else if(mp_left[0] < mp_right[0]) {
        t += second_operation(n, arr_left, arr_right);
        cout << t;
    } else {
        t += first_operation(n, arr_left, arr_right);
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n, lsum = 0, rsum = 0, ans = 0;
    cin >> n;
    int left[n], right[n];
    for(int i = 1, lc = 0, rc = 0; i <= 2*n; i++) {
        if(i % 2 != 0) {
            cin >> left[lc++];
            lsum += left[lc-1];
        } else if(i % 2 == 0) {
            cin >> right[rc++];
            rsum += right[rc-1];
        }
    }
    if(n % 2 != 0) {
        int mid = n/2;
        if(lsum > mid) {
            int still_to_open = n - lsum;
            ans += still_to_open;
        } else {
            ans += lsum;
        }
        if(rsum > mid) {
            int still_to_open = n - rsum;
            ans += still_to_open;
        } else {
            ans += rsum;
        }
    } else {
        int mid = n/2;
        if(lsum == mid) {
            ans += lsum;
        } else if(lsum > mid) {
            int still_to_open = n - lsum;
            ans += still_to_open;
        } else {
            ans += lsum;
        }
        if(rsum == mid) {
            ans += rsum;
        } else if(rsum > mid) {
            int still_to_open = n - rsum;
            ans += still_to_open;
        } else {
            ans += rsum;
        }
    }

    cout << ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n, lsum = 0, rsum = 0, ans = 0;
    cin >> n;
    int left[n], right[n];
    for(int i = 1, lc = 0, rc = 0; i <= 2*n; i++) {
        if(i % 2 != 0) {
            cin >> left[lc++];
            lsum += left[lc-1];
        } else if(i % 2 == 0) {
            cin >> right[rc++];
            rsum += right[rc-1];
        }
    }
    if(n % 2 != 0) {
        int mid = n/2;
        if(lsum > mid) {
            int still_to_open = n - lsum;
            ans += still_to_open;
        } else {
            ans += lsum;
        }
        if(rsum > mid) {
            int still_to_open = n - rsum;
            ans += still_to_open;
        } else {
            ans += rsum;
        }
    } else {
        int mid = n/2;
        if(lsum == mid) {
            ans += lsum;
        } else if(lsum > mid) {
            int still_to_open = n - lsum;
            ans += still_to_open;
        } else {
            ans += lsum;
        }
        if(rsum == mid) {
            ans += rsum;
        } else if(rsum > mid) {
            int still_to_open = n - rsum;
            ans += still_to_open;
        } else {
            ans += rsum;
        }
    }

    cout << ans << " " << lsum << " " << rsum;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int first_operation(int f, int arr_l[], int arr_r[]) {
    int left_ct = 0, right_ct = 0;
    for(int q = 0; q < f; q++) {
        if(arr_l[q] == 1) {
            left_ct++;
        }
    }
    for(int q = 0; q < f; q++) {
        if(arr_r[q] == 0) {
            right_ct++;
        }
    }

    int res = left_ct + right_ct;
    return res;

}

int second_operation(int f, int arr_l[], int arr_r[]) {
    int left_ct = 0, right_ct = 0;
    for(int q = 0; q < f; q++) {
        if(arr_l[q] == 0) {
            left_ct++;
        }
    }
    for(int q = 0; q < f; q++) {
        if(arr_r[q] == 1) {
            right_ct++;
        }
    }

    int res = left_ct + right_ct;
    return res;

}

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);

    unordered_map<int, int> mp_left;
    unordered_map<int, int> mp_right;

    int n, t = 0;
    cin >> n;
    int x;
    int arr_left[n];
    int arr_right[n];
    int arr_all[n*2];

    for(int i = 0; i < n*2; i++) {
        cin >> x;
        arr_all[i] = x;
    }

    for(int i = 0; i < n; i++) {
        arr_left[i] = arr_all[i*2];
    }

    for(int i = 0; i < n; i++) {
        arr_right[i] = arr_all[2*i + 1];
    }

    for(int e = 0; e < n; e++) {
        mp_left[arr_left[e]]++;
    }

    for(int e = 0; e < n; e++) {
        mp_right[arr_right[e]]++;
    }

    if(mp_left[0] > mp_right[0]) {
        t += first_operation(n, arr_left, arr_right);
        cout << t;
    } else if(mp_left[0] < mp_right[0]) {
        t += second_operation(n, arr_left, arr_right);
        cout << t;
    } else {
        t += first_operation(n, arr_left, arr_right);
        cout << t;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int first_operation(int f, int arr_l[], int arr_r[]) {
    int left_ct = 0, right_ct = 0;
    for(int q = 0; q < f; q++) {
        if(arr_l[q] == 1) {
            left_ct++;
        }
    }
    for(int q = 0; q < f; q++) {
        if(arr_r[q] == 0) {
            right_ct++;
        }
    }

    int res = left_ct + right_ct;
    return res;

}

int second_operation(int f, int arr_l[], int arr_r[]) {
    int left_ct = 0, right_ct = 0;
    for(int q = 0; q < f; q++) {
        if(arr_l[q] == 0) {
            left_ct++;
        }
    }
    for(int q = 0; q < f; q++) {
        if(arr_r[q] == 1) {
            right_ct++;
        }
    }

    int res = left_ct + right_ct;
    return res;

}

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);

    unordered_map<int, int> mp_left;
    unordered_map<int, int> mp_right;

    int n, t = 0;
    cin >> n;
    int x;
    int arr_left[n];
    int arr_right[n];
    int arr_all[n*2];

    for(int i = 0; i < n*2; i++) {
        cin >> x;
        arr_all[i] = x;
    }

    for(int i = 0; i < n; i++) {
        arr_left[i] = arr_all[i*2];
    }

    for(int i = 0; i < n; i++) {
        arr_right[i] = arr_all[2*i + 1];
    }

    for(int e = 0; e < n; e++) {
        mp_left[arr_left[e]]++;
    }

    for(int e = 0; e < n; e++) {
        mp_right[arr_right[e]]++;
    }

    if(mp_left[0] > mp_right[0]) {
        t += first_operation(n, arr_left, arr_right);
        cout << t;
    } else if(mp_left[0] < mp_right[0]) {
        t += second_operation(n, arr_left, arr_right);
        cout << t;
    } else {
        cout << 0;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int first_operation(int f, int arr_l[], int arr_r[]) {
    int left_ct = 0, right_ct = 0;
    for(int q = 0; q < f; q++) {
        if(arr_l[q] == 1) {
            left_ct++;
        }
    }
    for(int q = 0; q < f; q++) {
        if(arr_r[q] == 0) {
            right_ct++;
        }
    }

    int res = left_ct + right_ct;
    return res;

}

int second_operation(int f, int arr_l[], int arr_r[]) {
    int left_ct = 0, right_ct = 0;
    for(int q = 0; q < f; q++) {
        if(arr_l[q] == 0) {
            left_ct++;
        }
    }
    for(int q = 0; q < f; q++) {
        if(arr_r[q] == 1) {
            right_ct++;
        }
    }

    int res = left_ct + right_ct;
    return res;

}

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);

    unordered_map<int, int> mp_left;
    unordered_map<int, int> mp_right;

    int n, t = 0;
    cin >> n;
    int x;
    int arr_left[n];
    int arr_right[n];
    int arr_all[n*2];

    for(int i = 0; i < n*2; i++) {
        cin >> x;
        arr_all[i] = x;
    }

    for(int i = 0; i < n; i++) {
        arr_left[i] = arr_all[i*2];
    }

    for(int i = 0; i < n; i++) {
        arr_right[i] = arr_all[2*i + 1];
    }

    for(int e = 0; e < n; e++) {
        mp_left[arr_left[e]]++;
    }

    for(int e = 0; e < n; e++) {
        mp_right[arr_right[e]]++;
    }

    if(mp_left[0] > mp_right[0]) {
        t += first_operation(n, arr_left, arr_right);
        cout << t;
    } else if(mp_left[0] < mp_right[0]) {
        t += second_operation(n, arr_left, arr_right);
        cout << t;
    }

    return 0;
}


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

int main()
{
   int n,left=0,right=0,sum=0,lzero=0,lone=0,rzero=0,rone=0,ladjust=0,radjust=0;
   cin >> n;
   int l[n],r[n];
    for (int i = 0; i <n ; ++i)
    {
        cin >> l[i] >> r[i];
    }
    for (int i = 0; i <n ; ++i) {
        if (l[i]==0)
            lzero++;
        else if(l[i]==1)
            lone++;
    }
    for (int i = 0; i <n ; ++i) {
        if(r[i]==1)
            rone++;
        else if(r[i]==0)
            rzero++;
    }
   if (lzero>lone)
       ladjust = n-lzero;
   else if (lzero<lone)
       ladjust = n-lone;
   else if(lzero==lone)
       ladjust = n-lzero;
    if (rzero>rone)
        radjust = n-rzero;
    else if (rzero<rone)
        radjust = n-rone;
    else if(rzero==rone)
        radjust = n-rzero;
    cout << radjust+ladjust << endl;
}


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

int main()
{
   int n,left=0,right=0,sum=0,lzero=0,lone=0,rzero=0,rone=0,ladjust=0,radjust=0;
   cin >> n;
   int l[n],r[n];
    for (int i = 0; i <n ; ++i)
    {
        cin >> l[i] >> r[i];
    }
    for (int i = 0; i <n ; ++i) {
        if (l[i]==0)
            lzero++;
        else if(l[i]==1)
            lone++;
    }
    for (int i = 0; i <n ; ++i) {
        if(r[i]==1)
            rone++;
        else if(r[i]==0)
            rzero++;
    }
   if (lzero>lone)
       ladjust = n-lzero;
   else if (lzero<lone)
       ladjust = n-lone;
    if (rzero>rone)
        radjust = n-rzero;
    else if (rzero<rone)
        radjust = n-rone;
    cout << radjust+ladjust << endl;
}


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

int main()
{
   int n,left=0,right=0,sum=0,lzero=0,lone=0,rzero=0,rone=0,ladjust=0,radjust=0;
   cin >> n;
   int l[n],r[n];
    for (int i = 0; i <n ; ++i)
    {
        cin >> l[i] >> r[i];
    }
    for (int i = 0; i <n ; ++i) {
        if (l[i]==0)
            lzero++;
        else if(l[i]==1)
            lone++;
    }
    for (int i = 0; i <n ; ++i) {
        if(r[i]==1)
            rone++;
        else if(r[i]==0)
            rzero++;
    }
   if (lzero>lone)
       ladjust = lzero-n;
   else if (lzero<lone)
       ladjust = lone-n;
    if (rzero>rone)
        radjust = rzero-n;
    else if (rzero<rone)
        radjust = rone-n;
    sum = abs(ladjust+radjust);
    cout << sum << endl;
}


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

int main()
{
   int n,left=0,right=0,sum=0,lzero=0,lone=0,rzero=0,rone=0,ladjust=0,radjust=0;
   cin >> n;
   int l[n],r[n];
    for (int i = 0; i <n ; ++i)
    {
        cin >> l[i] >> r[i];
    }
    for (int i = 0; i <n ; ++i) {
        if (l[i]==0)
            lzero++;
        else if(l[i]==1)
            lone++;
    }
    for (int i = 0; i <n ; ++i) {
        if(r[i]==1)
            rone++;
        else if(r[i]==0)
            rzero++;
    }
   if (lzero>lone)
       ladjust = n-lzero;
   else if (lzero<lone)
       ladjust = n-lone;
   else if(lzero==rzero)
       ladjust = n-lzero
    if (rzero>rone)
        radjust = n-rzero;
    else if (rzero<rone)
        radjust = n-rone;
    else if(rzero==rone)
        radjust = n-rzero;
    cout << radjust+ladjust << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pint;

int main() {
    int n;
    cin >> n;
    int l[n], r[n];
    for (int i = 0; i < n; i++) {
        cin >> l[i] >> r[i];
    }
    int ctr0 = 0, ctr1 = 0;
    for (int i = 0; i < n; i++) {
        if (l[i] == 0)
            ctr0++;
        else
            ctr1++;
    }
    if (ctr0 == n || ctr1 == n) {
        cout << 0;
    } else {
        int d = min(ctr0, ctr1);
        int res = 0;
        if (d == ctr0)
            res = 1;
        else
            res = 0;
        int ctr3 = 0, ctr2 = 0;
        for (int i = 0; i < n; i++) {
            if (r[i] == res)
                ctr2++;
        }
        cout << ctr2 + d;
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pint;

int main() {
    int n;
    cin >> n;
    int l[n], r[n];
    for (int i = 0; i < n; i++) {
        cin >> l[i] >> r[i];
    }
    int ctr0 = 0, ctr1 = 0;
    for (int i = 0; i < n; i++) {
        if (l[i] == 0)
            ctr0++;
        else
            ctr1++;
    }
    int d = min(ctr0, ctr1);
    int res = 0;
    if (d == ctr0)
        res = 1;
    else
        res = 0;
    int ctr3 = 0, ctr2 = 0;
    for (int i = 0; i < n; i++) {
        if (r[i] == res)
            ctr2++;
    }
    cout << ctr2 + d;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pint;

int main() {
    int n;
    cin >> n;
    int l[n], r[n];
    for (int i = 0; i < n; i++) {
        cin >> l[i] >> r[i];
    }
    int ctr0 = 0, ctr1 = 0, ctrr1 = 0, ctrl = 0;
    for (int i = 0; i < n; i++) {
        if (l[i] == 0)
            ctr0++;
        else
            ctr1++;
    }
    for (int i = 0; i < n; i++) {
        if (r[i] == 0)
            ctrl++;
        else
            ctrr1++;
    }
    if (ctr0 == n || ctr1 == n) {
        cout << 0;
    } else {
        int d = min(ctr0, ctr1);
        int res = 0;
        if (d == ctr0)
            res = 1;
        else
            res = 0;
        int ctr2 = 0;
        for (int i = 0; i < n; i++) {
            if (r[i] == res)
                ctr2++;
        }
        int e = min(ctrr1, ctrl);
        int res1 = 0;
        if (d == ctrl)
            res1 = 1;
        else
            res1 = 0;
        int ctr3 = 0;
        for (int i = 0; i < n; i++) {
            if (l[i] == res1)
                ctr3++;
        }
        cout << min(ctr2 + d, ctr3 + e);
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pint;

int main() {
    int n;
    cin >> n;
    int l, r;
    int left = 0, right = 0;
    for (int i = 0; i < n; i++) {
        cin >> l >> r;
        left += l;
        right += r;
    }
    cout << min(left, n - left) + min(right, n - right);
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pint;

int main() {
    int n;
    cin >> n;
    int l[n], r[n];
    for (int i = 0; i < n; i++) {
        cin >> l[i] >> r[i];
    }
    int ctr = 0;
    for (int i = 0; i < n; i++) {
        if (l[i] == 0 && r[i] == 1)
            ctr++;
        else if (l[i] == 1 && r[i] == 0)
            ctr++;
    }
    cout << ctr;
//    int ctr0 = 0, ctr1 = 0;
//    for (int i = 0; i < n; i++) {
//        if (l[i] == 0)
//            ctr0++;
//        else
//            ctr1++;
//    }
//    if (ctr0 == n || ctr1 == n) {
//        cout << 0;
//    } else {
//        int d = min(ctr0, ctr1);
//        int res = 0;
//        if (d == ctr0)
//            res = 1;
//        else
//            res = 0;
//        int ctr3 = 0, ctr2 = 0;
//        for (int i = 0; i < n; i++) {
//            if (r[i] == res)
//                ctr2++;
//        }
//        cout << ctr2 + d;
//    }
}


/*
Link: codeforces.com/problemset/problem/248/A
*/

#include<iostream>
#include<vector>

int main(int argc, char* argv[])
{
	int door = 1;
	std::cin >> door;
	int lone = 0, lzero = 0, rone = 0, rzero = 0;
	for(int i = -0; i < door; i++)
	{
		int lposition;
		std::cin >> lposition;
		if(lposition == 1)
			lone++;
		else
			lzero++;

		int rposition;
		std::cin >> rposition;
		if(rposition == 1)
			rone++;
		else
			rzero++;
	}

	int time = 0;
	if((lzero == door) || (lone == door))
		time += 0;
	else if(lzero >= lone)
		time += lzero - lone;
	else if(lone >= lzero)
		time += lone - lzero;

	if((rzero == door) || (rone == door))
		time += 0;
	else if(rzero >= rone)
		time += rzero - rone;
	else if(rone >= rzero)
		time += rone - rzero;
	std::cout << time;

	return 0;
}


/*
Link: codeforces.com/problemset/problem/248/A
*/

#include<iostream>
#include<vector>

int main(int argc, char* argv[])
{
	int door = 1;
	std::cin >> door;
	int lone = 0, lzero = 0, rone = 0, rzero = 0;
	std::vector<int>rpos;
	std::vector<int>lpos;
	for(int i = -0; i < door; i++)
	{
		int lposition;
		std::cin >> lposition;
		lpos.push_back(lposition);
		if(lposition == 1)
			lone++;
		else
			lzero++;

		int rposition;
		std::cin >> rposition;
		rpos.push_back(rposition);
		if(rposition == 1)
			rone++;
		else
			rzero++;
	}

	int time = 0;
	if((lzero == 0) && (lone == 0))
		time += 0;
	else if(lzero >= lone)
		time += lzero - lone;
	else if(lone >= lzero)
		time += lone - lzero;
		time += lone - lzero;
	if((rzero == 0) && (rone == 0))
		time += 0;
	else if(rzero >= rone)
		time += rzero - rone;
	else if(rone >= rzero)
		time += rone - rzero;
	time -= 1;
	std::cout << time;

	return 0;
}


/*
Link: codeforces.com/problemset/problem/248/A
*/

#include<iostream>
#include<vector>

int main(int argc, char* argv[])
{
	int door = 1;
	std::cin >> door;
	int lone = 0, lzero = 0, rone = 0, rzero = 0;
	for(int i = -0; i < door; i++)
	{
		int lposition;
		std::cin >> lposition;
		if(lposition == 1)
			lone++;
		else
			lzero++;

		int rposition;
		std::cin >> rposition;
		if(rposition == 1)
			rone++;
		else
			rzero++;
	}

	int time = 0;
	if((lzero == door) || (lone == door))
		time += 0;
	else if(lzero >= lone)
		time += lzero - lone;
	else if(lone >= lzero)
		time += lone - lzero;

	if((rzero == door) || (rone == door))
		time += 0;
	else if(rzero >= rone)
		time += rzero - rone;
	else if(rone >= rzero)
		time += rone - rzero;
	time -= 1;
	std::cout << time;

	return 0;
}


/*
Link: https://codeforces.com/problemset/problem/248/A
*/

#include <iostream>
#include <vector>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t, count_a = 0, count_b = 0;
    cin >> t;
    int a, b;

    for(int i = 0; i < t; ++i)
    {
        cin >> a >> b;
        if(a)
            ++count_a;
        if(b)
            ++count_b;
    }

    int sum = 0;

    if(count_a > t - count_a)
        sum += (t - count_a);
    else
        sum += count_a;

    if(count_b > t - count_b)
        sum += (t - count_b);
    else
        sum += count_b;

    cout << sum;

    return 0;
}


/*
Link: codeforces.com/problemset/problem/248/A
*/

#include<iostream>
#include<vector>

int main(int argc, char* argv[])
{
	int door = 1;
	std::cin >> door;
	int lone = 0, lzero = 0, rone = 0, rzero = 0;
	std::vector<int>rpos;
	std::vector<int>lpos;
	for(int i = -0; i < door; i++)
	{
		int lposition;
		std::cin >> lposition;
		lpos.push_back(lposition);
		if(lposition == 1)
			lone++;
		else
			lzero++;

		int rposition;
		std::cin >> rposition;
		rpos.push_back(rposition);
		if(rposition == 1)
			rone++;
		else
			rzero++;
	}

	int time = 0;
	if(lzero >= lone)
		time += lzero - lone;
	else if(lone >= lzero)
		time += lone - lzero;
	if(rzero >= rone)
		time += rzero - rone;
	else if(rone >= rzero)
		time += rone - rzero;
	time -= 1;
	std::cout << time;

	return 0;
}


/*
Link: codeforces.com/problemset/problem/248/A
*/

#include<iostream>
#include<vector>

int main(int argc, char* argv[])
{
	int door = 1;
	std::cin >> door;
	int lone = 0, lzero = 0, rone = 0, rzero = 0;
	std::vector<int>rpos;
	std::vector<int>lpos;
	for(int i = -0; i < door; i++)
	{
		int lposition;
		std::cin >> lposition;
		lpos.push_back(lposition);
		if(lposition == 1)
			lone++;
		else
			lzero++;

		int rposition;
		std::cin >> rposition;
		rpos.push_back(rposition);
		if(rposition == 1)
			rone++;
		else
			rzero++;
	}

	int time = 0;
	if((lzero == 0) && (lone == 0))
		time += 0;
	else if(lzero >= lone)
		time += lzero - lone;
	else if(lone >= lzero)
		time += lone - lzero;
		time += lone - lzero;
	if((rzero == 0) && (rone == 0))
		time += 0;
	else if(rzero >= rone)
		time += rzero - rone;
	else if(rone >= rzero)
		time += rone - rzero;

	std::cout << time;

	return 0;
}


/*
Link: codeforces.com/problemset/problem/248/A
*/

#include<iostream>
#include<vector>

int main(int argc, char* argv[])
{
	int door = 1;
	std::cin >> door;
	int lone = 0, lzero = 0, rone = 0, rzero = 0;
	std::vector<int>rpos;
	std::vector<int>lpos;
	for(int i = -0; i < door; i++)
	{
		int lposition;
		std::cin >> lposition;
		lpos.push_back(lposition);
		if(lposition == 1)
			lone++;
		else
			lzero++;

		int rposition;
		std::cin >> rposition;
		rpos.push_back(rposition);
		if(rposition == 1)
			rone++;
		else
			rzero++;
	}

	int time = 0;
	if(lzero >= lone)
		time += lzero - lone;
	else if(lone >= lzero)
		time += lone - lzero;
	if(rzero >= rone)
		time += rzero - rone;
	else if(rone >= rzero)
		time += rone - rzero;

	std::cout << time;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,cnt1=0,cnt3=0,cnt2=0,cnt4=0;int left[n],right[n];cin>>n;
	for(int i=0;i<n;i++){
		cin>>left[i]>>right[i];
	}
	unordered_map<int,int> mpleft;
	unordered_map<int,int> mpright;
	for(int i=0;i<n;i++){
		mpleft[left[i]]++;
		mpright[right[i]]++;
	}
	cnt1 = mpleft[0];cnt3 = mpleft[1];cnt2 = mpright[0];cnt4 = mpright[1];

	if((cnt1>cnt3) && (cnt2>cnt4)){
		cout<<cnt3+cnt4<<endl;
	}else if((cnt1>cnt3) && (cnt2<=cnt4)){
		cout<<cnt3+cnt2<<endl;
	}else if((cnt1<=cnt3) && (cnt2<=cnt4)){
		cout<<cnt1+cnt2<<endl;
	}else{
		cout<<cnt1+cnt4<<endl;
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,cnt1=0,cnt3=0,cnt2=0,cnt4=0;int left[n],right[n];cin>>n;
	for(int i=0;i<n;i++){
		cin>>left[i]>>right[i];
	}
	unordered_map<int,int> mpleft;
	unordered_map<int,int> mpright;
	for(int i=0;i<n;i++){
		mpleft[left[i]]++;
		mpright[right[i]]++;
	}
	cnt1 = mpleft[0];cnt3 = mpleft[1];cnt2 = mpright[0];cnt4 = mpright[1];
	cout<<min(cnt1,cnt3)+min(cnt2,cnt4)<<endl;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;int left[n],right[n];cin>>n;
	for(int i=0;i<n;i++){
		cin>>left[i]>>right[i];
	}
	unordered_map<int,int> mpleft;
	unordered_map<int,int> mpright;
	for(int i=0;i<n;i++){
		mpleft[left[i]]++;
		mpright[right[i]]++;
	}
	cout<<min(mpleft[1],mpleft[0])+min(mpright[1],mpright[0]);

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,cnt1=0,cnt3=0,cnt2=0,cnt4=0;int left[n],right[n];cin>>n;
	for(int i=0;i<n;i++){
		cin>>left[i]>>right[i];
	}
	for(int i=0;i<n;i++){
		if(left[i]==0){
			cnt1++;
		}else{
			cnt3++;
		}
	}
	for(int i=0;i<n;i++){
		if(right[i]==0){
			cnt2++;
		}else{
			cnt4++;
		}
	}
	if((cnt1>cnt3) && (cnt2>cnt4)){
		cout<<cnt3+cnt4;
	}else if((cnt1>cnt3) && (cnt2<=cnt4)){
		cout<<cnt3+cnt2;
	}else if((cnt1<=cnt3) && (cnt2<=cnt4)){
		cout<<cnt1+cnt2;
	}else{
		cout<<cnt1+cnt4;
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,cnt1=0,cnt3=0,cnt2=0,cnt4=0;int left[n],right[n];cin>>n;
	for(int i=0;i<n;i++){
		cin>>left[i]>>right[i];
	}
	for(int i=0;i<n;i++){
		if(left[i]==0){
			cnt1++;
		}else{
			cnt3++;
		}
	}
	for(int i=0;i<n;i++){
		if(right[i]==0){
			cnt2++;
		}else{
			cnt4++;
		}
	}
	if((cnt1>cnt3) && (cnt2>cnt4)){
		cout<<cnt3+cnt4<<endl;
	}else if((cnt1>cnt3) && (cnt2<=cnt4)){
		cout<<cnt3+cnt2<<endl;
	}else if((cnt1<=cnt3) && (cnt2<=cnt4)){
		cout<<cnt1+cnt2<<endl;
	}else{
		cout<<cnt1+cnt4<<endl;
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;int left[n],right[n];cin>>n;
	for(int i=0;i<n;i++){
		cin>>left[i]>>right[i];
	}
	unordered_map<int,int> mpleft;
	unordered_map<int,int> mpright;
	for(int i=0;i<n;i++){
		mpleft[left[i]]++;
		mpright[right[i]]++;
	}
	cout<<min(mpleft[1],mpleft[0])+min(mpright[1],mpright[0]);
	return 0;

}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;cin>>n;
	int cnt1=0,cnt2=0,cnt3=0,cnt4=0;
	int left;int right;
	for(int i=0;i<n;i++){
		cin>>left>>right;
		if(left == 0){
			cnt1++;
		}
		if(left==1){
			cnt2++;
		}
		if(right==0){
			cnt3++;
		}
		if(right == 1){
			cnt4++;
		}
	}
	cout<<min(cnt1,cnt2)+min(cnt3,cnt4);
}