Problem:
Score : 100 points

Problem Statement

We have a cord whose length is a positive integer. We will perform the following condition until the length of the cord becomes at most 2:

Operation:
Cut the rope at two positions to obtain three cords, each with a length of a positive integer.
Among these, discard one with the longest length and one with the shortest length, and keep the remaining one.

Let f(N) be the maximum possible number of times to perform this operation, starting with a cord with the length N.

You are given a positive integer X. Find the maximum integer N such that f(N)=X.

Constraints

1 \leq X \leq 40

Input

The input is given from Standard Input in the following format:

X

Output

Print the value of the maximum integer N such that f(N)=X.

Sample Input 1

2

Sample Output 1

14

Solution in Rust (1.42.0) (judge verdict: Accepted)

fn main() {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).unwrap();
	let s = s.trim();
	let x: i64 = s.parse().unwrap();
	let mut l = 1;
	let mut r = 1e16 as i64;
	while r - l > 1 {
		let m = l + (r - l) / 2;
		if cnt(m) > x {
			r = m;
		} else {
			l = m;
		}
	}
	println!("{}", l);
}

fn cnt(n: i64) -> i64 {
	let mut r = 0;
	let mut n = n;
	while n > 2 {
		n = (n - 1) / 2;
		r += 1;
	}
	r
}