(java) Solved problem 34