100 10
87 73
15 71
14 33
1 4
20 80
65 67
36 36
25 4
22 21
7 97
 4 2
3 3
3 4
 5 4
3 3
4 4
5 5
1 2
 4 4
1 2
2 3
3 1
4 4
 4 3
1 1
2 3
3 4
 1000000 1
255765 255765
 4 3
1 2
2 3
4 4
 4 2
1 1
1 2
 3 3
1 1
2 2
3 3
 5 4
1 1
2 3
2 4
2 5
 4 5
1 4
3 4
1 2
2 3
2 4
 4 4
2 3
2 4
3 4
4 4
 10 9
8 10
3 10
2 8
9 3
4 8
1 10
7 9
5 4
7 3
 10 10
1 2
2 3
3 4
4 5
5 1
6 6
7 7
8 8
9 9
10 10
 5 5
1 4
3 4
1 2
2 3
2 4
 3 3
1 2
2 2
3 3
 5 3
1 1
2 2
3 3
 6 12
1 2
1 3
2 3
1 1
2 2
3 3
4 5
5 6
4 6
4 4
5 5
6 6
 4 4
1 2
2 3
1 3
4 4
 5 4
1 2
3 3
4 4
5 5
 7 13
6 7
2 7
3 7
4 3
5 2
1 4
7 7
3 1
5 5
3 3
1 5
2 6
6 6
 2 2
1 1
2 2
 5 5
1 1
2 2
3 3
4 4
5 5
 1 1
1 1
 7 3
1 1
3 3
6 6
 3 3
1 1
2 3
3 3

0 1 0 0 0 0 0 1 0 0 8 6 12 0 8 0 0 0 0 0 57 0 0 0 0 0
#ifndef home
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4a,popcnt,abm,mmx")
#endif // home
#define __USE_MINGW_ANSI_STDIO 0
#include<bits/extc++.h>
using namespace std;
using namespace __gnu_cxx;
#define mp make_pair
#define lowb lower_bound
#define upb upper_bound
#define bins binary_search
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define all(_x) (_x).begin(),(_x).end()
#define inf(_name) freopen(_name, "r", stdin)
#define ouf(_name) freopen(_name, "w", stdout)
#define sqr(_x) ((_x)*(_x))
#define cub(_x) ((_x)*(_x)*(_x))
#define gcd __gcd
#define lcm(_a,_b) ((_a)/gcd(_a,_b)*(_b))
#define forn(_i,_l,_r) for(int _i=_l;_i<_r;++_i)
#define ford(_i,_l,_r) for(int _i=_l;_i>=_r;--_i)
#define sz(_A) (int)_A.size()
#define re return
#define FASTER ios::sync_with_stdio(false);cout.setf(ios::showpoint);\
cin.tie(0);cout.tie(0);cout.precision(15)
#define F(_i,_l,_r) for(int _i=_l;_i<_r;++_i)
#define f(_i,_n) for(int _i=0;_i<_n;++_i)
#define bcnt __builtin_popcount
#define bcntll __builtin_popcountll
#define bcnt0 __builtin_ctz
#define bcnt0ll __builtin_ctzll
#define ep emplace
#define eb emplace_back
#define lintm llm
#define islower(c) (c>='a' && c<='z')
#define isupper(c) (c>='A' && c<='Z')
#define isalpha(c) (islower(c) || isupper(c))
template <class X,class C=less<X>,class Y=__gnu_pbds::null_type>
using ordered_map=__gnu_pbds::tree<X,Y,C,__gnu_pbds::rb_tree_tag,
__gnu_pbds::tree_order_statistics_node_update>;
template<class X,class C=greater<X>> using heap=__gnu_pbds::priority_queue
<X,C,__gnu_pbds::pairing_heap_tag>;typedef unsigned long long ulint;
typedef long long lint;typedef long long ll;typedef long double ld;
const int mod=1000000007;typedef unsigned long long ull;
typedef pair <int,int> pii;typedef pair<lint,lint> pll;
const int intm=INT_MAX;const lint llm=LLONG_MAX;
template<class X> inline void getarr(X *a,int n)
{for(int i=0;i<n;i++) cin>>a[i];}
template<class X> inline void getarr(X *a,int n,int m)
{for(int i=0;i<n;i++) getarr(a[i],m);}
template<class X> inline void putarr(X *a,int n,char ch=' ')
{for(int i=0;i<n;i++) cout<<a[i]<<ch;}
template<class X> inline void putarr(X* a,int n,int m)
{for(int i=0;i<n;i++){putarr(a[i],m,' ');cout<<'\n';}}
template<class X> inline X abs(X a){return a<0?-a:a;}
template<class X> inline void mini(X &x,X y){x=min(x,y);}
template<class X> inline void maxi(X &x,X y){x=max(x,y);}
template<class X> constexpr X bround(X x){re x==0?1:bround(x>>1)<<1;}
template<class X=int> X myrand(X l=0,X r=intm)
{
    static mt19937 gen;
    uniform_int_distribution<X> dist(l,r);
    return dist(gen);
}
//--------------------------------------------------stdfunc------------------
vector<int> g[1005000];
bool u[1000005];
void dfs(int v)
{
    if(u[v])re;
    u[v]=1;
    for(int x:g[v])
    {
        dfs(x);
    }
}
int main(){
    FASTER;
    #ifdef home
    assert(inf("input.txt"));
    //assert(ouf("output.txt"));
    #endif // home
    int n,m;
    cin>>n>>m;
    ll loop=0;
    f(i,m)
    {
        int x,y;
        cin>>x>>y;
        if(x==y)loop++;
        else
        {
            g[x].pb(y);
            g[y].pb(x);
        }
    }
    f(i,n+1)
    {
        if(g[i].size()>0)
        {
            dfs(i);
            break;
        }
    }
    ll ans=0;
    F(i,1,n+1)
    {
        if(!u[i] && g[i].size()>0){cout<<0;re 0;}
        else ans+=1ll*g[i].size()*(g[i].size()-1)/2;
    }
    cout<<ans+loop*(m-1)-loop*(loop-1)/2;
    return 0;
}
