import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [a, b] <- getIntList
    print $ solve a b

solve a b | b == 1 = 0
          | a == 2 = b - 1
          | otherwise = div b (a - 1) + f (mod b (a - 1))
    where f n | n <= 1 = 0
              | otherwise = 1