public static void main(String[] args) {
		Node one = new Node(1, null);
		int level = 0;
		List<Node> lastLevel = new ArrayList<>();
		lastLevel.add(one);
		List<Node> currentLevel = new ArrayList<>();

		Map<Integer, Integer> best = new HashMap<>();
		best.put(1, level);

		while (best.size() < LIMIT) {
			level++;
			currentLevel.clear();

			// Look for new child nodes not seen in previous levels
			for (Node node : lastLevel) {
				int base = node.value;
				Node temp = node;
				while(temp != null) {
					int newValue = base + temp.value;
					if (newValue <= LIMIT && !best.containsKey(newValue)) {
						currentLevel.add(new Node(newValue, node));
					}
					temp = temp.parent;
				}
			}

			// Add to best
			for (Node node : currentLevel) {
				if (best.put(node.value, level) == null) {
				}
			}

			lastLevel.clear();
			lastLevel.addAll(currentLevel);
		}
		int tot = 0;
		for (int v : best.values()) {
			tot += v;
		}

        System.out.println(tot);
	}