package main import "fmt" func main() { var n, m int fmt.Scan(&n, &m) if m < 3 { fmt.Println("-1") } else { k := (n + (m - 1)) / m for k > 1 { k += ((k + (m - 1)) / m) } fmt.Println(k * 2) } }