module Main where import Control.Monad import Control.Applicative import Data.Maybe import Data.List import qualified Text.Printf import qualified Data.ByteString.Char8 as BC import qualified Data.ByteString as BC import Debug.Trace ------------------------------------------ calc :: Int -> Int calc x = f 0 2000 where f l r | l+1 >= r = l | otherwise = let m = (l+r) `div` 2 in if m*(m+1)`div`2 <= x then f m r else f l m greedy :: Int -> Int greedy 0 = 0 greedy x = let y = calc x in 1 + greedy (x - y * (y+1) `div` 2) main :: IO () main = do n <- readInt let v = calc n w = calc (n `div` 2) if v*(v+1)`div`2 == n then print 1 else if 2*(w*(w+1)`div`2) == n then print 2 else print $ greedy n ------------------------------------------ {- Int input -} parseInt :: BC.ByteString -> Int parseInt = fst . fromJust . BC.readInt parseInts :: BC.ByteString -> [Int] parseInts = map parseInt <$> BC.words readInt :: IO Int readInt = parseInt <$> BC.getLine readInts :: IO [Int] readInts = parseInts <$> BC.getLine {- Double Formatting -} doubleFmt :: Double -> String doubleFmt = Text.Printf.printf "%.12f"