#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < b; i++)
using namespace std;

class Graph {
    vector<vector<int>> adj;
    vector<int> color;

public:
    Graph(int n) : adj(n), color(n, -1) {}

    void connect(int a, int b) {
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    bool dfs(int from = 0, int cur = 0) {
        color[from] = cur;
        for (auto to : adj[from]) {
            if (color[to] == cur) return false;
            if (color[to] == -1 && !dfs(to, 1 - cur)) return false;
        }
        return true;
    }

    vector<int> &getColor() {
        return color;
    }
};

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

    Graph graph(n);
    rep(i, 0, m) {
        int a, b;
        cin >> a >> b;
        graph.connect(--a, --b);
    }

    long long ans;
    if (graph.dfs()) {
        int cnt[2] = {0};
        for (auto i : graph.getColor()) cnt[i]++;
        ans = (long long)cnt[0] * cnt[1] - m;
    } else {
        ans = (long long)n * (n - 1) / 2 - m;
    }

    cout << ans << endl;
    
    return 0;
}
/*====Corycle====*/
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<complex>
#include<cstdio>
#include<vector>
#include<cmath>
#include<ctime>
#include<stack>
#include<queue>
#include<map>
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const int N=1e5+5;
int read(){
	int s=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){s=s*10+c-'0';c=getchar();}
	return s*f;
}
int n,m,a[N],num[2][N],f[2][2],g[2][2];
int main(){
//	freopen("_.in","r",stdin);
//	freopen("_.out","w",stdout);
	n=read();
	for(int i=1;i<=n;i++){a[i]=read();num[i&1][a[i]]++;}
	for(int t=0;t<2;t++){
		for(int i=1;i<N;i++){
			if(f[t][0]<=num[t][i]){
				f[t][1]=num[t][g[t][1]=g[t][0]];
				f[t][0]=num[t][g[t][0]=i];
			}
			else if(f[t][1]<=num[t][i]){
				f[t][1]=num[t][g[t][1]=i];
			}
		}
	}
	if(g[0][0]!=g[1][0])printf("%d\n",n-f[0][0]-f[1][0]);
	else printf("%d\n",min(n-f[0][0]-f[1][1],n-f[0][1]-f[1][0]));
	return 0;
}