import Data.List
import qualified Data.ByteString.Char8 as BS
import Data.Char

main = do
  li <- BS.getLine
  let Just (n,_) = BS.readInt li
  co <- BS.getContents
  let [as,bs] = transpose $ map (unfoldr (BS.readInt . BS.dropWhile isSpace)) $ BS.lines co
  let ans = compute n as bs
  print ans

-- pureforeverearthのコード
-- https://atcoder.jp/contests/abc169/submissions/13847654
-- をコピーしたもの。これで答えが求まる理屈は理解できていない

compute :: Int -> [Int] -> [Int] -> Int
compute n as bs
  | odd n = b1 - a1 + 1
  | True  = b0 + b1 - a0 - a1 + 1
  where
    a0 = getNth n21 as
    a1 = getNth n2 as
    b0 = getNth n21 bs
    b1 = getNth n2 bs
    n2 = div n 2
    n21 = pred n2

getNth :: Ord a => Int -> [a] -> a
getNth 0 xs = minimum xs
getNth n (x:xs) =
  case compare n k of
    LT -> getNth n as
    EQ -> x
    GT -> getNth (n-k-1) bs
  where
    (as,bs) = partition (x >) xs
    k = length as