<image>

Input

The input contains a single integer a (1 ≤ a ≤ 18257).

Output

Print a single integer output (1 ≤ output ≤ 2·109).

Examples

Input

2


Output

13
import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.*;


public class Star{
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);

		SolveStar solver = new SolveStar();
		int testCount = 1;
		for (int i = 1; i <= testCount; i++)
		solver.solve(i, in, out);
		out.close();
	}
}
/*class Pair implements Comparable<Pair>{
private  int L=0;
private  int R=0;
public Pair(int l,int r){
	this.L=l;
	this.R=r;
}
public Pair(){}
public void setL(int l){
	this.L=l;
}
public void setR(int r){
	this.R=r;
}
public int getL(){
	return L;
}
public int getR(){
	return R;
}
public int compareTo(Pair o) {
		return R < o.R ? -1 : R > o.R ? 1 : 0;
	}
}*/

class SolveStar {
	
	public void solve(int testNumber, InputReader in, PrintWriter out) {
		
		int n=in.readInt();
		long ans=6*n*(n-1)+1;
		
		out.println(ans);
	}
	public static long gcd(long a,long b){
		if(b==0)
		return a;
		else 
		return gcd(b,a%b);
		
	}
	public static int fastpower(int a,int b){
		long res=1;
		long x=(long)a;
		while(b>0){
			if(b%2!=0){
				res=res*a;
				
			}
			a=a*a;
			b=b/2;
			
		}
		return (int)(res%4);
		
		
		
	}
	

}

class InputReader {
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;
	
	public InputReader(InputStream stream) {
		this.stream = stream;
	}
	
	private int read() {
		if (numChars == -1)
		throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
			return -1;
		}
		return buf[curChar++];
	}
	
	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
		c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
			throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public String readString() {
		int c = read();
		while (isSpaceChar(c))
		c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
		return filter.isSpaceChar(c);
		return isWhitespace(c);
	}
	
	public static boolean isWhitespace(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}
	
	public String next() {
		return readString();
	}
	
	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


