You are given an undirected graph of N nodes and M edges, E_1, E_2, ... E_M.

A connected graph is a cactus if each of it's edges belogs to at most one simple cycle. A graph is a desert if each of it's connected components is a cactus. 

Find the number of pairs (L, R), (1 ≤ L ≤ R ≤ M) such that, if we delete all the edges except for E_L, E_{L+1}, ... E_R, the graph is a desert. 

Input

The first line contains two integers N and M (2 ≤ N ≤ 2.5 × 10^5, 1 ≤ M ≤ 5 × 10^5). Each of the next M lines contains two integers. The i-th line describes the i-th edge. It contains integers U_i and V_i, the nodes connected by the i-th edge (E_i=(U_i, V_i)). It is guaranteed that 1 ≤ U_i, V_i ≤ N and U_i ≠ V_i. 

Output

The output contains one integer number – the answer.

Examples

Input


5 6
1 2
2 3
3 4
4 5
5 1
2 4


Output


20

Input


2 3
1 2
1 2
1 2


Output


5

Note

In the second example: Graphs for pairs (1, 1), (2, 2) and (3, 3) are deserts because they don't have any cycles. Graphs for pairs (1, 2) and (2, 3) have one cycle of length 2 so they are deserts.
5 10
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
4 5
 4 5
1 2
2 3
2 4
3 4
4 1
 5 4
1 2
2 3
3 4
4 5
 3 6
1 2
2 3
3 1
1 2
2 3
3 1
 10 15
1 2
1 5
1 6
2 3
2 7
3 4
3 8
4 5
4 9
5 10
6 8
6 9
7 9
7 10
8 10
 8 11
1 2
2 3
2 4
3 4
4 1
5 6
6 8
6 7
7 8
7 5
8 5
 5 1
1 2
 5 8
1 2
2 3
3 1
2 5
3 4
4 5
5 3
1 4

38
 14
 10
 15
 99
 48
 1
 30

#include <bits/stdc++.h>
using namespace std;
const int M = 1000000007;
const int N = 1000005;
int n, i, ch[N][2], fa[N], rev[N], mx[N], k, m, j, u[N], v[N];
struct str {
  int u, v;
} e[N];
int lazy[N], w[N];
void pushup(int x) { mx[x] = mx[ch[x][0]] | mx[ch[x][1]] | (x > n ? w[x] : 0); }
void pushdown(int x) {
  if (rev[x])
    rev[ch[x][0]] ^= 1, rev[ch[x][1]] ^= 1, swap(ch[x][0], ch[x][1]),
        rev[x] = 0;
  if (lazy[x] != -1) {
    if (ch[x][0]) lazy[ch[x][0]] = mx[ch[x][0]] = w[ch[x][0]] = lazy[x];
    if (ch[x][1]) lazy[ch[x][1]] = mx[ch[x][1]] = w[ch[x][1]] = lazy[x];
    lazy[x] = -1;
  }
}
void update(int x) { pushup(x), pushdown(x); }
bool isr(int x) { return !(ch[fa[x]][0] == x || ch[fa[x]][1] == x); }
void rotate(int x) {
  int y = fa[x];
  bool d = (ch[y][0] == x);
  ch[y][!d] = ch[x][d];
  if (ch[x][d] != 0) fa[ch[x][d]] = y;
  fa[x] = fa[y];
  if (!isr(y)) ch[fa[y]][ch[fa[y]][1] == y] = x;
  ch[x][d] = y;
  fa[y] = x;
  pushup(y), pushup(x);
}
void pd(int x) {
  if (!isr(x)) pd(fa[x]);
  update(x);
}
void splay(int x) {
  pd(x);
  for (int y = fa[x]; !isr(x); rotate(x), y = fa[x])
    if ((!isr(y)) && (ch[fa[y]][0] == y) == (ch[y][0] == x)) rotate(y);
}
void access(int x) {
  for (int y = 0; x != 0; y = x, x = fa[x])
    splay(x), update(x), ch[x][1] = y, update(x);
}
void maker(int x) { access(x), splay(x), rev[x] ^= 1, update(x); }
void link(int x, int y) { maker(x), splay(x), fa[x] = y; }
void cut(int x, int y) {
  maker(x), access(y), splay(x), update(x), ch[x][1] = 0, fa[y] = 0, update(x);
}
int findroot(int x) {
  access(x), splay(x);
  update(x);
  while (ch[x][0] != 0) x = ch[x][0], update(x);
  splay(x);
  return x;
}
bool iscon(int x, int y) {
  maker(x);
  if (findroot(y) == x)
    return true;
  else
    return false;
}
int Sum(int u, int v) {
  maker(u);
  access(v);
  splay(v);
  return mx[v];
}
void Tag(int u, int v, int z) {
  maker(u);
  access(v);
  splay(v);
  mx[v] = w[v] = lazy[v] = z;
}
long long ans = 0;
int main() {
  scanf("%d %d", &n, &m);
  for (i = 1; i <= m; i++) scanf("%d %d", &e[i].u, &e[i].v);
  k = n;
  int l = 1;
  memset(lazy, -1, sizeof(lazy));
  for (i = 1; i <= m; i++) {
    if (!iscon(e[i].u, e[i].v)) {
      link(n + i, e[i].u);
      link(n + i, e[i].v);
    } else {
      while (iscon(e[i].u, e[i].v) && Sum(e[i].u, e[i].v)) {
        splay(n + l);
        int x = w[n + l];
        if (x != 0) {
          Tag(e[x].u, e[x].v, 0);
          cut(e[l].u, n + l);
          link(e[x].u, n + x);
          link(e[x].v, n + x);
        } else
          cut(e[l].u, n + l);
        ++l;
      }
      if (!iscon(e[i].u, e[i].v)) {
        link(n + i, e[i].u);
        link(n + i, e[i].v);
      } else
        Tag(e[i].u, e[i].v, i);
    }
    ans += i - l + 1;
  }
  cout << ans;
}
