#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;++i)
#define repn(i,n) for(int i=1;i<=n;++i)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n,cnt,ans=0;
vector <int> g[400010];
bool vis[400010],cyc;

void dfs(int pos,int par)
{
  vis[pos]=true;
  cnt++;
  bool bk=false;
  rep(i,g[pos].size())
  {
    if(g[pos][i]==par&& !bk)
    {
      bk=true;
      continue;
    }
    if(vis[g[pos][i]]) cyc=true;
    else dfs(g[pos][i],pos);
  }
}

int main()
{
  cin>>n;
  int x,y;
  rep(i,n)
  {
    scanf("%d%d",&x,&y);
    g[x].pb(y);g[y].pb(x);
  }
  repn(i,400000)
  {
    if(vis[i]) continue;
    cyc=false;cnt=0;
    dfs(i,0);
    ans+=cnt-1+(int)cyc;
  }
  cout<<ans<<endl;
	return 0;
}
#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main(){
	ll n,m;cin>>n>>m;
	vector<string> s;
  	ll odd=0,even=0;
  	for(ll i=0;i<n;i++){
    	string str;cin>>str;
    	ll ct=0;
      	for(ll j=0;j<m;j++){
        	if(str[j]=='1'){
            	ct++;
            }
        }
      ct%2?odd++:even++;
    }
  cout<<odd*even<<endl;
}