#include <bits/stdc++.h>
using namespace std;
struct Graph {
  vector<vector<int> > edges;
  vector<int> dst;
  int size;
  Graph(int n) {
    size = n;
    edges.resize(n);
    dst.resize(n);
  }
  void bfs(int s) {
    fill(dst.begin(), dst.end(), -1);
    queue<int> q;
    q.push(s);
    dst[s] = 0;
    while (!q.empty()) {
      int v = q.front();
      q.pop();
      for (int i = 0; i < edges[v].size(); i++) {
        int new_dst = dst[v] + 1;
        if (dst[edges[v][i]] == -1) {
          dst[edges[v][i]] = new_dst;
          q.push(edges[v][i]);
        }
      }
    }
    return;
  }
  void add_edge(int u, int v) {
    edges[u].push_back(v);
    edges[v].push_back(u);
  }
};
vector<string> string_split(string s, const char delimiter) {
  size_t start = 0;
  size_t end = s.find_first_of(delimiter);
  vector<string> output;
  while (end <= string::npos) {
    output.emplace_back(s.substr(start, end - start));
    if (end == string::npos) break;
    start = end + 1;
    end = s.find_first_of(delimiter, start);
  }
  return output;
}
int main() {
  int n, m, u, v, cnt = 0;
  cin >> n >> m;
  long long ans = m;
  Graph g(n + 1);
  vector<bool> check(n + 1, 0);
  while (m--) {
    scanf("%d%d", &u, &v);
    check[u] = check[v] = 1;
    if (u == v) {
      cnt++;
    } else
      g.add_edge(u, v);
  }
  ans -= cnt;
  ans *= cnt;
  ans += cnt * ((long long)cnt - 1) / 2;
  for (int i = 1; i <= n; i++) {
    ans += ((long long)g.edges[i].size() - 1) * g.edges[i].size() / 2;
  }
  g.bfs(v);
  for (int i = 1; i <= n; i++) {
    if (g.dst[i] == -1 && check[i]) {
      cout << 0 << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}
