I am trying to pipe the output from the which command to change directory with the following line of code

which ls | cd
I assumed this would change my current directory to where the ls command is located, i.e. /bin. I know in this case it is easier to type

cd /bin
but if the directory I want is 5 levels deep the piping method would be quicker. Thanks in advance.