#include <bits/stdc++.h>
using namespace std;
class Node {
 public:
  int x;
  Node *next;
  Node(int v, Node *nextv) : x(v), next(nextv){};
};
int main() {
  ios_base::sync_with_stdio(false);
  long long int n, m;
  cin >> n >> m;
  long long int loop = 0;
  long long int edge = 0;
  int temp1, temp2;
  vector<Node *> matrix(n + 1, NULL);
  vector<long long int> degree(n + 1, 0);
  vector<bool> chart(n + 1, false);
  for (int i = 1; i <= m; i++) {
    cin >> temp1 >> temp2;
    chart[temp1] = true;
    chart[temp2] = true;
    if (temp1 != temp2) {
      Node *p1 = new Node(temp1, matrix[temp2]);
      Node *p2 = new Node(temp2, matrix[temp1]);
      matrix[temp1] = p2;
      matrix[temp2] = p1;
      degree[temp1]++;
      degree[temp2]++;
      edge++;
    } else {
      loop++;
    }
  }
  if (m <= 1) {
    cout << 0 << endl;
    for (int i = 0; i <= n; i++) {
      Node *p = matrix[i], *q;
      while (p != NULL) {
        q = p;
        p = p->next;
        delete q;
      }
    }
    return 0;
  }
  int size = 0;
  int start;
  for (int i = 1; i < chart.size(); i++) {
    if (chart[i] == true) {
      start = i;
      size++;
    }
  }
  vector<bool> visited(n + 1, false);
  queue<int> Q;
  int front;
  int num;
  Q.push(start);
  visited[start] = true;
  num = 1;
  while (!Q.empty()) {
    front = Q.front();
    for (Node *j = matrix[front]; j != NULL; j = j->next) {
      if (visited[j->x] == false) {
        Q.push(j->x);
        visited[j->x] = true;
        num++;
      }
    }
    Q.pop();
  }
  if (num != size) {
    cout << 0 << endl;
  } else {
    long long int answer = 0;
    for (int i = 1; i <= n; i++) {
      answer += degree[i] * (degree[i] - 1) / 2;
    }
    answer += loop * (loop - 1) / 2 + loop * edge;
    cout << answer << endl;
  }
  for (int i = 0; i <= n; i++) {
    Node *p = matrix[i], *q;
    while (p != NULL) {
      q = p;
      p = p->next;
      delete q;
    }
  }
}
