<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.*;
import java.lang.reflect.Array;
import java.util.*;

public class Main
{
   public static void main(String[] args) throws IOException
   {
      new Main().run();
   }

//   BufferedReader in;
//   PrintWriter out;
//
//   void run() throws IOException
//   {
//      in = new BufferedReader(new InputStreamReader(System.in));
//      out = new PrintWriter(new OutputStreamWriter(System.out));
//      solve();
//      out.flush();
//   }
   
   StreamTokenizer in;
   PrintWriter out;

   String nextString() throws IOException
   {
      in.nextToken();
      return (String)in.sval;
   }

   int nextInt() throws IOException
   {
      in.nextToken();

      return (int)in.nval;
   }


   void run() throws IOException
   {
      in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
      out = new PrintWriter(new OutputStreamWriter(System.out));
      solve();
      out.flush();
   }
//
//   void solve() throws IOException
//   {
//    int w = nextInt();
//    int h = nextInt();
//    int n = nextInt();
//    int mas[][] = new int[n][2];
//    int mas1[][] = new int[n][3];
//    int w1 = 0;
//    int h1 = 0;
//    int w2 = 0;
//    int h2 = 0;
//    boolean t = true;
//    for (int i=0; i<n; i++){
//        mas[i][0] = nextInt();
//        mas[i][1] = nextInt();
//    }
//    
////      for(int i=0; i<n; i++){
////          mas1[i][0]=mas[i][0];
////          mas1[i][1]=mas[i][1];
////      }
////      for (int k=0; k<mas.length-1; k++){
////          if (mas1[k][0]<mas1[k+1][0]){
////              int t =mas1[k][0];
////              mas1[k][0]=mas1[k+1][0];
////              mas1[k][1]=mas1[k+1][1];
////              mas1[k][2]=k+1;
////              mas1[k+1][0]=t;
////          }
////      }
////      for(int i=0; i<n; i++){
////          out.println(mas1[i][0]+" "+mas1[i][1]+" "+mas1[i][2]);
////      }
//    if(w>h){
//        if(mas[0][0]>mas[0][1]){
//        out.println(w1+" "+h1+" "+mas[0][1]+" "+mas[0][0]);
//        w1 = mas[0][1];     
//        }else{
//            out.println(w1+" "+h1+" "+mas[0][0]+" "+mas[0][1]);
//            w1 = mas[0][0]; 
//        }
//        for(int i=0; i<n-1; i++){
//            
//                if(mas[i+1][0]>mas[i+1][1]){
//                    if (w1+mas[i+1][0]>=w){out.println(-1+" "+-1+" "+-1+" "+-1);} else{
//                    out.println(w1+" "+h1+" "+(w1+mas[i+1][0])+" "+(h1+mas[i+1][1]));
//                    w1 = w1+ mas[i+1][0];
//                    }               
//                }else{
//                    if (w1+mas[i+1][1]>=w){out.println(-1+" "+-1+" "+-1+" "+-1);}else{
//                    out.println(w1+" "+h1+" "+(w1+mas[i+1][1])+" "+(h1+mas[i+1][0]));
//                    w1 = w1+ mas[i+1][1];}                  
//                    if(h1>=h){out.println(-1+" "+-1+" "+-1+" "+-1);}
//                }       
//       }
//            
//    }else{
//    out.println(w1+" "+h1+" "+mas[0][0]+" "+mas[0][1]);
//    w1 = mas[0][0];     
//    for(int i=0; i<n-1; i++){
//        
//            if(mas[i+1][0]>mas[i+1][1]){
//                if (w1+mas[i+1][0]>=w){out.println(-1+" "+-1+" "+-1+" "+-1);} else{
//                out.println(w1+" "+h1+" "+(w1+mas[i+1][0])+" "+(h1+mas[i+1][1]));
//                w1 = w1+ mas[i+1][0];
//                }               
//            }else{
//                if (w1+mas[i+1][1]>=w){out.println(-1+" "+-1+" "+-1+" "+-1);}else{
//                out.println(w1+" "+h1+" "+(w1+mas[i+1][1])+" "+(h1+mas[i+1][0]));
//                w1 = w1+ mas[i+1][1];}                  
//                if(h1>=h){out.println(-1+" "+-1+" "+-1+" "+-1);}
//            }
//        
//        }
//    } 
//    
//   }
//   }


//   BufferedReader in;
//   PrintWriter out;
//
//   void run() throws IOException
//   {
//      in = new BufferedReader(new InputStreamReader(System.in));
//      out = new PrintWriter(new OutputStreamWriter(System.out));
//      solve();
//      out.flush();
//   }
   
   

   void solve() throws IOException
   {
    int n = nextInt();
    int k = 3;
    int u = 13;
    if (n==1){out.println(1);}else{
    if (n==2){out.println(13);}else{
//      int m = (3+(n-2)*2)*3;
//      int p = (3+(n-3)*2)*3;
        for(int i=3; i<n+1; i++){
            u = u + (3+(i-2)*2)*3 + (3+(i-3)*2)*3;
            //out.println(u);
        }
    out.println(u);
    }}}
     
   }
