package main import ( "fmt" ) func main() { var n, d int fmt.Scan(&n, &d) if n==d { fmt.Println("0") return } m := make([]bool, n) var j, cnt int for j == 0{ for i := 0; i < n;{ //fmt.Println("i", i) if m[i] { j = 1 break } m[i] = true cnt++ i = (i +d)%n } } fmt.Println(cnt-1) }