

repeatBall::Int->Char->String
repeatBall n c = take n $ repeat c

main = do
  [n,a,b] <- map read . words <$> getLine
  print $ length . filter (=='b') $ take n (cycle $ repeatBall a 'b' ++ repeatBall b 'r')