Basic implementation of question 6.
Add special case of input.