//line 1 "main.cpp" #if !__INCLUDE_LEVEL__ #include __FILE__ int main() { cincout::Etising(); int N, M; cin >> N >> M; atcoder::dsu uf(2 * N + 1); rep(i, M) { int A, B; cin >> A >> B; uf.merge(A, B); } int rem = 0; auto vec = uf.groups(); rep(i, 1, vec.size()) rem += vec[i].size() % 2; if(rem == 0) fin(0); if(rem == 1) fin(1); printl(combination(rem, 2)); } #else //line 1 "/home/etis/cpp-library/src/template.hpp" #pragma GCC target("avx") //#pragma GCC target("avx2") #pragma GCC optimize("O3") //#pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include using namespace std; //local debug #ifdef LOCAL #include #define debug(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__) #else #define debug(...) (static_cast(0)) #endif //AtCoder Library #if __has_include() #include using mint = atcoder::modint998244353; using Mint = atcoder::modint1000000007; #endif //alias using uint = unsigned int; using ll = long long; using ull = unsigned long long; using ld = long double; //constants constexpr const long long MOD = 998244353; constexpr const long long MODM = 1000000007; constexpr const int INF = 1e9; constexpr const ll LINF = 1e18; constexpr const ld PI = 3.1415926535; //rep(for-loop) macro #define overload4(a, b, c, d, e, ...) e #define rep2(i, n) for(ll i = 0; i < n; i++) #define rep3(i, k, n) for(ll i = k; i < n; i++) #define rep4(i, k, n, a) for(ll i = k; i < n; i += a) #define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2)(__VA_ARGS__) #define rep1_2(i, n) for(ll i = 1; i <= n; i++) #define rep1_3(i, k, n) for(ll i = k; i <= n; i++) #define rep1_4(i, k, n, a) for(ll i = k; i <= n; i += a) #define rep1(...) overload4(__VA_ARGS__, rep1_4, rep1_3, rep1_2)(__VA_ARGS__) #define Rep2(i, n) for(ll i = n - 1; i >= 0; i--) #define Rep3(i, k, n) for(ll i = n - 1; i >= k; i--) #define Rep4(i, k, n, a) for(ll i = n - 1; i >= k; i -= a) #define Rep(...) overload4(__VA_ARGS__, Rep4, Rep3, Rep2)(__VA_ARGS__) #define Rep1_2(i, n) for(ll i = n; i >= 1; i--) #define Rep1_3(i, k, n) for(ll i = n; i >= k; i--) #define Rep1_4(i, k, n, a) for(ll i = n; i >= k; i -= a) #define Rep1(...) overload4(__VA_ARGS__, Rep1_4, Rep1_3, Rep1_2)(__VA_ARGS__) #define vfor(x, v) for(auto x : v) #define mfor(map) for(auto &[key, value] : map) //vector macro #define vvecc(T, name, n, m) vector> name(n, vector(m)) #define vvec(T, name, n) vector> name(n) #define vvecs(T, name, n, m, s) vector> name(n, vector(m, s)) #define vvvecc(T, name, n, m, h) vector>> name(n, vector>(m, vector(h))) #define vvvecs(T, name, n, m, h, s) vector>> name(n, vector>(m, vector(h, s))) #define LB(v, x) distance((v).begin(), lower_bound(all(v), (x))) #define UB(v, x) distance((v).begin(), upper_bound(all(v), (x))) #define MIN(v) *min_element(all(v)) #define MINI(v) distance(v.begin(), min_element(all(v))) #define MAX(v) *max_element(all(v)) #define MAXI(v) distance(v.begin(), max_element(all(v))) #define Sort(v) sort(all(v)) #define Rev(v) reverse(all(v)) template inline ll vsum(const vector &v) {ll sum = 0; for(T x : v) sum += x; return sum;} //iterator macro #define all(v) begin(v), end(v) #define rall(v) rbegin(v), rend(v) #define rng(v, l, r) begin(v) + (l), begin(a) + (r) //data structure macro #define ef emplace_front #define eb emplace_back #define pf pop_front #define pb pop_back #define mp make_pair #define fi first #define se second #define mt make_tuple #define lb lower_bound #define ub upper_bound template using pq = priority_queue; template using pqmin = priority_queue, greater>; template using pqp = priority_queue>; template using pqpmin = priority_queue, vector>, greater>>; //output #define pl() cout << '\n' #define ifl(i, k) " \n"[i == k] template inline void print(const T& a) {cout << a;} inline void printl() {} template inline void printl(const T& t) {print(t); pl();} template inline void printf(const T& t) {print(t); pl(); cout << flush;} template inline void printl(const Head& head, const Tail&... tail) {print(head); cout << " "; printl(tail...);} template inline void printf(const Head& head, const Tail&... tail) {print(head); cout << " "; printl(tail...); cout << flush;} template inline void printl(const vector& v) {if(v.size() == 0) return; print(v[0]); for(auto i = v.begin(); ++i != v.end();) {cout << " "; print(*i);}} template inline void printl1(const vector& v) {if(v.size() <= 1) return; print(v[1]); for(auto i = v.begin() + 1; ++i != v.end();) {cout << " "; print(*i);}} template inline void prints(const T& a) {cout << a << " ";} template inline void fin(const T& t) {printl(t); exit(0);} inline void Yes(bool a) {cout << (a ? "Yes" : "No") << '\n';} template inline void Out2(bool a, T yes, U no) {if(a) printl(yes); else printl(no);} //functions inline int ctoi(char c) {return c - '0';} inline char to_char(int x) {return x + '0';} inline bool bw(ll a, ll x, ll b) {return (a < x && x < b);} inline bool bwe(ll a, ll x, ll b) {return (a <= x && x <= b);} template inline constexpr auto Emin(T... a) {return min(initializer_list>{a...});} template inline constexpr auto Emax(T... a) {return max(initializer_list>{a...});} template inline bool chmax(T &a, const U &b) {if (a < b) { a = b; return true;} return false;} template inline bool chmin(T &a, const U &b) {if (a > b) { a = b; return true;} return false;} template inline ll Epow(T x, U y) {ll ans = 1; for(int i = 0; i < y; i++) ans *= x; return ans;} template inline ll Eceil(T x, U y) {return (ll)ceil((ld)x / (ld)y);} template inline ll Efloor(T x, U y) {return (ll)floor((ld)x / (ld)y);} template inline bool check_bit(T tar, U bit) {return ((tar & Epow(2, bit)) != 0);} template inline bool overflow_if_add(T a, T b) {return (std::numeric_limits::max() - a) < b;} template inline bool overflow_if_mul(T a, T b) {return (std::numeric_limits::max() / a) < b;} //pair-sort template inline bool pud(pair& left, pair& right) { if (left.first == right.first) return right.second < left.second; else return left.first < right.first; } template inline bool pdu(pair& left, pair& right) { if (left.first == right.first) return left.second < right.second; else return right.first < left.first; } namespace cincout { void Etising() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(15); } } struct exec_time { private: std::chrono::system_clock::time_point start, end; public: exec_time() : start(std::chrono::system_clock::now()) {} ll get_time() { end = std::chrono::system_clock::now(); ll ret = (ll)std::chrono::duration_cast(end - start).count(); return ret; } }; void cordp(vector &A) { vector sorted; map> idx; rep(i, A.size()) { sorted.eb(A[i]); idx[A[i]].eb(i); } Sort(sorted); sorted.erase(unique(all(sorted)), sorted.end()); rep(i, sorted.size()) vfor(x, idx[sorted[i]]) A[x] = i; } //line 2 "/home/etis/cpp-library/src/math.hpp" using namespace std; long long pow_mod(long long x, long long n, long long mod = 1e18) { long long ret = 1; while(n > 0) { if(n & 1) ret = (ret * x) % mod; x = (x * x) % mod; n >>= 1; } return ret; } //a ÷ bをmodで割った余り(modは素数) - O(log(mod)) long long div_mod(long long a, long long b, long long mod = 1e18) {return (a * pow_mod(b, mod - 2, mod)) % mod;} //階乗 - O(n) long long factorial(long long n, long long mod = 1e18) { long long ans = 1; for(long long i = n; i >= 2; i--) ans = (ans * i) % mod; return ans; } //順列 - O(r) long long permutation(long long n, long long r, long long mod = 1e18) { long long ans = 1; for(long long i = 0; i < r; i++) ans = (ans * (n - i)) % mod; return ans; } //組み合わせ(modは素数) - O(min(r, n - r) + log(mod)) long long combination(long long n, long long r, long long mod = 1e18) { r = min(r, n - r); if(r == 0) return 1; long long up = n; long long down = 1; for(int i = 1; i < r; i++) { up = (up * (n - i)) % mod; down = (down * (i + 1)) % mod; } return div_mod(up, down, mod); } //nC0~nCrまでの列挙(modは素数) - O(rlog(mod)) vector getCombination_vec(long long n, long long r, long long mod = 1e18) { vector ret(r + 1); ret[0] = 1; long long up = n; long long down = 1; ret[1] = div_mod(up, down, mod); for(int i = 1; i < r; i++) { up = (up * (n - i)) % mod; down = (down * (i + 1)) % mod; ret[i + 1] = div_mod(up, down, mod); } return ret; } //素数判定 - O(√N) bool is_prime(long long N) { if (N == 1) return false; for (long long i = 2; i * i <= N; i++) { if (N % i == 0) return false; } return true; } //約数列挙 - O(√N) vector enum_divisors(long long N) { vector res; for (long long i = 1; i * i <= N; i++) { if (N % i == 0) { res.emplace_back(i); if (N / i != i) res.emplace_back(N / i); } } sort(res.begin(), res.end()); return res; } //素因数分解 - O(√N) vector> prime_factorize(long long N) { vector> res; for (long long a = 2; a * a <= N; a++) { if (N % a != 0) continue; long long ex = 0; while (N % a == 0) { ex++; N /= a; } res.emplace_back(make_pair(a, ex)); } if (N != 1) res.emplace_back(make_pair(N, 1)); return res; } //エラトステネスの篩 - O(NloglogN) vector Eratosthenes(long long N) { vector isprime(N + 1, true); isprime[0] = isprime[1] = false; for (long long p = 2; p <= N; p++) { if (!isprime[p]) continue; for (long long q = p * 2; q <= N; q += p) { isprime[q] = false; } } return isprime; } //N以下の素数を列挙 - O(NloglogN) vector getPrimes(long long N) { vector era = Eratosthenes(N); vector primes; for(long long i = 2; i <= N; i++) { if(era[i]) primes.emplace_back(i); } return primes; } //ユークリッド距離 long double calc_dist(long long x1, long long y1, long long x2, long long y2) {return sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));} long double calc_dist(pair p1, pair p2) {return sqrt(pow(p2.first - p1.first, 2) + pow(p2.second - p1.second, 2));} //ユークリッド距離の2乗 long long calc_dist2(long long x1, long long y1, long long x2, long long y2) {return pow(x2 - x1, 2) + pow(y2 - y1, 2);} long long calc_dist2(pair p1, pair p2) {return pow(p2.first - p1.first, 2) + pow(p2.second - p1.second, 2);} //line 30 "main.cpp" #endif