18 time complexity: 370399