Problem 104, not optimal but working.