from collections import defaultdict
from queue import Queue

def main():
    ns,ms = input().strip().split()
    n,m = int(ns), int(ms)
    graph = defaultdict(list)

    for i in range(0,m):
        a,b = input().strip().split()
        graph[int(a)-1].append(int(b)-1)
        graph[int(b)-1].append(int(a)-1)

    visited = set() 
    components = defaultdict(list)
    current_component = 0
    for vertice in graph:
        if vertice not in visited:
            visited.add(vertice)
            queue = Queue()
            queue.put(vertice)

            while not queue.empty():
                v = queue.get()
                components[current_component].append(v)
                for neighbour in graph[v]:
                    if neighbour not in visited:
                        visited.add(neighbour)
                        queue.put(neighbour)

            current_component += 1
    
    r = 0
    for c in components:
        for v in components[c]:
            r += len(components[c]) - len(graph[v]) - 1

    print(r//2) # print(current_component)
if __name__ == '__main__': 
    main()