#A
"""
a, b, c = map(int, input().split())
print(min(b//a, c))
"""
#B
"""
a, b, k = map(int, input().split())
for i in range(max(a, b), 0, -1):
    if a % i == 0 and b % i == 0:
        k -= 1
        if k == 0:
             print(i)
"""

#C
"""
s = list(input())
an0 = 0
an1 = 0
for i in s:
    if i == "1":
        an1 += 1
    if i == "0":
        an0 += 1
print(min(an0, an1)*2)
"""

#D

n, m = map(int, input().split())
ab = []
for i in range(m):
    ab.append(list(map(int, input().split())))

ab = ab[-1::-1]
size = [1 for _ in range(n)]
height = [1 for _ in range(n)]
par = [i for i in range(n)]
def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
def union(x, y):
    s1 = find(x)
    s2 = find(y)
    if s1 != s2:
        if height[s1] < height[s2]:
            par[s1] = s2
            size[s2] += size[s1]
            size[s1] = 0
        else:
            par[s2] = s1
            size[s1] += size[s2]
            size[s2] = 0
            if height[s1] == height[s2]:
                height[s1] += 1
 

ans = [0 for i in range(m)]
ans[0] = n * (n - 1) // 2
for num, i in enumerate(ab):
    if num == m-1:
        break
    a = i[0] - 1
    b = i[1] - 1
    sizea = size[find(a)]
    sizeb = size[find(b)]
    if find(a) == find(b):
        ans[num + 1] = ans[num]
    else:
        ans[num + 1] = ans[num] - (sizea * sizeb)
    union(a,b)
    
    
ans = ans[-1::-1]
for i in ans:
    print(i) """
a, b, c = map(int, input().split())
print(min(b//a, c))
""" """
a, b, k = map(int, input().split())
for i in range(max(a, b), 0, -1):
    if a % i == 0 and b % i == 0:
        k -= 1
        if k == 0:
             print(i)
""" """
s = list(input())
an0 = 0
an1 = 0
for i in s:
    if i == "1":
        an1 += 1
    if i == "0":
        an0 += 1
print(min(an0, an1)*2)
""" n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m ab = [] ab [] for i in range(m):
    ab.append(list(map(int, input().split()))) i range(m) range m ab.append(list(map(int, input().split()))) ab.append ab append list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split ab = ab[-1::-1] ab ab[-1::-1] ab -1::-1 -1 -1 1 for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) 1 size = [1 for _ in range(n)] size [1 for _ in range(n)] 1 for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) 1 height = [1 for _ in range(n)] height [1 for _ in range(n)] i for i in range(n) for i in range(n) i range(n) range n for i in range(n) i par = [i for i in range(n)] par [i for i in range(n)] def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x] find if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x] par[x] == x par[x] par x x return x x par[x] = find(par[x]) par[x] par x find(par[x]) find par[x] par x return par[x] par[x] par x x x def union(x, y):
    s1 = find(x)
    s2 = find(y)
    if s1 != s2:
        if height[s1] < height[s2]:
            par[s1] = s2
            size[s2] += size[s1]
            size[s1] = 0
        else:
            par[s2] = s1
            size[s1] += size[s2]
            size[s2] = 0
            if height[s1] == height[s2]:
                height[s1] += 1
  union s1 = find(x) s1 find(x) find x s2 = find(y) s2 find(y) find y if s1 != s2:
        if height[s1] < height[s2]:
            par[s1] = s2
            size[s2] += size[s1]
            size[s1] = 0
        else:
            par[s2] = s1
            size[s1] += size[s2]
            size[s2] = 0
            if height[s1] == height[s2]:
                height[s1] += 1
  s1 != s2 s1 s2 if height[s1] < height[s2]:
            par[s1] = s2
            size[s2] += size[s1]
            size[s1] = 0
        else:
            par[s2] = s1
            size[s1] += size[s2]
            size[s2] = 0
            if height[s1] == height[s2]:
                height[s1] += 1
  height[s1] < height[s2] height[s1] height s1 height[s2] height s2 par[s1] = s2 par[s1] par s1 s2 size[s2] += size[s1] size[s2] size s2 size[s1] size s1 size[s1] = 0 size[s1] size s1 0 par[s2] = s1 par[s2] par s2 s1 size[s1] += size[s2] size[s1] size s1 size[s2] size s2 size[s2] = 0 size[s2] size s2 0 if height[s1] == height[s2]:
                height[s1] += 1
  height[s1] == height[s2] height[s1] height s1 height[s2] height s2 height[s1] += 1 height[s1] height s1 1 x x y y 0 for i in range(m) for i in range(m) i range(m) range m for i in range(m) 0 ans = [0 for i in range(m)] ans [0 for i in range(m)] ans[0] = n * (n - 1) // 2 ans[0] ans 0 n * (n - 1) // 2 n * (n - 1) n n - 1 n 1 2 for num, i in enumerate(ab):
    if num == m-1:
        break
    a = i[0] - 1
    b = i[1] - 1
    sizea = size[find(a)]
    sizeb = size[find(b)]
    if find(a) == find(b):
        ans[num + 1] = ans[num]
    else:
        ans[num + 1] = ans[num] - (sizea * sizeb)
    union(a,b)
    
     num i enumerate(ab) enumerate ab if num == m-1:
        break
     num == m-1 num m-1 m 1 break a = i[0] - 1 a i[0] - 1 i[0] i 0 1 b = i[1] - 1 b i[1] - 1 i[1] i 1 1 sizea = size[find(a)] sizea size[find(a)] size find(a) find a sizeb = size[find(b)] sizeb size[find(b)] size find(b) find b if find(a) == find(b):
        ans[num + 1] = ans[num]
    else:
        ans[num + 1] = ans[num] - (sizea * sizeb)
     find(a) == find(b) find(a) find a find(b) find b ans[num + 1] = ans[num] ans[num + 1] ans num + 1 num 1 ans[num] ans num ans[num + 1] = ans[num] - (sizea * sizeb) ans[num + 1] ans num + 1 num 1 ans[num] - (sizea * sizeb) ans[num] ans num sizea * sizeb sizea sizeb union(a,b) union a b ans = ans[-1::-1] ans ans[-1::-1] ans -1::-1 -1 -1 for i in ans:
    print(i) i ans print(i) print i m = map(int, input().split()) map(int, input().split()) m n, m = map(int, input().split()) map(int, input().split()) n par = [i for i in range(n)] [i for i in range(n)] par ab = ab[-1::-1] ab[-1::-1] ab a = i[0] - 1 i[0] - 1 a def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x] def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x] find sizea = size[find(a)] size[find(a)] sizea size = [1 for _ in range(n)] [1 for _ in range(n)] size height = [1 for _ in range(n)] [1 for _ in range(n)] height ab = [] [] ab ans = [0 for i in range(m)] [0 for i in range(m)] ans b = i[1] - 1 i[1] - 1 b sizeb = size[find(b)] size[find(b)] sizeb ans = ans[-1::-1] ans[-1::-1] ans def union(x, y):
    s1 = find(x)
    s2 = find(y)
    if s1 != s2:
        if height[s1] < height[s2]:
            par[s1] = s2
            size[s2] += size[s1]
            size[s1] = 0
        else:
            par[s2] = s1
            size[s1] += size[s2]
            size[s2] = 0
            if height[s1] == height[s2]:
                height[s1] += 1
  def union(x, y):
    s1 = find(x)
    s2 = find(y)
    if s1 != s2:
        if height[s1] < height[s2]:
            par[s1] = s2
            size[s2] += size[s1]
            size[s1] = 0
        else:
            par[s2] = s1
            size[s1] += size[s2]
            size[s2] = 0
            if height[s1] == height[s2]:
                height[s1] += 1
  union
#A
"""
a, b, c = map(int, input().split())
print(min(b//a, c))
"""
#B
"""
a, b, k = map(int, input().split())
for i in range(max(a, b), 0, -1):
    if a % i == 0 and b % i == 0:
        k -= 1
        if k == 0:
             print(i)
"""

#C
"""
s = list(input())
an0 = 0
an1 = 0
for i in s:
    if i == "1":
        an1 += 1
    if i == "0":
        an0 += 1
print(min(an0, an1)*2)
"""

#D

n, m = map(int, input().split())
ab = []
for i in range(m):
    ab.append(list(map(int, input().split())))

ab = ab[-1::-1]
size = [1 for _ in range(n)]
height = [1 for _ in range(n)]
par = [i for i in range(n)]
def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
def union(x, y):
    s1 = find(x)
    s2 = find(y)
    if s1 != s2:
        if height[s1] < height[s2]:
            par[s1] = s2
            size[s2] += size[s1]
            size[s1] = 0
        else:
            par[s2] = s1
            size[s1] += size[s2]
            size[s2] = 0
            if height[s1] == height[s2]:
                height[s1] += 1
 

ans = [0 for i in range(m)]
ans[0] = n * (n - 1) // 2
for num, i in enumerate(ab):
    if num == m-1:
        break
    a = i[0] - 1
    b = i[1] - 1
    sizea = size[find(a)]
    sizeb = size[find(b)]
    if find(a) == find(b):
        ans[num + 1] = ans[num]
    else:
        ans[num + 1] = ans[num] - (sizea * sizeb)
    union(a,b)
    
    
ans = ans[-1::-1]
for i in ans:
    print(i)
