package main import ( "fmt" ) func main() { var A, B int fmt.Scan(&A, &B) for x := 1; ; x++ { if x%A == B%x { fmt.Println(x) return } } }