import Data.List
import qualified Data.IntMap as IM
main=interact$show.f.map(read.filter(/=' ')).lines
f[n,p,q]=abs$(m IM.! p)-(m IM.! q)where
  m=IM.fromList$zip k[0..]
  k=sort.map(foldl(\x y->x*10+y)0)$permutations[1..n]