main = do
  [n, k] <- fmap (map read . words) getLine

  print $ if k <= (n+1) `div` 2 then 2*(k-1)+1 else 2*(k - (n+1)`div`2)

import Data.List
import Data.Maybe
main=   readsolveprint
readsolveprint::IO()
readsolveprint =  interact $ show.solve.map read.words.head . lines
solve :: [Integer]->Integer
solve [x,y] = let z= ceiling (fromIntegral x/ 2) in if y <=z then 2*y-1 else 2*(y - z)

import Control.Applicative

main = do
    [n,i] <- map read.words <$> getLine :: IO [Integer]
    putStrLn.show $ index n i

index n i
    | i <= div (n+1) 2 = 2*i-1
    | otherwise = (i- div (n+1) 2) * 2

import Control.Applicative

main = do
  [n,k] <- map read . words <$> getLine :: IO [Integer]
  let d = n `div` 2 + fromIntegral (fromEnum (rem n 2 == 1))
  print $ if k > d then 2*(k-d) else 2*(k-1)+1

{-# LANGUAGE PatternGuards #-}

import Control.Concurrent
import Control.Monad
import System.IO
import Text.Printf
import System.Environment

main = subMain

solve n k = if (k > midn) then 2*(k - midn) else 2*k-1 where
		midn = if (nm2 == 0) then n2 else n2 + 1
		nm2 = mod n 2
		n2 = div n 2

subMain = do
  numsStr <- getLine
  let [n, k] = map (read :: String -> Integer) $ words numsStr
  print $ solve n k

---------------
-----------------------------------------------------------------------------

import Control.Monad
import Data.Array
import Data.Char
import Data.Int
import Data.List
import Data.List.Split
import Data.Maybe
-- import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
getList :: Read a => IO [a]
getList = fmap (map (read . B.unpack) . B.words) B.getLine
getIntList :: IO [Int]
getIntList = fmap (unfoldr (B.readInt . B.dropWhile isSpace)) B.getLine

solve :: Int64 -> Int64 -> Int64
solve n k = if k <= m then 2 * k - 1 else 2 * (k - m)
            where m = (n + 1) `div` 2

main :: IO ()
main = do
        [n,k] <- getList
        print $ solve n k

import Control.Applicative
import Data.List
import Data.List.Split

calc n k | even n && k<=n2 = 2*k-1
         | even n = (k-n2)*2
         | odd n && k<=(n2+1) = 2*k-1
         | otherwise = (k-n2-1)*2
  where n2 = div n 2

main=do
      [n,k]<-   map read <$>words <$> getLine ::IO [Integer]
      print $ calc n k

main :: IO ()
main = getLine >>= print . solve . map read . words

solve :: [Integer] -> Integer
solve [n, k] | k <= (n + 1) `div` 2 = 2 * k - 1
             | otherwise = 2 * (k - (n + 1) `div` 2)

main = interact $ show . solve . map read . words
solve [n,k] = r + 1 + (1 - n `mod` 2) * q
  where (q,r) = (2 * (k-1)) `divMod` n

import System.IO
import Control.Monad
import Data.List

glwr = fmap (map read . words) getLine

main = do
  hSetBuffering stdout NoBuffering
  solve

solve :: IO ()
solve = do
  n:k:_ <- glwr

  print $ evenOrOdd n k

evenOrOdd :: Integer -> Integer -> Integer
evenOrOdd n k
  | k <= odds = k*2 - 1
  | 0 < 1 = (k - odds) * 2
  where
    odds = div n 2 + sum [ 1 | odd n ]
    evens = n - odds

nthNumber n k
  | oddsCount >= k = 2 * k - 1
  | otherwise = (k - oddsCount) * 2
  where
    oddsCount = (n + 1) `div` 2

main = do
  input <- getLine
  let [n, k] = map (read :: String -> Integer) (words input) in print (nthNumber n k)

import Control.Applicative
main = map read . words <$> getLine >>= print . solve
solve :: [Integer] -> Integer
solve [n, k] | even n = solveEven n k
             | odd n = solveOdd n k
solveEven :: Integer -> Integer -> Integer
solveEven n k | k <= n `div` 2 = k * 2 - 1
              | k > n `div` 2 = (k - n `div` 2) * 2
solveOdd :: Integer -> Integer -> Integer
solveOdd n k | k <= n `div` 2 + 1 = k * 2 - 1
             | k > n `div` 2 + 1 = (k - (n`div` 2 + 1)) * 2

-- Vicfred
-- https://codeforces.com/problemset/problem/318/A

import Data.Int

solve :: [Int64] -> Int64
solve [n,k] = if k <= m then 2*k-1 else 2*(k-m)
              where m = (n+1) `div` 2

main :: IO ()
main = getLine >>= print . solve . map read . words

solve [a,b] | b <= div (a+1) 2 = 2 * b - 1
            | 0 < 1            = 2 * (b - div (a + 1) 2)
main = interact $ show . solve . map read . words

main=interact$show.f.map read.words
f :: [Integer] -> Integer
f[n,k]|k<=div(n+1)2=2*k-1|0<1=2*(k-div(n+1)2)

main = interact (show . answer . readInput)

readInput :: String -> [Integer]
readInput line = (map read) . words $ line

answer :: [Integer] -> Integer
answer [n, k] = if (k <= (n + 1) `div` 2) then k * 2 - 1 else (k - (n + 1) `div` 2) * 2

import Control.Monad
import Control.Applicative

genAns n k
  | k <= ceiling (fromIntegral n / 2) = k * 2 - 1
  | otherwise = (k - (ceiling (fromIntegral n / 2) )) * 2

main = do
  [n,k] <- map read . words <$> getLine :: IO [Integer]
  print $ genAns n k

import Control.Applicative
import Data.List

main= do
	[n,k]<- map read. words <$> getLine ::IO [Integer]
	print $ if even n then if k*2 <=n then k*2-1 else (2*(k- (div n 2)) )else if k*2-1<=n then k*2-1 else (2*(k-(div (n+1) 2)))

module Main (main)
    where

main :: IO ()
main = print . find . take 2 . map read . words =<< getLine
    where find [n,k]
            | k > lastOdd = 2*(k - lastOdd)
            | otherwise   = 2*k - 1
                where lastOdd = (n + n `mod` 2) `div` 2

main = do
	s<-getLine
	let [n,k]=map read $words s
	putStrLn $ show $ solve n k

solve n k | even n && k> div n 2 = 2*(k-div n 2 )
          | even n && k<= div n 2 = 1+2*(k-1)
          | odd n && k>div (n+1) 2=2*(k- div (n+1) 2)
          | odd n && k<=div (n+1) 2=1+2*(k-1)

findnum f s =
  if (odd f)
  then if (s > ((div f 2)+1))
       then (2*(s-((div f 2)+1)))
       else (2*s - 1)
  else if (s > (div f 2))
       then (2*(s-(div f 2)))
       else (2*s - 1)

main = do
  aa <- getLine
  let ff = (read (head (words aa)))::Integer
      ss = (read (last (words aa)))::Integer

  let ans = findnum ff ss
  putStrLn (show ans)

-- Snippet: readItems
readItems = do
    line <- getLine
    return $ map read $ words line

main = do
    [n, k] <- readItems
    let numOdd = div (n + 1) 2
    putStrLn $ show $ if k <= numOdd then k + k - 1 else (k - numOdd) * 2

main = do
  m <- getLine
  let [m1, m2] = (map read . words) m
  print $ makn m1 m2
makn :: Integer -> Integer -> Integer
--makn x y = head $ drop (y-1) (filter odd [1..x] ++ filter even [1..x])
makn x y
 | 2*y-1 <= x = 2*y-1
 | otherwise = 2*(y-(quot (x+1) 2))

solve [n, k] =
  (+ div (2*(k - 1)) n).(+1).(*2).mod (k - 1) $ div (n + 1) 2
main = getLine >>= print. solve. map read. words

main=interact$ (++"\n").show.(\[n,k] ->
  let numOdds=(n+1)`div`2 in if k<= numOdds then 2*k-1 else 2*(k- numOdds)
  ).map read.words

main :: IO ()
main = interact $ show . solve . map read . words

solve :: [Integer] -> Integer
solve [n, k]
  | k <= m = 2 * k - 1
  | otherwise = 2 * (k - m)
  where
  m = n `div` 2 + n `mod` 2

main :: IO ()
main = do
    [n, k] <- map (read :: String -> Integer) . words <$> getLine
    print $ if 2 * k <= (n + 1)
        then 2 * (k - 1) + 1
        else 2 * (k - ((n + 1) `div` 2))

main :: IO()
main = interact mainFunction

mainFunction :: String -> String
mainFunction input = let [n, k] = map parseInteger . words $ input
                     in show $ solve n k

parseInteger :: String -> Integer
parseInteger = read

solve :: Integer -> Integer -> Integer
solve n k = let oddCount = (n + 1) `div` 2
            in if k <= oddCount
               then 2 * k - 1
               else 2 * (k - oddCount)

main :: IO ()
main = do
 line <- getLine
 putStrLn $ show $ solve line

lineToInts :: String -> [Integer]
lineToInts s = map (read :: String -> Integer) (words s)

solve :: String -> Integer
solve line =
 let nums = lineToInts line
     amount = head nums
     index = (last nums) - 1 in
 -- ([1,3..amount] ++ [2,4..amount]) !! (fromIntegral index)
 solve' amount index

solve' :: Integer -> Integer -> Integer
solve' amount index
 | index < odds = index * 2 + 1
 | otherwise = (index - odds + 1) * 2
 where odds = ceiling $ (fromIntegral amount) / 2

{-# LANGUAGE BlockArguments #-}

import Control.Arrow
import Data.List

main = do { nk <- getLine
          ; let [n,k] = words >>> map read $ nk
          ; putStrLn $ show (solve n k)
          }

solve :: Integer -> Integer -> Integer
solve n k = let m = (div n 2) + (mod n 2)
            in  if   k <= m
                then 2*k - 1
                else 2*(k-m)

main = getLine >>= return . map read . words
               >>= putStrLn . show . solve

solve (a:b:_)
  | bound < b = (b - bound) * 2
  | otherwise = b * 2 - 1
    where dm    = a `divMod` 2
          bound = fst dm + snd dm

main = do
    str <- getLine
    let xs = map read $ words str :: [Integer]
    let n = xs !! 0
    let k = xs !! 1
    let m = if (mod n 2 == 0) then (div n 2) else (div n 2 + 1)
    let ans = if (k > m) then ((k - m) * 2) else (k * 2 - 1)
    print ans

main = do
    input <- getLine
    let inp = (split ' ' input)
    let n = read (inp !! 0) :: Integer
    let k = read (inp !! 1) :: Integer
    let v = (n+1) `div` 2
    putStrLn (show (if k <= v then (k * 2 - 1) else ((k - v) * 2)))

split' :: (Eq a) => a -> [a] -> [a] -> [[a]]
split' _ [] l = [l]
split' v (x:xs) l
   | x /= v = split' v xs (l ++ [x])
   | otherwise = [l] ++ split' v xs []

split :: (Eq a) => a -> [a] -> [[a]]
split v xs = split' v xs []

process :: Integral a => a -> a -> a
process n k
    | k <= m = 2*k-1
    | otherwise = 2*(k-m)
    where m = n - n `div` 2

readInt :: String -> Integer
readInt = read

main = do
    [n, k] <- fmap (map readInt.words) getLine
    print $ process n k

import Control.Monad
import qualified Data.Map.Lazy as Map
import qualified Data.ByteString.Lazy as BS
import Data.List

main :: IO ()
main = do
  n:m:_ <- fmap (map read . words) getLine
  print $ rush n m

rush :: Integer -> Integer -> Integer
rush n m
  | n `mod` 2 == 0 && m * 2 <= n = 2 * m - 1
  | n `mod` 2 == 0 = (m - n `div` 2) * 2
  | n `mod` 2 == 1 && m * 2 - 1 <= n = 2 * m - 1
  | otherwise = (m - n `div` 2 - 1) * 2

import Control.Monad

main = do
   [n,k] <- liftM (map (\x -> read x::Integer) . words) getLine
   let midn = n`div`2 + (if odd n then 1 else 0)
       result = if k > midn then 2*(k-midn) else 2*(k-1)+1
   print result

import Control.Monad (liftM, replicateM)
import Prelude hiding (reads)

reads :: Read a => IO [a]
reads  =  liftM (map read . words) getLine

solve :: [Integer] -> Integer
solve [n, k]
  | k <= n `div` 2 + n `mod` 2  =  2 * k - 1
  | otherwise  =  2 * (k - n `div` 2 - n `mod` 2)

main :: IO ()
main  =  reads >>= print . solve

import Control.Applicative

main = do
    [a,b] <- map read.words <$> getLine :: IO [Integer]
    putStrLn.show $ if odd a then oddA a b else evenA a b

oddA a b = if b <= div (a+1) 2 then 2*b-1 else (b-div (a+1) 2)*2
evenA a b = if b <= div a 2 then 2*b-1 else (b-div a 2)*2

-- Even and Odds
main :: IO ()
main = do
  [n, k] <- fmap (map read . words) getLine
  print $ sol n k

sol :: Integer -> Integer -> Integer
sol n k
  | k <= ceil = pred (k * 2)
  | otherwise = (* 2) (k - ceil)
  where
    ceil = div (succ n) 2

main = interact solve
solve str = let [n, k] = map (read::String -> Integer) . words $ str
            in findk n k

findk n k
    | k <= oddCounts = show $ 2*k - 1
    | otherwise = show $ (k-oddCounts) * 2
    where oddCounts = (n+1) `div` 2

import Control.Applicative

main = do
    [a,b] <- map read.words <$> getLine :: IO [Int]
    putStrLn.show $ if odd a then oddA a b else evenA a b

oddA a b = if b <= div (a+1) 2 then [1,3..a] !! (b-1) else (b-div (a+1) 2)*2
evenA a b = if b <= div a 2 then 2*b-1 else (b-div a 2)*2

import Control.Applicative

main = do
  [n,k] <- map read . words <$> getLine :: IO [Int]
  let d = n `div` 2 + fromEnum (rem n 2 == 1)
  print $ if k > d then 2*(k-d) else 2*(k-1)+1

{-# LANGUAGE PatternGuards #-}

import Control.Concurrent
import Control.Monad
import System.IO
import Text.Printf
import System.Environment

main = subMain

solve n k = if (k > midn) then 2*(k - midn) else 2*k-1 where
		midn = div n 2 + 1

subMain = do
  numsStr <- getLine
  let [n, k] = map (read :: String -> Integer) $ words numsStr
  print $ solve n k

---------------
-----------------------------------------------------------------------------

{-# LANGUAGE PatternGuards #-}

import Control.Concurrent
import Control.Monad
import System.IO
import Text.Printf
import System.Environment

main = subMain

solve n k = if (k >= midn) then 2*(k - midn) else 2*k-1 where
		midn = if (nm2 == 0) then n2 else n2 + 1
		nm2 = mod n 2
		n2 = div n 2

subMain = do
  numsStr <- getLine
  let [n, k] = map (read :: String -> Integer) $ words numsStr
  print $ solve n k

---------------
-----------------------------------------------------------------------------

{-# LANGUAGE PatternGuards #-}

import Control.Concurrent
import Control.Monad
import System.IO
import Text.Printf
import System.Environment

main = subMain

solve n k = if (k > midn) then 2*(k - midn) else 2*k-1 where
		midn = div n 2 + 1

subMain = do
  numsStr <- getLine
  let [n, k] = map (read :: String -> Int) $ words numsStr
  print $ solve n k

---------------
-----------------------------------------------------------------------------

import Control.Applicative
import Data.List
import Data.List.Split

calc n k | even n && k<=n2 = 2*k-1
         | even n = (k-n2)*2
         | odd n && k<=(n2+1) = 2*k-1
         | otherwise = (k-n2-1)*2
  where n2 = div n 2

main=do
      [n,k]<-   map read <$>words <$> getLine ::IO [Int]
      print $ calc n k

import System.IO
import Control.Monad
import Data.List

glwr = fmap (map read . words) getLine

main = do
  hSetBuffering stdout NoBuffering
  solve

solve :: IO ()
solve = do
  n:k:_ <- glwr

  print $ evenOrOdd n k

evenOrOdd :: Int -> Int -> Int
evenOrOdd n k
  | k <= odds = k*2 - 1
  | 0 < 1 = (k - odds) * 2
  where
    odds = div n 2 + sum [ 1 | odd n ]
    evens = n - odds

nthNumber n k
  | oddsCount >= k = 2 * k - 1
  | otherwise = (k - oddsCount) * 2
  where
    oddsCount = (n + 1) `div` 2

main = do
  input <- getLine
  let [n, k] = map (read :: String -> Int) (words input) in print (nthNumber n k)

-- Vicfred
-- https://codeforces.com/problemset/problem/318/A

solve :: [Int] -> Int
solve [n,k] = if k <= m then 2*k-1 else 2*(k-m)
              where m = (n+1) `div` 2

main :: IO ()
main = getLine >>= print . solve . map read . words

solve [a,b] | a `div` 2 > b = 2*b - 1
            | a `div` 2 < b = 2 * (b - (a `div` 2) - 1)
main = interact $ show . solve . map read . words

import Control.Applicative
import Data.List

main= do
	[n,k]<- map read. words <$> getLine ::IO [Int]
	print $ if even n then if k*2 <=n then k*2-1 else (2*(k- (div n 2)) )else if k*2-1<=n then k*2-1 else (2*(k-(div (n+1) 2)))

main = do
  m <- getLine
  let [m1, m2] = (map read . words) m
  print $ makn m1 m2
makn :: Integer -> Integer -> Integer
--makn x y = head $ drop (y-1) (filter odd [1..x] ++ filter even [1..x])
makn x y
 | 2*y <x = 2*y-1
 | otherwise = 2*(y-(quot (x+1) 2))

main = do
  m <- getLine
  let [m1, m2] = (map read . words) m
  print $ makn m1 m2
makn :: Integer -> Integer -> Integer
--makn x y = head $ drop (y-1) (filter odd [1..x] ++ filter even [1..x])
makn x y
 | 2*y <x = 2*y-1
 | otherwise = 2*(y- 1-(quot x 2))

main = do
  m <- getLine
  let [m1, m2] = (map read . words) m
  print $ makn m1 m2
makn :: Integer -> Integer -> Integer
--makn x y = head $ drop (y-1) (filter odd [1..x] ++ filter even [1..x])
makn x y
 | 2*y <x = 2*y-1
 | otherwise = 2*y

main :: IO ()
main = do
    [n, k] <- map (read :: String -> Integer) . words <$> getLine
    print $ if 2 * k < n
        then 2 * (k - 1) + 1
        else 2 * (k - ((n + 1) `div` 2))

main :: IO()
main = interact mainFunction

mainFunction :: String -> String
mainFunction input = let [n, k] = map parseInt . words $ input
                     in show $ solve n k

parseInt :: String -> Int
parseInt = read

solve :: Int -> Int -> Int
solve n k = let oddCount = (n + 1) `div` 2
            in if k <= oddCount
               then 2 * k - 1
               else 2 * (k - oddCount)

main = do
    input <- getLine
    let inp = (split ' ' input)
    let n = read (inp !! 0) :: Int
    let k = read (inp !! 1) :: Int
    let v = (n+1) `div` 2
    putStrLn (show (if k <= v then (k * 2 - 1) else ((k - v) * 2)))

split' :: (Eq a) => a -> [a] -> [a] -> [[a]]
split' _ [] l = [l]
split' v (x:xs) l
   | x /= v = split' v xs (l ++ [x])
   | otherwise = [l] ++ split' v xs []

split :: (Eq a) => a -> [a] -> [[a]]
split v xs = split' v xs []

-- Even and Odds

main :: IO ()
main = do
        [n, k] <- fmap (map read . words) getLine
        print $ sol n k

sol :: Int -> Int -> Int
sol n k
  | 2 * k <= n = last . take k $ [1,3..]
  | otherwise = last . take (k `div` 2) $ [2,4..]

-- Even and Odds
main :: IO ()
main = do
  [n, k] <- fmap (map read . words) getLine
  print $ sol n k

sol :: Int -> Int -> Int
sol n k
  | k <= ceil = pred (k * 2)
  | otherwise = (* 2) (k - ceil)
  where
    ceil = div (succ n) 2

main = interact solve
solve str = let [n, k] = map (read::String -> Int) . words $ str
            in findk n k

findk n k
    | k <= oddCounts = show $ 2*k - 1
    | otherwise = show $ (k-oddCounts) * 2
    where oddCounts = (n+1) `div` 2

findnum f s =
  if (odd f)
  then if (s > ((div f 2)+1))
       then (2*(s-((div f 2)+1)))
       else (2*s - 1)
  else if (s > (div f 2))
       then (2*(s-(div f 2)))
       else (2*s - 1)

main = do
  aa <- getLine
  let ff = (read (head (words aa)))::Int
      ss = (read (last (words aa)))::Int

  let ans = findnum ff ss
  putStrLn (show ans)

{-# LANGUAGE BlockArguments #-}

import Control.Arrow
import Data.List

main = do { nk <- getLine
          ; let [n,k] = words >>> map read $ nk
          ; putStrLn $ show (solve n k)
          }

solve :: Int -> Int -> Int
solve n k = let m = (div n 2) + (mod n 2)
            in  if   k <= m
                then 2*k - 1
                else 2*(k-m)

import Data.List
import Data.Maybe
main=   readsolveprint
readsolveprint::IO()
readsolveprint =  interact $ show.solve.map read.words.head . lines
solve :: [Int]->Int
solve [x,y] = let z= ceiling (fromIntegral x/ 2) in if y <=z then 2*y-1 else 2*(y - z)

import Control.Monad

main = do
   [n,k] <- liftM (map (\x -> read x::Int) . words) getLine
   let midn = n`div`2
   print $ if k > midn then 2*(k-midn-1) else 2*(k-1)+1

import Control.Monad

main = do
   [n,k] <- liftM (map (\x -> read x::Int) . words) getLine
   let midn = n`div`2
   print $ if k > midn then 2*(k-midn-(if odd n then 1 else 0)) else 2*(k-1)+1

import Control.Applicative

main = do
    [n,i] <- map read.words <$> getLine :: IO [Int]
    putStrLn.show $ index n i

index n i
    | i < div (n+1) 2 = 2*i-1
    | otherwise = (i- div (n+1) 2) * 2

import Control.Applicative

main = do
    [a,b] <- map read.words <$> getLine :: IO [Int]
    putStrLn.show $ if odd a then oddA a b else evenA a b

oddA a b = if b <= div (a+1) 2 then 2*b-1 else (b-div (a+1) 2)*2
evenA a b = if b <= div a 2 then 2*b-1 else (b-div a 2)*2

import Control.Applicative

main = do
    [n,i] <- map read.words <$> getLine :: IO [Int]
    putStrLn.show $ index n i

index n i
    | i <= div (n+1) 2 = 2*i-1
    | otherwise = (i- div (n+1) 2) * 2


m :: Int -> Int -> Int -> Int
m y n x = y*n - x*100

ans :: Int -> Int
ans m | m > 0 = (m + 99) `div` 100
      | otherwise = 0

main = do
  [n, x, y] <- fmap ((map read).words) getLine
  print $ ans $ m y n x

getWords :: IO [String]
getWords = getLine >>= return . words

reads :: Read a => IO [a]
reads = getWords >>= return . (map read)

solve :: Int -> Int -> Int -> Int
solve n x y  =  max 0 ((n*y - 1) `div` 100 + 1 - x)

main :: IO ()
main  =  do
    [n, x, y] <- Main.reads
    print $ solve n x y

main=interact$show.f.map read.words
f[n,x,y]=max 0$ -(-n*y)`div`100-x

main :: IO ()
main = getContents >>= print . solve . map read . words

solve :: [Integer] -> Integer
solve [ n, x, y ] = max 0 $ (n * y + 99) `div` 100 - x
solve _ = undefined

main = print . solve . map read . words =<< getLine
solve [n,x,y] = max 0 $ (y*n + 99) `div` 100 - x

main=interact$show.s.map read.words
s[n,x,y]=max 0$(-100*x+y*n+99)`div`100

import Control.Applicative
import Data.List

main= do
	[n,a,b]<- map read. words <$> getLine::IO [Double]
	print $  max 0 $ ceiling $ b*n/100.0 - a

import Control.Applicative
import Data.List

main= do
	[n,a,b]<- map read. words <$> getLine::IO [Double]
	print $  ceiling $ b*n/100.0 - a


import Data.List
import qualified Data.Map.Strict as Map

toint s = (read s) :: Integer

solve::String -> String
solve ss =
	let n:s:_ = map toint $ words ss in
	show(div (s+n-1) n)++"\n"

main = do
  interact $ solve

import System.IO

parseInt :: IO [Int]
parseInt = fmap (map read . words) getLine

main :: IO()
main = do
  [n, s] <- parseInt

  let sol = ceiling $ fromIntegral s  / fromIntegral n
  print sol

import Control.Applicative
import Control.Monad

main= do
		[n,m]<- map read <$> words <$> getLine ::IO [Int]
		print $ (div m n) + if (mod m n)>0 then 1 else 0

import Data.List (nub)

process :: Int -> Int -> Int
process n s = (s - 1) `div` n + 1

readInt :: String -> Int
readInt = read

main :: IO ()
main = do
    [n,s] <- fmap (map readInt.words) getLine
    print $ process n s

import Data.List

main = do
       e<-getLine
       let (n:s:[])=map read (words e)::[Integer]
       print $ s `div` n + if s `mod` n==0 then 0 else 1

import Prelude
import Control.Monad

str2Ints str = [read x::Int | x <- words str]
getLineN n = replicateM n getLine

main = do
    s <- getLine;
    let l = str2Ints(s);
    (putStrLn.show)(l!!1 `quot` l!!0 + (if l!!1 `mod` l!!0/=0 then 1 else 0));

main = interact $ show . solve . map read . words
solve [n,s] = s `div` n + signum (s `mod` n)

main = do
    contents <- getContents
    process (parse contents)

parse :: String -> Maybe (Integer, Integer)
parse s = two_first(words s)

process :: Maybe (Integer, Integer) -> IO ()
process (Just (n, s)) = print (solve n s)
process Nothing = putStrLn "Invalid input"

two_first (a:b:x) = Just (read a, read b)
two_first x = Nothing

solve :: Integer -> Integer -> Integer
solve n s = (quot (s - 1) n) + 1

main = do
    contents <- getContents
    print (solve (parse contents))

parse :: String -> (Integer, Integer)
parse s = two_first(words s)

two_first (a:b:x) = (read a, read b)
two_first x = (10, 100000)

solve (n, s) = (quot (s - 1) n) + 1

import Control.Monad

solve :: Int -> Int -> Int
solve n s = let (q, r) = s `quotRem` n in
  q + (if r /= 0 then 1 else 0)

main = do
  [n, s] <- fmap read <$> words <$> getLine :: IO [Int]
  print $ solve n s

import Prelude
import Control.Monad

str2Ints str = [read x::Int | x <- words str]
getLineN n = replicateM n getLine

main = do
    s <- getLine;
    let l = str2Ints(s);
    (putStrLn.show)(l!!1 `quot` l!!0 + (if l!!1 `mod` l!!0==1 then 1 else 0));

import Control.Applicative
import Control.Monad

main= do
		[n,m]<- map read <$> words <$> getLine ::IO [Int]
		print $ (div m n) + if (mod m n)==1 then 1 else 0


main :: IO()
main = print . solve . map read . words =<< getContents

solve :: [Int] -> Int
solve [0, m] = 0
solve [n, m] | n < m     = -1
             | otherwise = (div ((div (n + 1) 2) + (m - 1)) m) * m

getAnswer :: Integer -> Integer -> Integer
getAnswer n m = quantify n 1 m

quantify :: Integer -> Integer -> Integer -> Integer
quantify limit current divisor = if current > limit
                                 then -1
                                 else if satisfy limit current divisor
                                 then current
                                 else quantify limit (current + 1) divisor

satisfy :: Integer -> Integer -> Integer -> Bool
satisfy limit steps divisor = if steps `mod` divisor == 0 && steps >= allowed
                              then True
                              else False
    where allowed = (limit+1) `div` 2

main :: IO ()
main = do
    numbers <- getLine
    let [n, m] = map read (words numbers)
    print (getAnswer n m)

import Data.List
main = interact $show.solve.map read.words

solve::[Int]->Int
solve (n:m:[]) = getRes $ find (comp m) [leftBound n..n]
             where leftBound n | even n = div n 2
                               | otherwise = div n 2 +1

comp m n | mod n m == 0  = True
         | otherwise = False

getRes::Maybe Int->Int
getRes (Just n) = n
getRes Nothing = -1

default ( Integer, Rational)

fib  = 0:1:zipWith (+) fib fib'
fib' = tail fib
sol n m = ((n+1) `div` 2 - 1) `div` m * m + m
solve [n,m] = if sol n m <= n then sol n m else -1

main = interact $ show . solve . map read . words

main = do
  [n, m] <- fmap (map read . words) getLine

  let ix = [i | i <- [1..10000], i `mod` m == 0, i <= n && n <= 2*i]

  print $ if null ix then -1 else head ix

module Main where

import Control.Applicative
import Control.Monad
import Data.Char           (toLower)
import Data.List           (intersperse)
import System.IO

solve :: Integral t => t -> t -> t
solve n m =
    if min_result > max_steps
        then -1
        else min_result
  where
    min_result = min_steps `cdiv` m * m
    max_steps = n
    min_steps = n `cdiv` 2
    cdiv a b = a `div` b + if a `mod` b > 0 then 1 else 0

main :: IO ()
main = do
    hSetBuffering stdin $ BlockBuffering Nothing
    hSetBuffering stdout $ BlockBuffering Nothing
    [n, m] <- map read . words <$> getLine
    print $ solve n m

import Data.List
import Data.Tree
import Data.Int
import Data.Maybe
import Data.Char
import Data.Functor
import Control.Monad
import Control.Monad.ST.Safe
import Control.Arrow
import Data.Array
import Data.Array.ST.Safe
import Data.STRef
import qualified Data.Map as Map
import qualified Data.Set as Set
import qualified Data.ByteString.Char8 as C
main=   readsolveprint
readsolveprint::IO()
readsolveprint = solve =<< (map (fst.fromJust.C.readInt).C.words<$>C.getLine)
--solve::Int->IO()
solve [x,y] = let m =x `div` 2+ x `mod` 2; b= snd $ break (\a-> a `mod` y ==0) [m..x] in print $ if b== [] then (-1) else head b

import Data.Char

h :: Int -> Int -> Int -> Int
h n m x
 | n-2*m >= 2*m = h (n-2*m) m (x+m)
 | n > 2*m = x + 2*m
 | n >= m = x+m
 | otherwise = -1

--main = do
-- line <- getLine
-- print (h line [])

main = do
 line <- getLine
 let a = (read (takeWhile (/= ' ') line) :: Int)
 let b = (read (drop 1 (dropWhile (/= ' ') line)) :: Int)
 print (h a b 0)

import Control.Applicative
import Data.List

process n m | mod nos m ==0 = nos
            | nos < m && n<m = -1
            | nos < m =m
            | otherwise = nos +m -(mod nos m)
   where nos = div (n+1) 2

main = do
  [n,m]<-  map read  <$>   words  <$> getLine ::IO [Int]
  print $ process n m

main :: IO ()
main = getLine >>= print . solve . map read . words

solve :: [Int] -> Int
solve [n, m] | n < m = -1
             | otherwise = m * ((n `div'` 2) `div'` m)
        where div' a b = - (-a) `div` b

main = interact $ show . solve . map read . words
solve [n,m]
  | r > n     = -1
  | otherwise = r
  where b = (n+1) `div` 2 + m - 1
        r = b - b `mod` m

{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
{-# LANGUAGE BangPatterns, TupleSections, OverloadedStrings #-}
import Control.Applicative
import Control.Exception
import Control.Monad
import Control.Monad.ST
import Data.Array.Base
import Data.Array.ST (runSTUArray, STArray, runSTArray)
import Data.Bits
import qualified Data.ByteString.Char8 as B
import Data.Char
import Data.Function
import Data.Int
import Data.List
import qualified Data.Map as M
import qualified Data.Set as S
import Data.STRef
import GHC.Arr (Array, Ix, range, unsafeIndex)
bool :: a -> a -> Bool -> a
bool t f b=if b then t else f
readInt :: B.ByteString -> Int
readInt bs=case B.readInt bs of{Just(n,_)->n;_->error$"readInt error : bs = "++show bs;}
rep, rev :: Monad m => Int -> (Int -> m ()) -> m ()
rep !n f=go 0 where go !i=when(i<n)$f i>>go(i+1)
rev !n f=go(n-1)where go !i=when(i>=0)$f i>>go(i-1)
{-# INLINE rep #-}
{-# INLINE rev #-}
for :: Monad m => Int -> (Int -> Bool) -> (Int -> Int) -> (Int -> m ()) -> m ()
for !i0 p next f=go i0 where go !i=when(p i)$f i>>go(next i)
{-# INLINE for #-}
modifyArray :: (MArray a e m, Ix i) => a i e -> i -> (e -> e) -> m ()
modifyArray a i f=readArray a i>>=writeArray a i.f
{-# INLINE modifyArray #-}
unsafeModify :: (MArray a e m, Ix i) => a i e -> Int -> (e -> e) -> m ()
unsafeModify a i f=unsafeRead a i>>=unsafeWrite a i.f
{-# INLINE unsafeModify #-}

main :: IO ()
main = do
  [n,m] <- map read.words <$> getLine :: IO [Int]
  case [k|k<-[m,m+m..n],let a=2*k-n, let b=n-k, a>=0, b>=0] of
    [] -> print (-1)
    xs -> print $ head xs

#!/usr/bin/env runghc
main = getContents >>= mapM_ print . solve . lines
solve = map (f . map read . words)
f [n,m]
  | n==0 = 0
  | n<m = -1
  | otherwise = (((n+1)`div`2)+(m-1))`div`m*m

import Control.Applicative

main=do
	[n,m]<-map read.words <$> getLine::IO [Int]
	let ans = ( div n 2 )+ ( if odd n then 1 else 0)
	print $ if (m>n) then (-1) else (((div ans m)+(if mod ans m >0 then 1 else 0))*m)

main = do
  [n, m] <- getLine >>= return. map read. words :: IO [Int]
  let idx = [i | i <- [div (n + 1) 2 .. n], mod i m == 0]
  print $ if (not.null $ idx) then head idx else -1

main = interact $ show . f . map (read :: String -> Int) . words where
    f [n, m] = _f (div n 2) n m
    _f (-1) _ _ = -1
    _f x n m
        | mod (n - x) m == 0 = n - x
        | otherwise = _f (x - 1) n m

import Data.List

cal ls = if length res == 0 then "-1" else show $ minimum res
  where  xs = map read $ words $ head $ lines ls
         n = head xs
         m = head $ tail xs
         dm = divMod n 2
         min = (uncurry (+)) dm
         res = [i | i <- [min .. n], i `mod` m == 0]

main = interact cal

main :: IO ()
main = interact solve

minMoves :: Int -> Int -> Int
minMoves n m
    | moves <= n && n <= 2 * moves = moves
    | otherwise = -1
    where moves = m * (n `divUp` (2 * m))

divUp :: (Integral a) => a -> a -> a
divUp a b =  (a + b - 1) `div` b

solve :: String -> String
solve s = show $ minMoves n m
    where (n:m:_) = fmap read . words $ s

climb :: Int -> Int -> Int -> Int
climb _ 0 _ = -1
climb moves stairs m
    | even stairs && ((steps + moves) `mod` m == 0) = moves + steps
    | odd stairs && ((steps + moves + 1) `mod` m == 0) = moves + steps + 1
    | otherwise = climb (moves + 1) (stairs - 1) m
        where steps = quot stairs 2

main = do
    [stairs, m] <- fmap (map read . words) getLine
    print $ climb 0 stairs m

getAnswer :: Integer -> Integer -> Integer
getAnswer n m = quantify n 1 m

quantify :: Integer -> Integer -> Integer -> Integer
quantify limit current divisor = if current > limit
                                 then -1
                                 else if satisfy limit current divisor
                                 then current
                                 else quantify limit (current + 1) divisor

satisfy :: Integer -> Integer -> Integer -> Bool
satisfy limit steps divisor = if steps `mod` divisor == 0 && steps >= allowed
                              then True
                              else False
    where allowed = limit `div` 2

main :: IO ()
main = do
    numbers <- getLine
    let [n, m] = map read (words numbers)
    print (getAnswer n m)

import Data.List
main = interact $show.solve.map read.words

solve::[Int]->Int
solve (n:m:[]) = getRes $ find (comp m) [div n 2..n]

comp m n | mod n m == 0  = True
         | otherwise = False

getRes::Maybe Int->Int
getRes (Just n) = n
getRes Nothing = -1

import Data.Char

h :: Int -> Int -> Int -> Int
h n m x
 | n-2*m >= 2*m = h (n-2*m) m (x+m)
 | n >= 2*m = x + 2*m
 | n >= m = x+m
 | otherwise = -1

--main = do
-- line <- getLine
-- print (h line [])

main = do
 line <- getLine
 let a = (read (takeWhile (/= ' ') line) :: Int)
 let b = (read (drop 1 (dropWhile (/= ' ') line)) :: Int)
 print (h a b 0)

import Data.Char

h :: Int -> Int -> Int -> Int
h n m x
 | n-2*m >= m = h (n-2*m) m (x+m)
 | n >= m = x+m
 | otherwise = -1

--main = do
-- line <- getLine
-- print (h line [])

main = do
 line <- getLine
 let a = (read (takeWhile (/= ' ') line) :: Int)
 let b = (read (drop 1 (dropWhile (/= ' ') line)) :: Int)
 print (h a b 0)

import Control.Applicative
import Data.List

process n m | mod nos m ==0 = nos
            | nos < m = -1
            | otherwise = nos +m -(mod nos m)
   where nos = div (n+1) 2

main = do
  [n,m]<-  map read  <$>   words  <$> getLine ::IO [Int]
  print $ process n m

#!/usr/bin/env runghc
main = getContents >>= mapM_ print . solve . lines
solve = map (f . map read . words)
f [n,m]
  | n<m = -1
  | otherwise = ((n`div`2)+(m-1))`div`m*m

#!/usr/bin/env runghc
main = getContents >>= mapM_ print . solve . lines
solve = map (f . map read . words)
f [n,m]
  | n==0 = 0
  | n<m = -1
  | otherwise = ((n`div`2)+(m-1))`div`m*m

import Control.Applicative

main=do
	[n,m]<-map read.words <$> getLine::IO [Int]
	let ans = ( div n 2 )+ ( if odd n then 1 else 0)
	print $ if (m>n) then (-1) else ((div ans m)+(if mod ans m >0 then 1 else 0)*m)

import Control.Applicative

main=do
	[n,m]<-map read.words <$> getLine::IO [Int]
	let ans = ( div n 2 )+ ( if odd n then 1 else 0)
	print $ if (m>n) then (-1) else (((div ans m)+1)*m)

main :: IO ()
main = interact solve

minMoves :: Int -> Int -> Int
minMoves n m
    | moves <= n && n < 2 * moves = moves
    | otherwise = -1
    where moves = m * (n `divUp` (2 * m))

divUp :: (Integral a) => a -> a -> a
divUp a b =  (a + b - 1) `div` b

solve :: String -> String
solve s = show $ minMoves n m
    where (n:m:_) = fmap read . words $ s

climb :: Int -> Int -> Int -> Int
climb _ 0 _ = -1
climb moves stairs m
    | even stairs && ((steps + moves) `mod` m == 0) = moves + steps
    | odd stairs && ((steps + moves) + 1 `mod` m == 0) = moves + steps + 1
    | otherwise = climb (moves + 1) (stairs - 1) m
        where steps = quot stairs 2

main = do
    [stairs, m] <- fmap (map read . words) getLine
    print $ climb 0 stairs m


canBuy :: Int -> Bool
canBuy x | x < 0          = False
         | x == 0         = True
         | x `mod` 3 == 0 = True
         | x `mod` 7 == 0 = True
         | x < 7          = canBuy (x - 3)
         | otherwise      = canBuy (x - 7)

showResult :: Bool -> String
showResult True = "YES"
showResult False = "NO"

main :: IO ()
main = do
    cases <- fmap (read :: String -> Int) getLine
    results <- sequence $ replicate cases getLine
    mapM_ putStrLn (map (showResult . canBuy . (read :: String -> Int)) results)
    return ()

module Main where
import qualified Data.ByteString.Char8 as B
import Control.Monad
import Control.Monad.Trans.State.Lazy
import Data.Bool

main = B.interact exec
exec = B.pack . evalState app . B.words
app = (unlines . map (bool "NO" "YES" . solve)) `fmap` (flip replicateM poi =<< poi)
  where
  pop = state $ \(x:xs) -> (x, xs)
  poi = fmap int pop
  int = maybe undefined fst . B.readInt

solve x = or [3*a + 7*b == x| a <- [0..100], b <- [0..100]]

main :: IO ()
main =
    interact
    $ unlines
    . map
        ((["NO", "YES"] !!)
        . fromEnum
        . (`elem` [3 * a + 7 * b | a <- [0 .. 100], b <- [0 .. 100]])
        . read
        )
    . tail
    . words

main = getLine >> interact (unlines . solve . map read . lines)

solve [] = []
solve (n:ns)
    | filter (\t -> (n - 3*t) `mod` 7 == 0) [0 .. (n `div` 3)] == [] = "NO":(solve ns)
    | otherwise = "YES":(solve ns)

g=1000000007::Integer

f :: Int->String
f n
  |n<0="NO"
  |n `mod` 7==0="YES"
  |otherwise=f (n-3)

main = do
       a<-getLine
       b<-getContents
       let xs=map read (lines b)::[Int]
       mapM_ putStrLn $ map f xs

main = interact $ unlines . map (solve . read) . tail . words
solve n | null [ () | i <- [0..33], j <- [0..14], 3*i+7*j == n ] = "NO"
        | otherwise = "YES"

groupOn :: Int -> [a] -> [[a]]
groupOn _ [] = []
groupOn n xs = let (sts, nds) = splitAt n xs in sts : groupOn n nds
-------------------------------------------------------------------------------

main = interact $ unlines . parse . lines

parse (_:ops') = map sol ops
  where
    ops = map (fn . words) ops'
    fn :: [String] -> Int
    fn [b] = read b

sol a = res
  where
    res = sol' a
    sol' a
      | a < 0 = "NO"
      | a `mod` 3 == 0 = "YES"
      | otherwise = sol' (a-7)

canBuy :: Int -> Bool
canBuy x = x `mod` 3 == 0 || x `mod` 7 == 0

showResult :: Bool -> String
showResult True = "YES"
showResult False = "NO"

main :: IO ()
main = do
    cases <- fmap (read :: String -> Int) getLine
    results <- sequence $ replicate cases getLine
    mapM_ putStrLn (map (showResult . canBuy . (read :: String -> Int)) results)
    return ()

canBuy :: Int -> Bool
canBuy x | x < 0        = False
         | x == 0       = True
         | x < 7        = canBuy (x - 3)
         | otherwise    = canBuy (x - 7)

showResult :: Bool -> String
showResult True = "YES"
showResult False = "NO"

main :: IO ()
main = do
    cases <- fmap (read :: String -> Int) getLine
    results <- sequence $ replicate cases getLine
    mapM_ putStrLn (map (showResult . canBuy . (read :: String -> Int)) results)
    return ()

main = interact $ unlines . map (show . solve . read) . tail . words
solve n | null [ () | i <- [0..33], j <- [0..14], 3*i+7*j == n ] = "NO"
        | otherwise = "YES"


import Data.Bits
main=interact$show.f.map read.words
f :: [Integer] -> Integer
f[l,r]=last.(0:).takeWhile(<2*(l`xor`r)).map pred$iterate(2*)1

import Control.Applicative
import Data.Bits

gao :: Int -> (Integer, Integer) -> (Integer, Integer) -> Integer
gao p r1 r2
  | r1 == (0, mm) = mm
  | r2 == (0, mm) = mm
  | otherwise     = maximum $ [u1 `xor`  u2 `xor` gao (p - 1) w1 w2 |
      (u1, v1) <- f r1, (u2, v2) <- f r2, let w1 = g v1, let w2 = g v2]
  where
    mm = bit (p + 1) - 1
    b = bit p
    m = b - 1
    f (x, y) = filter (uncurry (<=) . snd) [
      (0, (x, min y m)), (b, (max x b, y))]
    g (x, y) = (x .&. m, y .&. m)

main :: IO ()
main = do
  [l, r] <- map read <$> words <$> getLine
  print $ gao 100 (l, r) (l, r)

import Data.Bits
import Data.Int
main :: IO()
main = do
    [b,a] <- fmap ((map read) . words) getLine :: IO [Int64]
    let l = reverse $ zip (bits a []) (bits b [0,0..])
        l' = dropWhile (\(x1,x2) -> x1==x2) l
        ans = bit $ length l' :: Int64
    print (ans-1)

bits 0 t = t
bits n t = n `rem` 2 : bits (n `quot` 2) t

import Control.Monad
import Data.Bits

readi :: [Char] -> Integer
readi x = read x :: Integer

func1 l r = foldl (max) 0 $ (foldl (++) []) $ [map (xor x) [l..r] | x <- [l..r]]

maxdig = 70

func2 l r = (foldl (max) 0 $ filter (\x -> (m .&. x) /= 0) (map (2^) [0..maxdig]))*2 - 1
	where m = xor l r

main = do
	[l, r] <- ((map readi) . words) `liftM` getLine
	putStr $ show $ max (func2 l r) 0

import Control.Monad
import Data.Bits

readi :: [Char] -> Integer
readi x = read x :: Integer

func1 l r = foldl (max) 0 $ (foldl (++) []) $ [map (xor x) [l..r] | x <- [l..r]]

maxdig = 70

func2 l r = (foldl (max) 0 $ filter (\x -> (m .&. x) /= 0) (map (2^) [0..maxdig]))*2 - 1
	where m = xor l r

main = do
	[l, r] <- ((map readi) . words) `liftM` getLine
	putStr $ show $ func2 l r


ri :: String -> Integer
ri = read

myDiv :: Integer -> Integer -> Integer
myDiv x y  | rem x y /= 0 = (div x y) + 1
           | otherwise = div x y

calc :: [Integer] -> Integer
calc [n,m,a] = (myDiv n a) * (myDiv m a)

main = do
     line <- getLine

     print $ calc (map ri (words line))

import Control.Applicative

main = do
  [n, m, a] <- (map read . words) <$> getLine
  print $ (div (n+a-1) a)*(div (m+a-1) a)

ans :: Integer -> Integer  -> Integer  -> Integer
ans n m a = x * y
 where x = if n `mod` a == 0 then n `div` a else (n `div` a) + 1
       y = if m `mod` a == 0 then m `div` a else (m `div` a) + 1

main = do
	inp <- getLine
	let (n : m : a : []) = map read (words inp) :: [Integer]
	putStrLn $ show $ ans n m a

import Data.Word

solve:: (Integral a) => a -> a -> a -> a
solve n m a = (ceilDiv n a) * (ceilDiv m a)
    where
        ceilDiv = \x y -> (div x y) + (if (mod x y) > 0 then 1 else 0)

main :: IO ()
main = do
    --let input = "1000000000 1000000000 192"
    input <- getLine :: IO String
    let [n, m, a] = map (read :: String -> Word64) $ words input
    print $ solve n m a

import Control.Applicative

main = do
  [n, m, a] <- (map read . words) <$> getLine
  print $ (div (n+a-1) a) *(div (m+a-1) a)

main= readsoveprint
readsoveprint::IO()
readsoveprint=getLine >>= print . solve .isdata
solve :: [Int]->Integer
solve [x,y,z]=(ceiling $ fromIntegral x/ fromIntegral z) *  (ceiling $ fromIntegral y/ fromIntegral z)
isdata :: String->[Int]
isdata x= map read  $ words x

-- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-- File Name : 0001A.hs
-- Creation Date : 17-10-2012
-- Last Modified : Fri 19 Oct 2012 01:44:16 PM EEST
-- Created By : Greg Liras <gregliras@gmail.com>
--_._._._._._._._._._._._._._._._._._._._._.

{-# OPTIONS_GHC -O2 -optc-O2 #-}

import Data.Char (isSpace)
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as BSC

calcTiles len side =
    let
        x = ceiling $ fromIntegral len / fromIntegral side
    in
        case x of
            0 -> 1
            _ -> x

main :: IO ()
main =
    do
        all <- BS.getContents
        let Just (n, r1)    = readInt all
        let Just (m, r2)    = readInt r1
        let Just (a, _)     = readInt r2
        let x = fromIntegral $ (calcTiles n a) * (calcTiles m a)
        print $ x
    where
        readInt s = BSC.readInt (BSC.dropWhile isSpace s)
        readInteger s = BSC.readInteger (BSC.dropWhile isSpace s)
        readMany readf s = case readf s of
            Just (x, r) ->  let
                                (xs, t) = readMany readf r
                            in
                                (x : xs, t)
            Nothing     ->  ([], s)

str2int_list :: String -> [Int]
str2int_list = map read . words

stonesNeeded x a =
    let quotient = div x a
        has_remainder = fromEnum (mod x a /= 0)
    in quotient + has_remainder

main = do
    input <- getLine :: IO String
    let [n, m, a] = str2int_list input
        stonesNeededBy x = stonesNeeded x a
        answer = (toInteger $ stonesNeededBy n) * (toInteger $ stonesNeededBy m)
    print answer

{-# LANGUAGE CPP, TemplateHaskell #-}
-----------------------------------------------------------------------------
--
-- Module      :  Main
-- Copyright   :
-- License     :  AllRightsReserved
--
-- Maintainer  :
-- Stability   :
-- Portability :
--
-- |
--
-----------------------------------------------------------------------------

module Main (
    main
) where

import Control.Monad (unless)
import Data.List (stripPrefix)
import System.Exit (exitFailure)
--import Test.QuickCheck.All (quickCheckAll)

-- Simple function to create a hello message.
hello s = "Hello " ++ s

fun n a = ((div n a) + if mod n a >0 then 1 else 0)

count n m a =  (fun n a )* (fun m a)

-- Hello World
main = do
      [n, m, a] <- (map read . words) `fmap` getLine
      print ( count n m a)

-- Entry point for unit tests.
--testMain = do
--    allPass <- $quickCheckAll -- Run QuickCheck on all prop_ functions
--    unless allPass exitFailure

-- This is a clunky, but portable, way to use the same Main module file
-- for both an application and for unit tests.
-- MAIN_FUNCTION is preprocessor macro set to exeMain or testMain.
-- That way we can use the same file for both an application and for tests.
#ifndef MAIN_FUNCTION
#define MAIN_FUNCTION exeMain
#endif
--main = MAIN_FUNCTION

squares n m a
    | n < a        = 1              * divma
    | mod n a == 0 = (div n a    )  * divma
    | mod n a /= 0 = (div n a + 1)  * divma
    where
      divma
        | m <  a  = 1
        | m >= a  = if mod m a == 0 then div m a else div m a + 1

main = do
  numbers <- getLine
  let n = read ((words numbers) !! 0) :: Integer
  let m = read ((words numbers) !! 1) :: Integer
  let a = read ((words numbers) !! 2) :: Integer
  print (squares n m a)

main = do
  [a, b, c] <- (read <$>) <$> words <$> getLine
  print $ div (a + c - 1) c * div (b + c - 1) c

main = do
  line <- getLine
  let [m, n, a] = map read (words line) :: [Integer]
  print $ div (m+a-1) a * div (n+a-1) a

ceildiv m n = m `div` n + if m `mod` n == 0 then 0 else 1

main = do
  line <- getLine
  let [m, n, a] = map read (words line) :: [Integer]
  putStrLn . show $ ceildiv m a * ceildiv n a

module Main where

parseInts :: String -> [Integer]
parseInts = map (read :: String -> Integer) . words

divUp n a = (div n a) +
    if (mod n a) > 0
       then 1
       else 0

main = do
    answer <- getLine
    let [n, m, a] = parseInts answer
    print $ (divUp n a) * (divUp m a)
    return ()

calcStones :: [Integer] -> Integer
calcStones [x, y, z] = row * column
  where
    row = ceiling $ (fromInteger x) / (fromInteger z)
    column = ceiling $ (fromInteger y) / (fromInteger z)

main = do
  inputList <- getLine >>= return . words
  print $ calcStones $ map (\x -> read x :: Integer) inputList

import Control.Monad

main :: IO ()
main = do
    line <- getLine
    let n:m:a:xs = fmap (\x -> read x :: Int) $ words line
    print (toInteger (coveringStones n a) * toInteger (coveringStones m a))

coveringStones :: Int -> Int -> Int
coveringStones l a =(div l a) + if (mod l a == 0) then 0 else 1

main=interact(unlines.map f.lines)
f s=do show$ceiling(n/a)*ceiling(m/a)
 where [n,m,a]=map read(words s)

main=interact(unlines.map  f.lines)
f s=do show(ceiling(n/a)*ceiling(m/a))
    where [n, m, a]=(map read (words s))

main = do
	contents <- getContents
	let
	   numbers = map (\str -> read str :: Int) $ words contents
	   n = numbers !! 0
	   m = numbers !! 1
	   k = numbers !! 2
	print $ (toInteger $ f n k) * (toInteger $ f m k)

f :: Int -> Int -> Int
f n k = if n `mod` k == 0
	then n `div` k
	else (n `div` k) + 1

import Data.Int

parseString :: String -> [Int64]
parseString str = map (\x -> read x::Int64) $ words str

solution :: Int64 -> Int64 -> Int64 -> Int64
solution n m a = (fst x1 + y x1) * (fst x2 + y x2)
    where
        x1 = divMod n a
        x2 = divMod m a
        y x = if snd x == 0 then 0 else 1

main :: IO()
main = do
    a <- getLine
    print $ solution ((ps a)!!0) ((ps a)!!1) ((ps a)!!2)
    where ps = parseString

module Main where

import Control.Monad (sequence)
import qualified Data.ByteString.Char8 as BS

main :: IO ()
main = do
  result <- (fmap (map fst)
             . sequence
             . map BS.readInteger
             . BS.words) `fmap` BS.getLine
  case result of
    Just (n : m : a : _)
      | flagstoneArea == 1 -> print area
      | flagstoneArea > area -> print 1
      | otherwise ->
        print ((ceiling ((fromIntegral n) / (fromIntegral a))) *
               (ceiling ((fromIntegral m) / (fromIntegral a))))
      where
        area = n * m
        flagstoneArea = a * a
    Nothing -> error ("err: invalid input " ++ show result)

main :: IO ()
main = interact func

func :: String -> String
func s = show . func' . map read $ words s

func' :: [Integer] -> Integer
func' (n:m:a:[]) = (m `div` a + (m `dived` a)) * (n `div` a + (n `dived` a))
  where dived x y = if x `mod` y == 0 then 0 else 1
func' _ = error ""

main :: IO ()
main = interact func

func :: String -> String
func s = show . func' . map read $ words s

func' :: [Integer] -> Integer
func' (n:m:a:[]) = (m `div` a + (m `dived` a)) * (n `div` a + (n `dived` a))
  where dived x y = if x `mod` y == 0 then 0 else 1

main :: IO ()
main = do
    s <- getLine
    putStrLn $ (coverSquare' . (map read) . words) s
    return ()

coverSquare' :: (Show a, Integral a) => [a] -> String
coverSquare' [n,m,a] = show $ coverSquare n m a
coverSquare' _       = "coverSquare': Invalid number of arguments."

coverSquare :: Integral a => a -> a -> a -> a
coverSquare n m a = (n `quot'` a) * (m `quot'` a)
  where
    c `quot'` d = (c `quot` d) + (if c `rem` d > 0 then 1 else 0)

main = do
    (n:m:[a]) <- map read <$> words <$> getLine
    print $ (n `divUp` a) * (m `divUp` a) where
        divUp a b = ceiling (fromIntegral a / fromIntegral b)

module Main (main) where

import System
import Data.Char
import Data.List
import Control.Monad
import Control.Applicative

solve n m a = ((n-1) `div` a + 1)*((m-1) `div` a + 1)

main = do line <- getLine
          let arr = words line
          let [n,m,a] = map read arr :: [Integer]
          print $ solve n m a
          return ()

module Main where

requiredCount :: Integer -> Integer -> Integer
requiredCount size tileSize = (size - 1) `div` tileSize + 1

solution :: Integer -> Integer -> Integer -> String
solution n m a = show $ (requiredCount n a) * (requiredCount m a)

main::IO()
main = do
    line <- getLine
    let [nString, mString, aString] = words line
    let n = read nString :: Integer
    let m = read mString :: Integer
    let a = read aString :: Integer
    putStr $ solution n m a

main :: IO ()
main = interact func

func :: String -> String
func s = show . func' . map read $ words s

func' :: [Integer]  ->   Integer
func' (n:m:a:[]) = (m `div` a + (m `dived` a)) * (n `div` a + (n `dived` a))
  where dived x y = if x `mod` y == 0 then 0 else 1
func' _ = error ""

import Control.Applicative
main= do
	[n,m,a]<- map read. words <$> getLine:: IO [Integer]
	let x = ( div n a) + if ( mod n a ==0) then 0 else 1
	let y = ( div m a) + if ( mod m a ==0) then 0 else 1
	print $ x*y

main :: IO ()
main = do
	--nmpStr <- readFile "input.txt"
	nmpStr <- getLine
	let n : m : p : [] = map (read :: String -> Integer) $ words nmpStr
	print ((if ((mod n p) /= 0) then (div n p + 1) else div n p) * (if ((mod m p) /= 0) then (div m p + 1) else div m p))
	return ()

module Main where

main :: IO ()
main = do
        line <- getLine
        let i = map (read :: String->Int) $ words line
        let n = fromIntegral $ i !! 0
        let m = fromIntegral $ i !! 1
        let a = fromIntegral $ i !! 2
        print $ (ceiling $ m / a) * (ceiling $ n / a)

--ghc 7.10

import Control.Applicative
import Control.Monad
import System.IO

readNumbers :: String -> [Integer]
readNumbers = map read . words

res n a = if (mod n a == 0) then div n a else 1 + div n a

-- IO Monad
main :: IO ()
main = do
    l1 <- getLine
    let aye = readNumbers l1
        n = aye!!0
        m = aye!!1
        a = aye!!2
    print(res n a * res m a)

module Main where

import Control.Applicative ((<$>), pure)
import Data.Word (Word64)

input :: IO (Word64, Word64, Word64)
input = do
  [n, m, a] <- fmap read . words <$> getLine
  pure (n, m, a)

count :: Word64 -> Word64 -> Word64
count x y =
  let n = x `div` y
      in if x `mod` y /= 0
         then n + 1
         else n

main :: IO ()
main = do
  (n, m, a) <- input
  print $ count n a * count m a

a meiapal resto
    | null resto = (meiapal, resto)
    | otherwise = (\(r:rs)->if r==' ' then (meiapal, rs) else a (meiapal++[r]) rs) resto

pri resu rest
    | null rest = (resu, rest)
    | otherwise = (\(pal, resto)->pri (resu++[pal]) resto) (a [] rest)

separa str = fst (pri [] str)

sq n m a
    | a==1 = m*n
    | (mod n a) == 0 = sq (n-1) m a
    | (mod m a) == 0 = sq n (m-1) a
    | otherwise = ((div m a)+1)*((div n a)+1)

sqn l = let a:b:c:_=l in sq a b c

main = do
    s <- getLine
    putStrLn (show(sqn (let readInt a = read a::Integer in map readInt (separa s))))

ans :: [Integer] -> Integer
ans (x : (y : (z : xs))) = ((x + z - 1) `div` z) * ((y + z - 1) `div` z)

main = do
    d <- getLine
    putStr (show (ans (map read (words d))))

module Main where

import           Control.Applicative

f :: Double -> Double -> Double -> Integer
f n m a = g n * g m
  where
    g x = ceiling $ (/) x a

main :: IO ()
main = do
  (n:m:a:_) <- words <$> getLine
  putStrLn $ show $ f (read n) (read m) (read a)

(|>) a b = b a

f n m a =
  ceiling ((fromIntegral n) / (fromIntegral a))
  * ceiling ((fromIntegral m) / (fromIntegral a))

main = do
  s <- getLine
  let a = s |> words |> map (read :: String -> Int)
  f (a !! 0) (a !! 1) (a !! 2) |> print

module Main where

import Control.Monad
import Data.List

getUpperBound :: Integer -> Integer -> Integer
getUpperBound x y
    | mod x y == 0 = quot x y
    | otherwise    = (quot x y) + 1

theaterSquare :: [Integer] -> Integer
theaterSquare (x:y:z:_) = (getUpperBound x z) * (getUpperBound y z)

main :: IO()
main = do
    input <- getLine
    let arr = Data.List.map (read :: String -> Integer) . words $ input
    print . theaterSquare $ arr

getDiv :: Integer -> Integer -> Integer
getDiv x a = x `div` a

getMul :: Integer -> Integer -> Integer
getMul x a
 | x `mod` a == 0 = getDiv x a
 | otherwise = getDiv x a + 1

main :: IO ()
main = do
 num <- fmap (map read.words) getLine
 let a = last num
 print $ getMul (num !! 0) a * getMul (num !! 1) a

import Data.Int
import Control.Applicative

findFlagstoneNumber :: Int64 -> Int64 -> Int64 -> Int64
findFlagstoneNumber n m a
  = solve1d n * solve1d m
  where solve1d x = div (x + a - 1) a

solve :: String -> String
solve str
  | [n, m, a] <- read <$> words str
  = show $ findFlagstoneNumber n m a

main :: IO ()
main = interact solve

import Data.List

solve :: [Integer] -> Integer
solve [n, m, a] = (div (n + a - 1)  a) * (div (m + a - 1) a)

--splitTokens :: String -> [String]
--splitTokens "" = []
--splitTokens (x:xs) = getTokens (x:xs) ""
--                    where getTokens "" s = [s]
--                          getTokens (y:ys) s = if y == ' ' the
main = do
    z <- getLine
    putStrLn $ show $ solve $ map read (words z)

import Data.Int
findFlagstoneNumber :: [Int64] -> Int64
findFlagstoneNumber args
  | [n, m, a] <- args
  = div (n + a - 1) a
    * div (m + a - 1) a

solve :: String -> String
solve str
  = (show $ findFlagstoneNumber $ map (\x -> read x) $ words str)
    ++ "\n"

main :: IO ()
main = interact solve

import Data.Int
import Control.Applicative

findFlagstoneNumber :: Int64 -> Int64 -> Int64 -> Int64
findFlagstoneNumber n m a
  = foldl1 (*) $ solve1D <$> [n, m]
    where solve1D = (`div` a) . (+) (a - 1)

main :: IO ()
main = do
  [n, m, a] <- map read <$> words <$> getLine
  print $ findFlagstoneNumber n m a

module Main where
main = interact $ match . fmap read . words

match [n, m, a] = show $ solve n m a
match _ = error "Input mismatch"

--solve :: Integer -> Integer -> Integer -> Integer
solve :: (Integral a) => a -> a -> a -> a
solve n m a = divUp n a * divUp m a

divUp :: (Integral a) => a -> a -> a
divUp a b =  (a + b - 1) `div` b

module Main where

import Data.Int (Int64)

main :: IO ()
main = mapM_ (print . (\[m, n, a] -> f m n a) . map read . words) . lines =<< getContents

f :: Int64 -> Int64 -> Int64 -> Int64
f n m a = ceiling (fromIntegral n / fromIntegral a) * ceiling (fromIntegral m / fromIntegral a)

import Data.Int
import Control.Applicative

findFlagstoneNumber :: Int64 -> Int64 -> Int64 -> Int64
findFlagstoneNumber n m a
  = solve1d n * solve1d m
  where solve1d x = div (x + a - 1) a

solve :: String -> String
solve str
  | [n, m , a] <- read <$> words str
  = show $ findFlagstoneNumber n m a

main :: IO ()
main = interact solve

import Data.Int
findFlagstoneNumber :: Int64 -> Int64 -> Int64 -> Int64
findFlagstoneNumber n m a
  = div (n + a - 1) a * div (m + a - 1) a

solve :: String -> String
solve str
  | [n, m, a] <- map (\x -> read x) $ words str
  = show $ findFlagstoneNumber n m a

main :: IO ()
main = interact solve

import Data.Int
findFlagstoneNumber :: Int64 -> Int64 -> Int64 -> Int64
findFlagstoneNumber n m a
  = div (n + a - 1) a
    * div (m + a - 1) a

solve :: String -> String
solve str
  = ( show
      $ findFlagstoneNumber
        (read $ args !! 0)
        (read $ args !! 1)
        (read $ args !! 2)
    ) ++ "\n"
  where args = words str

main :: IO ()
main = interact solve

solve' :: [Integer] -> Integer
solve' [n, m, a] = ((n - 1) `quot` a + 1) * ((m - 1) `quot` a + 1)

solve :: IO String -> IO Integer
solve x = fmap (solve'.(map read.words)) x

main :: IO()
main = solve getLine >>= print

main = do
   input <- fmap words getLine
   let ints = (map read input :: [Integer])
   let a = ints !! 0
   let b = ints !! 1
   let c = ints !! 2
   print (calc a b c)

calc a b c = (if mod a c == 0 then div a c else div a c + 1)*(if mod b c == 0 then div b c else div b c + 1)

f :: [String] -> [Integer]
f = map read

--tileCount:: (Integral a) => a -> a-> a
tileCount length side
    | modulus == 0 = quotient
    | otherwise = quotient + 1
    where
        modulus = length `mod` side
        quotient = length `div` side

main = do
    z <- getLine
    let [m, n, a] = f (words z)
    print ((tileCount m a) * (tileCount n a))

main :: IO ()
main = interact $ show . solve . (map read . words) . head . lines

solve :: [Integer] -> Integer
solve [n, m, a] = ((n - 1) `quot` a + 1) * ((m - 1) `quot` a + 1)
solve _ = 0

divUp a b = (a - 1) `div` b + 1
solve [n, m, a] = (n `divUp` a) * (m `divUp` a)
main = interact $ show . solve . map read . words

s[n,m,a]=div (-n) a *  div (-m) a
main=getLine>>=print.s.map read.words

main :: IO ()
main = do
    [n, m, a] <- fmap (map read . words) getLine :: IO [Integer]
    let rp = if mod n a /= 0 then 1 else 0
        rq = if mod m a /= 0 then 1 else 0
        p = (div n a) + rp
        q = (div m a) + rq
    print (p * q)

{-# LANGUAGE OverloadedStrings, ScopedTypeVariables, BangPatterns, PatternGuards, ViewPatterns, RecordWildCards, ForeignFunctionInterface, CPP, TypeSynonymInstances, FlexibleInstances, FlexibleContexts, ImplicitParams #-}
{-# OPTIONS_GHC -O2 -Wall -fno-warn-unused-do-bind -fno-warn-type-defaults -fno-warn-unused-imports #-}

import Control.Applicative
import Control.Monad
import Foreign
import Foreign.C
import Data.List
import qualified Data.ByteString.Char8 as BS
-- import qualified Data.Map as Map
-- import qualified Data.Set as Set

main :: IO ()
main = do
  n   :: Integer        <- input
  m   :: Integer        <- input
  a   :: Integer        <- input
  output' $ ((n - 1) `quot` a + 1) * ((m - 1) `quot` a + 1)

--------------------------------------------------
-- Imported C functions
--------------------------------------------------
#define BUFMAX                (100005)

type BString = BS.ByteString

foreign import ccall unsafe "stdio.h scanf"
  c_scanf_i     :: CString -> Ptr Int   -> IO ()
foreign import ccall unsafe "stdio.h scanf"
  c_scanf_i64   :: CString -> Ptr Int64 -> IO ()
foreign import ccall unsafe "stdio.h scanf"
  c_scanf_f     :: CString -> Ptr Float -> IO ()
foreign import ccall unsafe "stdio.h scanf"
  c_scanf_s     :: CString -> CString   -> IO ()
foreign import ccall unsafe "stdio.h printf"
  c_printf_i    :: CString -> Int       -> IO ()
foreign import ccall unsafe "stdio.h printf"
  c_printf_i64  :: CString -> Int64     -> IO ()
foreign import ccall unsafe "stdio.h printf"
  c_printf_d    :: CString -> Double    -> IO ()
foreign import ccall unsafe "stdio.h printf"
  c_printf_s    :: CString -> CString   -> IO ()

fmt_i, fmt_i64, fmt_f, fmt_d, fmt_s :: CString
fmt_i   = unsafePerformIO $ newCString "%d"
fmt_i64 = unsafePerformIO $ newCString "%I64d"
fmt_f   = unsafePerformIO $ newCString "%f"
fmt_d   = unsafePerformIO $ newCString "%.16f"
fmt_s   = unsafePerformIO $ newCString "%s"
{-# NOINLINE fmt_i    #-}
{-# NOINLINE fmt_i64  #-}
{-# NOINLINE fmt_f    #-}
{-# NOINLINE fmt_d    #-}
{-# NOINLINE fmt_s    #-}

ptr_i   :: Ptr Int
ptr_i   = unsafePerformIO malloc
ptr_i64 :: Ptr Int64
ptr_i64 = unsafePerformIO malloc
ptr_f   :: Ptr Float
ptr_f   = unsafePerformIO malloc
ptr_d   :: Ptr Double
ptr_d   = unsafePerformIO malloc
ptr_s   :: CString
ptr_s   = unsafePerformIO $ mallocArray BUFMAX
{-# NOINLINE ptr_i    #-}
{-# NOINLINE ptr_i64  #-}
{-# NOINLINE ptr_f    #-}
{-# NOINLINE ptr_d    #-}
{-# NOINLINE ptr_s    #-}

class Input a           where
  input :: IO a

instance Input Int      where
  input = c_scanf_i fmt_i ptr_i >> peek ptr_i
instance Input Int64    where
  input = c_scanf_i64 fmt_i64 ptr_i64 >> peek ptr_i64
instance Input Integer  where
  input = toInteger <$> (input :: IO Int64)
instance Input Double   where
  input = c_scanf_f fmt_f ptr_f >> realToFrac <$> peek ptr_f
instance Input String   where
  input = c_scanf_s fmt_s ptr_s >> peekCString ptr_s
instance Input BString  where
  input = c_scanf_s fmt_s ptr_s >> BS.packCString ptr_s

class Output a          where
  output_   :: a -> IO ()
  output    :: a -> IO ()
  output    = (>> space  ) . output_
  output'   :: a -> IO ()
  output'   = (>> newline) . output_

instance Output Int     where
  output_   = c_printf_i fmt_i
instance Output Int64   where
  output_   = c_printf_i64 fmt_i64
instance Output Integer where
  output_   = output_ . show
instance Output Double  where
  output_   = c_printf_d fmt_d
instance Output String  where
  output_   = flip withCString (c_printf_s fmt_s)
instance Output BString where
  output_   = flip BS.useAsCString (c_printf_s fmt_s)

space   :: IO ()
space   = output_ (" "  :: String)

newline :: IO ()
newline = output_ ("\n" :: String)

--import System.Environment
import Data.Int

solve n m a =
  hline * vline
  where
    hadd = if n `mod` a > 0 then 1 else 0
    vadd = if m `mod` a > 0 then 1 else 0
    hline = n `div` a + hadd
    vline = m `div` a + vadd

readInts :: IO [Int64]
readInts = fmap (map read.words) getLine

main = do
  (n:m:a:rest) <- readInts
  putStrLn (show $ solve n m a)

{-# OPTIONS_GHC -O2 #-}

main :: IO ()
main = do
  n : m : a : _ <- fmap (map read . words) getLine :: IO [Integer]
  print $ ((n - 1) `quot` a + 1) * ((m - 1) `quot` a + 1)

плиты :: [Integer] -> Integer
плиты (ш:д:пл:[]) = (ceiling (fromInteger ш / fromInteger пл)) * (ceiling (fromInteger д / fromInteger пл))
main = interact $ show . плиты . map read . words

import qualified Data.ByteString.Char8 as B
import Data.Maybe

getThreeIntsM = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

cover x a = toInteger $ x `div` a + (if x `rem` a == 0 then 0 else 1)

main = do
        [n, m, a] <- getThreeIntsM
        putStrLn . show $ (cover n a) * (cover m a)

readInts :: IO [Integer]
readInts = fmap (map read.words) getLine

main = do
    [n, m, a] <- readInts
    putStrLn $ (show (((n + a - 1) `div` a) * ((m + a - 1) `div` a)))

main = fmap (fmap read . words) getLine >>= \[n,m,a] -> print $ (n^/a)*(m^/a) where x^/y = quot (x + y - 1) y

--flagStones :: Fractional a => a -> a -> a -> a
flagStones n m a = (ceiling $ n / a) * (ceiling $ m / a)

main = do
 str <- getLine
 let [n, m, a] = map read . words $ str :: [Double]
 print $ flagStones n m a

#! /usr/bin/runhaskell
module Main where
import System.IO
main = do
  s <- getLine
  let rs = (map read (words s)) :: [Integer]
  let n = head rs
      m = head (tail rs)
      a = last rs
      in putStrLn $ show (ff n a * ff m a)

ff :: Integer -> Integer -> Integer
ff n a = if n `mod` a == 0 then n `div` a
         else n `div` a + 1

module Main (
  main
) where

import Data.Int

solve :: Int64 -> Int64 -> Int64 -> Int64
solve n m a = (n `div1` a) * (m `div1` a)
  where
    div1 x y = (x + y - 1) `quot` y

main :: IO ()
main = do
  [n, m, a] <- getInts
  print $ solve n m a

getInts :: IO [Int64]
getInts = (map read . words) `fmap` getLine :: IO [Int64]

main = do
    [n,m,a] <- fmap (map read . words) $ getLine :: IO [Integer]
    print $ (floor n a) * (floor m a)
    where floor x y = (x + y - 1) `div` y

import GHC.Int

convert :: Read a => String -> [a]
convert = map read . words

main :: IO ()
main = do
  line <- getLine
  let [n, m, a] = convert line :: [GHC.Int.Int64]
  let x = (n - 1) `div` a + 1
  let y = (m - 1) `div` a + 1
  print (x * y)

{-# LANGUAGE ScopedTypeVariables #-}

import Data.List.Split

main :: IO()
main = do
  line :: String <- getLine
  let x = map read $ splitOn " " line :: [Integer]
  let f = \[a,b,c] -> ((-a) `div` c) * ((-b) `div` c)
  print (f x)

squares n m a
    | mod n a == 0 = (div n a    )  * divma
    | mod n a /= 0 = (div n a + 1)  * divma
    where
      divma = if div m a <= 0 then 1 else div m a + 1

main = do
  numbers <- getLine
  let n = read ((words numbers) !! 0) :: Int
  let m = read ((words numbers) !! 1) :: Int
  let a = read ((words numbers) !! 2) :: Int
  print (squares n m a)

main :: IO ()
main = do
	--nmpStr <- readFile "input.txt"
	nmpStr <- getLine
	let n : m : p : [] = map (read :: String -> Int) $ words nmpStr
	print ((if ((mod n p) /= 0) then (div n p + 1) else div n p) * (if ((mod m p) /= 0) then (div m p + 1) else div m p))
	return ()

import System.Environment(getArgs)

p1a :: Double -> Double -> Double -> Int
p1a n m a = ceiling (n / a) * ceiling (m / a)

main :: IO ()
main = do cons <- getContents
          let [n, m, a] = fmap read $ words cons
          print $ p1a n m a

module Main where

import IO
import GHC.Base

main = do

    s <- getLine
    (m:n:a) <- return $ map readint $ split s ' '
    --m1 <- getLine
    --n1 <- getLine
    --a1 <- getLine

    print $ ( (m `roundInt` head a) * (n `roundInt` head a))
roundInt :: Int -> Int -> Int
roundInt a b | a `modInt` b == 0 = a `divInt` b
             | otherwise = a`divInt`b + 1
--readseq :: String -> [Int]
--readseq = read
split :: String -> Char -> [String]
split [] delim = [""]
split (c:cs) delim
   | c == delim = "" : rest
   | otherwise = (c : head rest) : tail rest
   where
       rest = split cs delim
readint :: String -> Int
readint = read

main = do
    [n,m,a] <- fmap (map read . words) $ getLine :: IO [Int]
    print $ (floor n a) * (floor m a)
    where floor x y = (x + y - 1) `div` y

import Control.Applicative

tileCount:: (Integral a) => a -> a-> a
tileCount length side
    | modulus == 0 = quotient
    | otherwise = quotient + 1
    where
        modulus = length `mod` side
        quotient = length `div` side

readInt :: String -> Int
readInt = read

main = do
    [m, n, a] <- (map readInt . words) <$> getLine
    print ((tileCount m a) * (tileCount n a))

--import Helpers
--import Data.String.Utils

{-
indicate :: String -> String
indicate address =
    if address == "127.0.0.1" then "localhost" else address
-}
{-
indicate :: String -> String
indicate "127.0.0.1" = "localhost"
indicate address = address
-}
parseInt :: String -> Int
parseInt x = read x :: Int

solve:: Int -> Int -> Int -> Int
solve n m a = (ceilDiv n a) * (ceilDiv m a)

ceilDiv :: Int -> Int -> Int
ceilDiv x y = (div x y) + (if (mod x y) > 0 then 1 else 0)

main :: IO ()
main = do
    --let input = "6 6 4"
    input <- getLine :: IO String
    let parsed = map parseInt $ words input
    --print parsed
    print $ solve (head parsed) (head $ tail parsed) (head $ tail $ tail parsed)

f :: [String] -> [Int]
f = map read

tileCount:: (Integral a) => a -> a-> a
tileCount length side
    | modulus == 0 = quotient
    | otherwise = quotient + 1
    where
        modulus = length `mod` side
        quotient = length `div` side

main = do
    z <- getLine
    let [m, n, a] = f (words z)
    print ((tileCount m a) * (tileCount n a))

import System.Environment

solve n m a =
  hline * vline
  where
    hadd = if n `mod` a > 0 then 1 else 0
    vadd = if m `mod` a > 0 then 1 else 0
    hline = n `div` a + hadd
    vline = m `div` a + vadd

readInts :: IO [Int]
readInts = fmap (map read.words) getLine

main = do
  (n:m:a:rest) <- readInts
  putStrLn (show $ solve n m a)

solve :: Int -> Int -> Int
solve x y = (x + y - 1) `div` y

main = do
  line <- getLine
  let [n, m, a] = map read $ words line
  print $ ((solve n a) * (solve m a))

module Main (
  main
) where

import Data.Maybe
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as BS8

solve :: Int -> Int -> Int -> Int
solve n m a = (n `div1` a) * (m `div1` a)
  where
    div1 x y = (x `div` y) + if (x `mod` y) == 0 then 0 else 1

main :: IO ()
main = do
  [n, m, a] <- getInts
  print $ solve n m a

getInts :: IO [Int]
getInts = fmap (map readInt . BS8.words) BS.getLine
  where
    readInt =  fst . fromJust . BS8.readInt

import Control.Monad

main :: IO ()
main = do
    line <- getLine
    let n:m:a:xs = fmap (\x -> read x :: Int) $ words line
    print ((coveringStones n a) * (coveringStones m a))

coveringStones :: Int -> Int -> Int
coveringStones l a = (div l a) + if (mod l a == 0) then 0 else 1

(|>) a b = b a

f n m a =
  ceiling ((fromIntegral n) / (fromIntegral a))
  + ceiling ((fromIntegral m) / (fromIntegral a))

main = do
  s <- getLine
  let a = s |> words |> map (read :: String -> Int)
  f (a !! 0) (a !! 1) (a !! 2) |> print

main = do
	input <- getLine
	let n = read $ [input !! 0]
	let m = read $ [input !! 2]
	let a = read $ [input !! 4]
	putStrLn $ show $ (ceiling(n / a)) * (ceiling(m / a))

module Main where

main :: IO ()
main = do
  input <- getLine
  print $ (solve.words) input

solve :: [String] -> Int
solve input = let
  ints = map read input :: [Int]
  [n, m, a] = ints
  nAdd = if div n a == 0 then 0 else 1
  mAdd = if div m a == 0 then 0 else 1
  nPlit = div n a
  mPlit = div m a
  in
   (nPlit + nAdd) * (mPlit + mAdd)

solve :: Int -> Int -> Int -> Int
solve n m a = squares n a * squares m a
squares :: Int -> Int -> Int
squares x a
    | x `mod` a == 0 = x `div` a
    | otherwise = x `div` a + 1
main = do
    numsStr <- getLine
    let [n, m, a] = map read $ words numsStr
    print $ solve n m a

solve :: [Int] -> Int
solve [x, y, a] = (x' + x `quot` a)*(y' + y `quot` a)
  where x' = if x `rem` a == 0 then 0 else 1
        y' = if y `rem` a == 0 then 0 else 1

main = interact (show . solve . map read . words)

{-# LANGUAGE BangPatterns, ViewPatterns, PatternGuards, ScopedTypeVariables #-}
{-# LANGUAGE FlexibleInstances, FlexibleContexts, TypeSynonymInstances #-}
{-# LANGUAGE ForeignFunctionInterface #-}

import Control.Applicative
import Control.Monad
import Data.Int
import Foreign
import Foreign.C
import qualified System.IO.Unsafe as U

main :: IO ()
main = do
  [n, m, a]  :: [Int]   <- replicateM 3 input
  print $ ((n - 1) `quot` a + 1) * ((m - 1) `quot` a + 1)

--------------------------------------------------
-- Helper functions
--------------------------------------------------
for_ :: Int -> Int -> (Int -> IO ()) -> IO ()
for_ begin end k = loop begin
 where
  loop !i = when (i < end) $ k i >> loop (i + 1)

c_bufsize :: Int
c_bufsize = 2 ^ 16

{-# NOINLINE g_buffer #-}
g_buffer :: Ptr ()
g_buffer = U.unsafePerformIO $ mallocBytes c_bufsize

class Input a where
  input :: IO a

instance Input Int where
  input = do
    scan_i c_format_i g_buffer'
    peek g_buffer'
   where
    g_buffer' = castPtr g_buffer :: Ptr Int

foreign import ccall unsafe "stdio.h scanf" scan_i :: CString -> Ptr Int -> IO ()

{-# NOINLINE c_format_i #-}
c_format_i :: CString
c_format_i  = U.unsafePerformIO $ newCString "%d"

instance Input Int64 where
  input = do
    scan_i64 c_format_i64 g_buffer'
    peek g_buffer'
   where
    g_buffer' = castPtr g_buffer :: Ptr Int64

foreign import ccall unsafe "stdio.h scanf" scan_i64 :: CString -> Ptr Int64 -> IO ()

{-# NOINLINE c_format_i64 #-}
c_format_i64 :: CString
c_format_i64  = U.unsafePerformIO $ newCString "%I64d"

instance Input String where
  input = do
    scan_s c_format_s g_buffer'
    peekCString g_buffer'
   where
    g_buffer' = castPtr g_buffer :: CString

foreign import ccall unsafe "stdio.h scanf" scan_s :: CString -> CString -> IO ()

{-# NOINLINE c_format_s #-}
c_format_s :: CString
c_format_s  = U.unsafePerformIO $ newCString "%s"

module Main where
main = do
       inpStr <- getLine
       let [n, m, a] = readIntList inpStr
       print $ solve n m a

readIntList :: String -> [Int]
readIntList = fmap read . words

solve :: Int -> Int -> Int -> Int
solve n m a = (divUp n  a) *  (divUp m a)

divUp :: (Integral i) => i -> i -> i
divUp a b =  (a + b - 1) `div` b

main = putStrLn . show . (\[a,b,c]->((a+c-1) `div` c) * ((b+c - 1 :: Int) `div` c)) . map read . words =<< getLine

module Main where

compute :: Int -> Int -> Int -> Int
compute n m a = ceiling (toRational n / toRational a) * ceiling (toRational m / toRational a)

main :: IO ()
main = do
	input <- getLine
	let tokens = words input;
		n = read (tokens !! 0);
		m = read (tokens !! 1);
		a = read (tokens !! 2) in
		putStrLn (show (compute n m a))

--BEGIN--
mod' :: Int -> Int -> Int
mod' x y | (y > x)   = x
         | otherwise = mod' (x - y) y

_div' :: Int -> Int -> Int -> Int
_div' x y k | (y > x)   = k
            | otherwise = _div' (x - y) y (k + 1)

div' :: Int -> Int -> Int
div' x y = _div' x y 0

main :: IO ()
main = do
--  nmaStr <- readFile "input.txt"
    nmaStr <- getLine
    let n : m : a : [] = map (read :: String -> Int) $ words nmaStr

    let x = div' n a
    let y = div' m a

    let x' = if ((mod' n a) /= 0) then (x + 1) else x
    let y' = if ((mod' m a) /= 0) then (y + 1) else y

    print (x' * y')

    return ()
--END--

module Main where

import Control.Monad (sequence)
import qualified Data.ByteString.Char8 as BS

main :: IO ()
main = do
  result <- (fmap (map fst)
             . sequence
             . map BS.readInt
             . BS.words) `fmap` BS.getLine
  case result of
    Just (n : m : a : _)
      | flagstoneArea == 1 -> print area
      | flagstoneArea > area -> print 1
      | otherwise -> print ((area `div` flagstoneArea) ^ 2)
      where
        area = n * m
        flagstoneArea = a * a
    Nothing -> error ("err: invalid input " ++ show result)

f[n,m,a] = (-n `div` a) * (-m `div` a)
main = interact $ show.f.map read.words

import Control.Monad

fn a x n
    | a * x > n = a
    | otherwise = fn (a+1) x n

main = do
    l <- liftM words getLine
    let [n,m,a] = map read l :: [Int]
    -- print (n,m,a)

    let w = fn 1 4 n
    let h = fn 1 4 m
    -- print (w,h)
    print (w*h)

squares n m a
    | mod n a == 0 = (div n a    )  * divma
    | mod m a /= 0 = (div n a + 1)  * divma
    where
      divma = if div m a == 0 then 1 else div m a + 1

main = do
  numbers <- getLine
  let n = read ((words numbers) !! 0) :: Int
  let m = read ((words numbers) !! 1) :: Int
  let a = read ((words numbers) !! 2) :: Int
  print (squares n m a)

module Main (
  main
) where

import Data.Maybe
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as BS8

solve :: Int -> Int -> Int -> Int
solve n m a = (n `div1` a) * (m `div1` a)
  where
    div1 x y = (x + y - 1) `quot` y

main :: IO ()
main = do
  [n, m, a] <- getInts
  print $ solve n m a

getInts :: IO [Int]
getInts = fmap (map readInt . BS8.words) BS.getLine
  where
    readInt =  fst . fromJust . BS8.readInt

a meiapal resto
    | null resto = (meiapal, resto)
    | otherwise = (\(r:rs)->if r==' ' then (meiapal, rs) else a (meiapal++[r]) rs) resto

pri resu rest
    | null rest = (resu, rest)
    | otherwise = (\(pal, resto)->pri (resu++[pal]) resto) (a [] rest)

separa str = fst (pri [] str)

sq n m a
    | a==1 = m*n
    | (mod n a) == 0 = sq (n-1) m a
    | (mod m a) == 0 = sq n (m-1) a
    | otherwise = ((div m a)+1)*((div n a)+1)

sqn l = let a:b:c:_=l in sq a b c

main = do
    s <- getLine
    putStrLn (show(sqn (let readInt a = read a::Int in map readInt (separa s))))

{-# LANGUAGE ScopedTypeVariables #-}

import Data.List.Split

main :: IO()
main = do
  line :: String <- getLine
  let x = map read $ splitOn " " line :: [Int]
  print $ (((x !! 0) + (x !! 2) - 1) `quot` (x !! 2) *
      ((x !! 1) + (x !! 2) - 1) `quot` (x !! 2))

import Control.Applicative
main= do
	[n,m,a]<- map read. words <$> getLine:: IO [Int]
	let x = ( div n a) + if ( mod n a ==0) then 0 else 1
	let y = ( div m a) + if ( mod m a ==0) then 0 else 1
	print $ x*y

solve [ n, m, a ] = ( n `div` a ) * ( m `div` a )
main = interact $ show . solve . map read . words

module Main where

readParams :: String -> [Int]
readParams line = map (\part -> read part) (split line)

split :: String -> [[Char]]
split [] = [""]
split (c:cs)
	| c == ' ' = "" : rest
	| otherwise = (c : head rest) : tail rest
	where
           rest = split cs

sol :: Int -> Int -> Int -> Int
sol n m a = h * w
	where
		ceil c d = (c+d-1) `div` d
		h = ceil m a
		w = ceil n a

main::IO()
main = do
	inputStr <- getLine
	let params = readParams inputStr in putStrLn $ show $ sol (params !! 0) (params !! 1) (params !! 2)

solve :: Int -> Int -> Int
solve x y = (x + y - 1) `div` y

main = do
  line <- getLine
  let [n, m, a] = map read $ words line
  print $ ((solve n a) * (solve m a))

module Main where

import Data.Int (Int64)

main :: IO ()
main = mapM_ (print . (\[m, n, a] -> f m n a) . map read . words) . lines =<< getContents

f :: Int64 -> Int64 -> Int64 -> Int64
f n m a = round (fromIntegral n / fromIntegral a) * round (fromIntegral m / fromIntegral a)

main :: IO ()
main =  do
  cnt <- getLine
  let [n, m , a] = map read $ words cnt
  print $ bla n m a

bla :: Int -> Int -> Int -> Int
bla n m a =  div n a  + div m a + tmp + tmp2
  where
    tmp = if  mod n a /= 0 then 1 else 0
    tmp2 = if  mod m a /= 0 then 1 else 0

ans :: [Integer] -> Integer
ans (x : (y : (z : xs))) = ((x + z - 1) `div` z) * ((y + z - 1) `div` z)

main = do
    d <- getLine
    print (show (ans (map read (words d))))

module Main where

import Control.Monad (sequence)
import qualified Data.ByteString.Char8 as BS

main :: IO ()
main = do
  result <- (fmap (map fst)
             . sequence
             . map BS.readInt
             . BS.words) `fmap` BS.getLine
  case result of
    Just (n : m : a : _)
      | flagstoneArea == 1 -> print area
      | flagstoneArea > area -> print 1
      | otherwise ->
        print ((ceiling ((fromIntegral n) / (fromIntegral a))) *
               (ceiling ((fromIntegral m) / (fromIntegral a))))
      where
        area = n * m
        flagstoneArea = a * a
    Nothing -> error ("err: invalid input " ++ show result)

module Main where

f :: [Int] -> Int
f [n,m,a] = (div (n+a-1) a) + (div (m+a-1) a)

main = do
    a <- getLine
    print $ f $ map read $ words a

import Data.Char
--flagStones :: Fractional a => a -> a -> a -> a
flagStones n m a = (ceiling $ n / a) * (ceiling $ m / a)

main = do
  str <- getLine
  let n = fromIntegral . digitToInt . head $ str
      m = fromIntegral . digitToInt $ str !! 2
      a = fromIntegral . digitToInt . last $ str
  print $ flagStones n m a

import Data.List

solve :: [Int] -> Int
solve [n, m, a] = (div (n + a - 1)  a) * (div (m + a - 1) a)

--splitTokens :: String -> [String]
--splitTokens "" = []
--splitTokens (x:xs) = getTokens (x:xs) ""
--                    where getTokens "" s = [s]
--                          getTokens (y:ys) s = if y == ' ' the
main = do
    z <- getLine
    putStrLn $ show $ solve $ map read (words z)

to_int_array :: String -> [Int]
to_int_array str = (map read) (words str)

get_count :: Int -> Int -> Int
get_count n a = if mod n a == 0 then div n a else div n a + 1

get_all_counts :: [Int] -> Int
get_all_counts a = get_count (a!!0) (a!!2) * get_count (a!!0) (a!!2)

get_count_string :: String -> String
get_count_string s = show(get_all_counts(to_int_array s))

main = interact(get_count_string)

import Control.Monad

fn a x n
    | a * x > n = a
    | otherwise = fn (a+1) x n

main = do
    l <- liftM words getLine
    let [n,m,a] = map read l :: [Int]
    -- print (n,m,a)

    let w = fn 1 a n
    let h = fn 1 a m
    -- print (w,h)
    print (w*h)

main = print "foobarbaaaaacaaaaaaaaaaaaaa"

import Control.Monad
splitBy :: Char -> [Char] -> [[Char]]
splitBy del = foldr f [[]]
  where f c l@(x:xs) | c == del = []:l
                     | otherwise = (c:x):xs
strToInts :: [Char] -> [Int]
strToInts = (map read).(splitBy ' ')
getIntLine :: IO [Int]
getIntLine = liftM strToInts getLine

udiv :: Int -> Int -> Int
udiv a b = quot (a + b - 1) b

solve (a:b:c:xs) = udiv a c * (udiv b c)

main = do
  x <- getIntLine
  ans <- return $ solve x
  print ans

main = interact $ solve . toInts . head . lines
  where
    toInts :: String -> [Int]
    toInts = map read . words
    solve [n, m, a] = show $ ((n - 1) `quot` a + 1) * ((m - 1) `quot` a + 1)

solve :: [Int] -> Int
solve [x, y, a] = x'*y'
  where x' = ceiling $ (fromIntegral x) / (fromIntegral a)
        y' = ceiling $ (fromIntegral y) / (fromIntegral a)

main = interact (show . solve . map read . words)

squares n m a
    | mod n a == 0 = (div n a    )  * divma
    | mod n a /= 0 = (div n a + 1)  * divma
    where
      divma = if div m a <= 1 then 1 else div m a + 1

main = do
  numbers <- getLine
  let n = read ((words numbers) !! 0) :: Int
  let m = read ((words numbers) !! 1) :: Int
  let a = read ((words numbers) !! 2) :: Int
  print (squares n m a)

import System.Environment(getArgs)

p1a :: Double -> Double -> Double -> Int
p1a n m a = ceiling (n / a) * ceiling (m / a)

main :: IO ()
main = do cons <- getContents
          let [n, m, a] = fmap read $ words cons
          print $ p1a n m a

module Main where

import           Control.Applicative

f :: Integer -> Integer -> Integer -> Integer
f n m a = g n a * g m a
  where
    g x y = x `div` y + 1

main :: IO ()
main = do
  (n:m:a:_) <- words <$> getLine
  putStrLn $ show $ f (read n) (read m) (read a)

f [n, m, a] = (-n / a) * (-m / a)

main = interact $ show.f.map read.words

findFlagstoneNumber :: Int -> Int -> Int -> Int
findFlagstoneNumber n m a
  = div (n + a - 1) a
    * div (m + a - 1) a

solve :: String -> String
solve str
  = ( show
      $ findFlagstoneNumber
        (read $ args !! 0)
        (read $ args !! 1)
        (read $ args !! 2)
    ) ++ "\n"
  where args = words str

main :: IO ()
main = interact solve

module Main where

calcSquaresNeeded :: Integer -> Integer -> Integer -> Integer
calcSquaresNeeded n m a = maximum [1, n `div` a + (rest n a)] * maximum [1, m `div` a + (rest m a)]

rest :: Integer -> Integer -> Integer
rest n a
    | n `mod` a > 0 = 1
    | otherwise = 0

main = do
    s <- getLine
    let input = words s
    print $ show (calcSquaresNeeded (read (input !! 0) :: Integer) (read (input !! 1) :: Integer) (read (input !! 2) :: Integer))

main = do
    [n, a, b] <- fmap (map read . words) getLine
    print $ ((div (a + n - 1) n) * (div (b + n - 1) n))

solve :: Int -> Int -> Int
solve x y = (x + y - 1) `div` y

main = do
  line <- getLine
  let [n, m, a] = map read $ words line
  print $ ((solve n a) * (solve m a))

module Main where

calcSquaresNeeded n m a = maximum [1, n `div` a + (rest n a)] * maximum [1, m `div` a + (rest m a)]

rest n a
    | n `mod` a > 0 = 1
    | otherwise = 0

main = do
    s <- getLine
    let input = words s
    print $ show (calcSquaresNeeded (read (input !! 0) :: Integer) (read (input !! 1) :: Integer) (read (input !! 2) :: Integer))

module Main where

main :: IO ()
main = do
  input <- getLine
  print $ (solve.words) input

solve :: [String] -> Int
solve input = let
  ints = map read input :: [Int]
  [n, m, a] = ints
  nAdd = if mod n a == 0 then 0 else 1
  mAdd = if mod m a == 0 then 0 else 1
  nPlit = div n a
  mPlit = div m a
  in
   (nPlit + nAdd) * (mPlit + mAdd)

main :: IO ()
main = interact func

func :: String -> String
func s = show . func' . map read $ words s

func' :: [Int]  ->  Int
func' (n:m:a:[]) = (m `div` a + (m `dived` a)) * (n `div` a + (n `dived` a))
  where dived x y = if x `mod` y == 0 then 0 else 1
func' _ = error ""

main = do
	contents <- getContents
	let
	   numbers = map (\str -> read str :: Int) $ words contents
	   n = numbers !! 0
	   m = numbers !! 1
	   k = numbers !! 2
	print $ toInteger $ f n k * f m k

f :: Int -> Int -> Int
f n k = if n `mod` k == 0
	then n `div` k
	else (n `div` k) + 1

{-# LANGUAGE ScopedTypeVariables #-}

import Data.List.Split

main :: IO()
main = do
  line :: String <- getLine
  let x = map read $ splitOn " " line :: [Int]
  print $ (((x !! 0) + (x !! 2) - 1) `quot` (x !! 2) *
      ((x !! 1) + (x !! 2) - 1) `quot` (x !! 2))

parseString :: String -> [Int]
parseString str = map (\x -> read x::Int) $ words str

solution :: Int -> Int -> Int -> Int
solution n m a = (fst x1 + y x1) * (fst x2 + y x2)
    where
        x1 = divMod n a
        x2 = divMod m a
        y x = if snd x == 0 then 0 else 1

main :: IO()
main = do
    a <- getLine
    print $ solution ((ps a)!!0) ((ps a)!!1) ((ps a)!!2)
    where ps = parseString

main :: IO ()
main = do
    [n, m, a] <- fmap (map read . words) getLine :: IO [Int]
    let r = if (n * m) /= 0 then 1 else 0
        p = (div n a) + r
        q = (div m a) + r
    print (p * q)

calc :: Int -> Int -> Int
calc a c = ceiling $ (fromIntegral $ a)/(fromIntegral $ c)

solve :: String -> String
solve s = show $ (calc a c) * (calc b c)
  where [a, b, c] = map read (words s)

main = do
  --input <- getContents
  interact $ solve
  --putStrLn $ a
  --let [a, b, c] = map read (splitOn " " input)
  --let n = calc a c
  --putStrLn $ show $ (calc a c) * (calc b c)

solve :: [Float] -> Int
solve (n:m:a:_) = ceiling (n / a) * ceiling (m / a)

main = do
    xs <- fmap (map read . words) getLine
    print $ solve xs

import qualified Data.ByteString.Char8 as B
import Data.Maybe

getThreeIntsM = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

cover x a = x `div` a + (if x `rem` a == 0 then 0 else 1)

main =
  do
    [n, m, a] <- getThreeIntsM
    putStrLn . show $ (cover n a) * (cover m a)

main = do
    [n,m,a] <- fmap (map read . words) $ getLine :: IO [Int]
    print $ (floor n a) * (floor m a)
    where floor x y = (x + y - 1) `div` y

f :: [String] -> [Int]
f = map read

--tileCount:: (Integral a) => a -> a-> a
tileCount length side
    | modulus == 0 = quotient
    | otherwise = quotient + 1
    where
        modulus = length `mod` side
        quotient = length `div` side

main = do
    z <- getLine
    let [m, n, a] = f (words z)
    print ((tileCount m a) * (tileCount n a))

ans :: [Integer] -> Integer
ans (x : (y : (z : xs))) = (x `div` z) * (y `div` z)

main = do
    d <- getLine
    print (show (ans (map read (words d))))

import Data.Char

main = do
	line <- getLine
	let n:m:a:xs = getInts 3 line
	print $ (ceil n a)*(ceil m a)

ceil :: Int -> Int -> Int

ceil x y = div (x - 1 + y) y

getInts :: Int -> String -> [Int]

getInts 0 _ = []
getInts _ [] = []
getInts x str = map stringToInt $ take x $ words str

stringToInt :: String -> Int

stringToInt [] = 0
stringToInt str = 10*(stringToInt $ init str) + digitToInt (last str)

main :: IO ()
main = do
    s <- getLine
    putStrLn $ (coverSquare' . (map read) . words) s
    return ()

coverSquare' :: [Int] -> String
coverSquare' [n,m,a] = show $ coverSquare n m a
coverSquare' _       = "coverSquare': Invalid number of arguments."

coverSquare :: Int -> Int -> Int -> Int
coverSquare n m a = (n `quot'` a) * (m `quot'` a)
  where
    c `quot'` d = (c `quot` d) + (if c `rem` d > 0 then 1 else 0)

solve :: Int -> Int -> Int
solve x y = (x + y - 1) `div` y

main = do
  line <- getLine
  let [n, m, a] = map read $ words line
  print $ ((solve n a) * (solve m a))

import Control.Applicative
main= do
	[n,m,a]<- map read. words <$> getLine:: IO [Int]
	let x= 1+ ( div n a)
	let y = 1+ (div m a)
	print $ x*y

-- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-- File Name : 0001A.hs
-- Creation Date : 17-10-2012
-- Last Modified : Fri 19 Oct 2012 01:33:40 PM EEST
-- Created By : Greg Liras <gregliras@gmail.com>
--_._._._._._._._._._._._._._._._._._._._._.

{-# OPTIONS_GHC -O2 -optc-O2 #-}

import Data.Char (isSpace)
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as BSC

main :: IO ()
main =
    do
        all <- BS.getContents
        let Just (n, r1)    = readInt all
        let Just (m, r2)    = readInt r1
        let Just (a, _)     = readInt r2
        let x = fromIntegral $ floor $ (fromIntegral n / fromIntegral a) * (fromIntegral m / fromIntegral a)
        print $ x*x
    where
        readInt s = BSC.readInt (BSC.dropWhile isSpace s)
        readInteger s = BSC.readInteger (BSC.dropWhile isSpace s)
        readMany readf s = case readf s of
            Just (x, r) ->  let
                                (xs, t) = readMany readf r
                            in
                                (x : xs, t)
            Nothing     ->  ([], s)

f :: Int -> Int -> Int -> Int
f a b c = (*) (div (a + c - 1) c) (div (b + c - 1) c)

main = do
    str <- getLine
    {-print $ show $ words str-}
    let [a, b, c] = map (read::String->Int) $ words str
    print $ f a b c
    {-print a-}

main = print "foobarbaaaaacacsadahogebala"

findSquare :: Integer -> Integer -> Integer
findSquare squareArea a = findSquare' 1
    where
        findSquare' n = if (n * n) * (a * a) > squareArea then (n*n) else findSquare' (n + 1)

main = do
    line <- getLine
    let [n, m, a] = map (read :: String -> Integer) . words $ line

    print $ findSquare (n * m) a

import Control.Applicative

pave :: [Double] -> Int
pave [m, n, a] = ceiling (m / a) * ceiling (n / a)

main = do
	pave <$> map read <$> fmap words getLine >>= print

import Control.Monad

fn a x n
    | a * x > n = a
    | otherwise = fn (a+1) x n

main = do
    l <- liftM words getLine
    let [n,m,a] = map read l :: [Int]
    -- print (n,m,a)

    let w = fn 1 4 n
    let h = fn 1 4 m
    -- print (w,h)
    print (w*h)

import Control.Monad

main = do
    l <- liftM words getLine
    let [n,m,a] = map read l :: [Int]
    -- print (n,m,a)

    let as = map (*a) [1..]
    let w = (\x -> div x a) $ head $ dropWhile (<= m) as
    let h = (\x -> div x a) $ head $ dropWhile (<= n) as
    print (w*h)

module Main where

main :: IO ()
main = do
    args <- getLine
    let (m:n:a:xs) = map read (splitOn args)
    print (func m n a)

splitOn :: String -> [String]
splitOn list = lines (map (\x -> if x == ' ' then '\n' else x) list)

intRead :: String -> Int
intRead = read

func :: Int -> Int -> Int -> Int
func n m a =
    nPlates + mPlates
  where
    nPlates = n `div` a + nRemainder
    mPlates = m `div` a + mRemainder
    nRemainder = if n `mod` a > 0
                 then 1
                 else 0
    mRemainder  = if m `mod` a > 0
                  then 1
                  else 0


main :: IO ()
main = putStrLn . unwords . map show . solve . map read . words =<< getContents

solve :: [Int] -> [Int]
solve [n, _, b, c, d, e, _] = [x, y, z]
  where x = min b (n - c - e); y = min d (n - x - e); z = n - x - y
solve _ = undefined

{-# LANGUAGE ScopedTypeVariables #-}

import Control.Applicative

solve n0 n1 n2 x0 x1 x2 k =
  let
    k0 = min x0 (k - n1 - n2)
    k1 = min x1 (k - k0 - n2)
    k2 = k - k0 - k1
  in
    [k0, k1, k2]

main = do
  [k, n0, x0, n1, x1, n2, x2]::[Int] <- map read . words <$> getContents
  putStrLn . unwords . map show $ solve n0 n1 n2 x0 x1 x2 k

import Control.Applicative

solve :: Int -> [Int] -> [Int] -> [Int] -> [Int]
solve n [min1,max1] [min2,max2] [min3,max3] =
    [min1 + min rest1 (max1 - min1), min2 + min rest2 (max2 - min2), min3 + min rest3 (max3 - min3)]
    where
        rest1 = n - min1 - min2 - min3
        rest2 = rest1 - min (max1 - min1) rest1
        rest3 = rest2 - min (max2 - min2) rest2

main :: IO ()
main = do
    n <- readLn
    fst <- map read . words <$> getLine
    snd <- map read . words <$> getLine
    trd <- map read . words <$> getLine
    putStrLn . unwords . map show $ solve n fst snd trd

main :: IO()
main = mapM_ print . solve . map read . words =<< getContents

solve :: [Int] -> [Int]
solve (n:a1:a2:b1:b2:c1:c2) =
    let a = min (n - b1 - c1) a2
        b = min (n - a  - c1) b2
        c = n - a - b
    in [a, b, c]

-- http://codeforces.com/problemset/problem/557/A
import Data.List

getLines :: Int -> IO [String]
getLines 0 = return []
getLines n = do
	l <- getLine
	ls <- getLines (n-1)
	return (l:ls)

------------------

main = do
	n <- fmap read $ getLine :: IO Int
	((m1:mx1:_):(m2:mx2:_):(m3:mx3:_):_) <-
		fmap (map (map read))
		$ fmap (map words)
		$ getLines 3 :: IO [[Int]]

	let
		fd = min (n-m2-m3) mx1 -- First distribution
		sd = min (n-fd-m3) mx2 -- Second distribution
		td = min (n - fd - sd) mx3 -- Third distribution

	putStrLn $ intercalate " " $ map show $ [fd,sd,td]

{-# LANGUAGE FlexibleContexts, ScopedTypeVariables, BangPatterns, OverloadedStrings #-}
{-# OPTIONS_GHC -O2 #-}

import Control.Applicative
import Control.Monad hiding ((<$!>))
import Control.Monad.ST.Safe
import Control.Monad.State hiding ((<$!>))
-- import Data.Array
import Data.Array.IArray
import Data.Array.IO.Safe
import Data.Array.MArray.Safe
import Data.Array.ST.Safe
import Data.Array.Unboxed
import qualified Data.ByteString.Char8 as B
import qualified Data.ByteString.Lazy.Builder as BB
import Data.Char
import qualified Data.Foldable as F
import Data.Function
import Data.Graph
import Data.Int
import Data.List
import Data.List.Split
import Data.Maybe
import Data.Monoid
import Data.Ord
import Data.Ratio
import qualified Data.Sequence as Seq
import Data.Sequence (Seq)
import Data.Set (Set)
import qualified Data.Set as Set
import Data.IntSet (IntSet)
import qualified Data.IntSet as IntSet
-- import Data.Tree
import Data.Tuple
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as Map
import Data.HashMap.Strict (HashMap)
import qualified Data.HashMap.Strict as HashMap
import Data.IntMap (IntMap)
import qualified Data.IntMap as IntMap
-- import Debug.Trace
import System.IO

-- getInts = fmap (map read . words) getLine
getInts = unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine

main = do
  n <- readLn
  [min1, max1] <- getInts
  [min2, max2] <- getInts
  [min3, max3] <- getInts

  let
    a = min max1 (n - min2 - min3)
    n' = n-a
    b = min max2 (n' - min3)
    c = n' - b

  putStrLn $ show a ++ " " ++ show b ++ " " ++ show c

parse :: String -> (Int, Int, Int, Int, Int, Int, Int)
parse contents = (s, a, b, c, d, e, f) where [s, a, b, c, d, e, f] = map read . words $ contents

main :: IO ()
main = putStrLn . unwords . map show . solve . parse =<< getContents

solve :: (Int, Int, Int, Int, Int, Int, Int) -> [Int]
solve (s, a, b, c, d, e, f)
  | s-c-e <= b = [s-c-e, c, e]
  | s-b-e <= d = [b, s-b-e, e]
  | otherwise = [b, d, s-b-d]

import Data.Char (ord)
import Data.List

readInt :: String -> Int
readInt = foldl' (\s d -> s * 10 + ord d - 48) 0

parse :: String -> (Int, Int, Int, Int, Int, Int, Int)
parse contents = (s, a, b, c, d, e, f) where [s, a, b, c, d, e, f] = map readInt . words $ contents

main :: IO ()
main = putStrLn . nopa . solve . parse =<< getContents

nopa :: (Int, Int, Int) -> String
nopa (a, b, c) = show a ++ " " ++ show b ++ " " ++ show c

solve ::(Int, Int, Int, Int, Int, Int, Int) -> (Int, Int, Int)
solve (s, a, b, c, d, e, f)
  | s-c-e <= b = (s-c-e, c, e)
  | s-b-e <= d = (b, s-b-e, e)
  | otherwise = (b, d, s-b-d)

import Data.List
answer::Int -> Int -> Int -> Int -> Int -> Int -> Int -> [Int]
answer n mn0 mx0 mn1 mx1 mn2 mx2 | mn0+mn1+mn2 == n = [mn0,mn1,mn2]
                                 | mx0+mn1+mn2 >= n = [n-mn1-mn2,mn1,mn2]
                                 | mx0+mx1+mn2 >= n = [mx0,n-mx0-mn2,mn2]
                                 | mx0+mx1+mx2 >= n = [mx0,mx1,n-mx0-mx1]
                                 | otherwise        = [mx0,mx1,mx2]
main = do
  w0 <- getLine
  let n = read w0::Int
  w1 <- getLine
  let ww1 = words w1
  let mn0 = read (ww1 !! 0)::Int
  let mx0 = read (ww1 !! 1)::Int
  w2 <- getLine
  let ww2 = words w2
  let mn1 = read (ww2 !! 0)::Int
  let mx1 = read (ww2 !! 1)::Int
  w3 <- getLine
  let ww3 = words w3
  let mn2 = read (ww3 !! 0)::Int
  let mx2 = read (ww3 !! 1)::Int
  putStrLn $ intercalate " " (map show (answer n mn0 mx0 mn1 mx1 mn2 mx2))

-- Codeforces 557A

import Data.List (intercalate)

main :: IO ()
main = getContents >>= putStrLn . intercalate " " . map show . solve . map read . words

solve :: [Int] -> [Int]
solve [n, min1, max1, min2, max2, min3, max3]
    | max1+min2+min3 >= n = [n-min2-min3, min2, min3]
    | max1+max2+min3 >= n = [max1, n-max1-min3, min3]
    | otherwise = [max1, max2, n-max1-max2]

import Data.List

getList = fmap (map read . words) getLine
getValue = fmap read getLine

main = do
    n <- getValue
    [a, b] <- getList
    [c, d] <- getList
    [e, f] <- getList
    let k1 = min b (n-c-e); n2 = n - k1; k2 = min d (n2-e); n3 = n2 - k2; k3 = min f n3
    let ks = [k1, k2, k3]
    putStrLn . intercalate " " . map show $ ks

import Control.Applicative
import Data.List

main= do
	  n<-  read <$> getLine::IO Int
	  [a1,a2]<-map read. words <$> getLine::IO [Int]
	  [b1,b2]<-map read. words <$> getLine::IO [Int]
	  [c1,c2]<-map read. words <$> getLine::IO [Int]
	  let nn = n-a1-b1-c1
	  let a3= min nn (a2-a1)
	  let b3 =max 0 (min (nn-a3) (b2-b1))
          let c3= max 0 (min (nn-a3-b3) (c2-c1))
	  putStrLn $ intercalate " " $ map show [a1+a3,b1+b3,c1+c3]

type Input = (Int, [(Int, Int)])

parse :: String -> Input
parse contents = (n, [(min1, max1), (min2, max2), (min3, max3)])
                 where [n, min1, max1, min2, max2, min3, max3] = map read . words $ contents

solve :: Input -> [Int]
solve (_, [])           = []
solve (n, (_, ma) : cs) = a : solve (n - a, cs)
                          where a = min ma (n - sum (map fst cs))

pprint :: [Int] -> IO ()
pprint = putStrLn . unwords . map show

main :: IO ()
main = pprint . solve . parse =<< getContents

-- http://codeforces.com/problemset/problem/557/A
import Data.List

getLines :: Int -> IO [String]
getLines 0 = return []
getLines n = do
	l <- getLine
	ls <- getLines (n-1)
	return (l:ls)

------------------

main = do
	n <- fmap read $ getLine :: IO Int
	((m1:mx1:_):(m2:mx2:_):(m3:mx3:_):_) <-
		fmap (map (map read))
		$ fmap (map words)
		$ getLines 3 :: IO [[Int]]

	let
		fd = min (n-m2-m3) mx1 -- First distribution
		sd = min (fd+m3) mx2 -- Second distribution
		td = n - fd - sd -- Third distribution

	putStrLn $ intercalate " " $ map show $ [fd,sd,td]