Exercise 3 with working input