object Main extends App {
  val in = scala.io.Source.stdin.getLines.toSeq
  val ls = in.map(_.split(' ').map(_.toInt).toIndexedSeq)
  val N = (ls.head)(0)
  val M = (ls.head)(1)
  val S = ls.tail
  println(N, M, S.toSeq)
  var sets:Array[Set[Int]] = Array()
  S.foreach{e =>
    //println(e)
    var inserted = false
    var insi = -1
    sets.indices.map{ i =>
      if(inserted && (sets(i).contains(e(0)) || sets(i).contains(e(1)) )) {
        sets(insi) = sets(i) ++ Set(e(0), e(1))
        sets(i) = Set()
      }   
      
      if(sets(i).contains(e(0)) || sets(i).contains(e(1)) ) {
        sets(i) = sets(i) ++ Set(e(0), e(1))
        inserted = true
        insi = i
      }
    }
    if(!inserted) sets = sets :+ Set(e(0), e(1))
    
    println(sets.toSeq)
    val sizes = sets.map(_.size).filter(_ > 0)
    println(sizes.toSeq)
    val red = sizes.foldLeft(1L){(a,e) => a*e}
    val ret = N * (N-1) / 2 - red/2
    println(ret)

}
  //println(sets.toSeq)
 
  //println(ret)
}
