main :: IO ()
main = do
  n <- readLn
  if n == 0
    then return ()
    else do
      putStrLn (show (func' n))
      main
 
func :: [Int] -> [Int]
func (x:y:z:r) = ((x+y+z):x:y:z:r)

funcn :: Int -> [Int] -> [Int]
funcn 0 ls = ls
funcn n ls = funcn (n-1) (func ls)

func2 :: Int -> Int
func2 0 = 1
func2 1 = 1
func2 n = head (funcn (n-2) [2,1,1])


func' :: Int -> Int
func' n = (days `div` 365) + (min (days `mod` 365) 1)
  where num = func2 n
        days = (num `div` 10) + (min (num `mod` 10) 1)