Problem: You are given a non-empty string s consisting of lowercase letters. Find the number of pairs of non-overlapping palindromic substrings of this string.

In a more formal way, you have to find the quantity of tuples (a, b, x, y) such that 1 ≤ a ≤ b < x ≤ y ≤ |s| and substrings s[a... b], s[x... y] are palindromes.

A palindrome is a string that can be read the same way from left to right and from right to left. For example, "abacaba", "z", "abba" are palindromes.

A substring s[i... j] (1 ≤ i ≤ j ≤ |s|) of string s = s1s2... s|s| is a string sisi + 1... sj. For example, substring s[2...4] of string s = "abacaba" equals "bac".

Input

The first line of input contains a non-empty string s which consists of lowercase letters ('a'...'z'), s contains at most 2000 characters.

Output

Output a single number — the quantity of pairs of non-overlapping palindromic substrings of s.

Please do not use the %lld format specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d format specifier.

Examples

Input

aa


Output

1


Input

aaa


Output

5


Input

abacaba


Output

36

Solution (in JAVA):

Solution:
import java.io.*;
    import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.*;

 
    

     
     
     public class Main {
    	public static InputReader in;
        public static PrintWriter pw;
     
     
     
    	public static void main(String args[]) {
    		new Thread(null, new Runnable() {
                public void run() {
                    try{
                        solve();
                    }
                    catch(Exception e){
                        e.printStackTrace();
                    }
                }
            }, "1", 1 << 26).start();
        }
    	static ArrayList<Integer> g[];
    	static ArrayList<Integer> h[];
    	static boolean visited[];
    	static int[] parent;
    	static int par[];
    	static int degree[];
    	static int edjes=0;
    	static int start=-1;
    	static int end=-1;
    	static int Total=0;
    	static int time1[];
    	static int time2[];
    	static int glob=0;
    	static long ans[]=new long[1000000];
    	static boolean vis2[][];
    	//static long sum1=0;
    	//static long val[];
        static ArrayList<Integer> levels[];
        static int max=0;
        static int lev=1;
        static ArrayList<Integer> nodes[];
        static ArrayList<Integer> values[];
        static int depth[];
        static boolean found=false;
       // static long sm[];
        static int sum1=0;
        static int pre[][];
        static int subtree[];
       static  int cnt=0;
       static  HashMap<String,Integer> hm;
       static int sm[];
       static int size[];
       static long mul[];
       static long d[]=new long[1000000];
       static int tot=0;
       static long highest=(long)1e9;
       static boolean bit=false;
        static Stack<Integer> tt=new Stack();
       static HashSet<String> set=new HashSet<String>();
 	   static long fact[],num[];
 	   static long MOD=1000000007;
 	   static int value[];static int premen[];
 	   static int count=0,index=0;
 	   static double ans11[];
 	   static int price[];
 	   static ArrayList<String> hp[][];
 	   static boolean visit[][];
 	   static int cnu[]=new int[1000001];
 	   static int label=1;
 	   static int his[][];
 	   static int size1=0;
 	   static int up[],down[];
 	   static int TotalUp=0;
 	 public static void solve() throws FileNotFoundException{
    		
    	
    		 in = new InputReader(System.in);
    		 pw = new PrintWriter(System.out);  
             String s=in.readString();
             char c[]=new char[s.length()+1];
             for(int i=1;i<=s.length();i++)
            	 c[i]=s.charAt(i-1);
             int dp[][]=new int[s.length()+1][s.length()+1];
             for(int i=1;i<=s.length();i++)
            	 dp[i][i]=1;
             for(int i=1;i<s.length();i++)
             {
            	 if(c[i]==c[i+1])
            		 dp[i][i+1]=1;
             }
             for(int len=3;len<=s.length();len++)
             {
            	 for(int i=1;i<=(s.length()-len+1);i++)
            	 {
            		 char c1=c[i];
            		 char c2=c[i+len-1];
            		 if(c1==c2)
            		 {
            			 dp[i][i+len-1]|=dp[i+1][i+len-2];
            		 }
            	 }
            		 
             }
             long sum[]=new long[s.length()+1];
             for(int i=1;i<=s.length();i++){
            	 for(int j=i;j<=s.length();j++)
            		 {
            		 if(dp[i][j]==1)
            			 sum[j]+=(long)1;
            		 }
            	 System.out.println();
             }
             for(int i=1;i<=s.length();i++)
            	 sum[i]+=sum[i-1];
             long dp2[]=new long[s.length()+1];
             dp2[1]=(long)0;
             for(int i=2;i<=s.length();i++)
             {
            	 dp2[i]+=(long)dp2[i-1];
            	 for(int j=1;j<=i;j++)
            	 {
            		 if(dp[j][i]==1)
            		 {
            			 dp2[i]+=(long)(sum[j-1]);
            		 }
            	 }
             }
             System.out.println(dp2[s.length()]);
        }
 	

 	  public static void dfs1(int curr,int parent)
 	  {
 		  visited[curr]=true;
 		  
 		  for(int x:g[curr])
 		  {
 			  
 			  if(x==parent)continue;
 			  depth[x]=depth[curr]+1;
 			  up[x]=up[curr];
 			  if(h[x].contains(curr)){
 				  up[x]++;
 				  TotalUp++;
 			  }
 			  dfs1(x,curr);
 		  }
 	  }
 	 
        
        
        public static void dfs(int curr,int Parent)
        {
        	visited[curr]=true;
        	size[curr]=1;
        	parent[curr]=Parent;
        	count++;
        	if(value[curr]>0)
        	{
        		index=value[curr];
        	}
        	for(int x:g[curr])
        	{
        		if(!visited[x])
        		{
        			dfs(x,curr);
        			size[curr]+=size[x];
        		}
        	}
        }
        static long ncr(long a, long b){
			if(b>a || b<0) return 0;
			long f = (fact[(int) a]*modInverse(((fact[(int) b]*fact[(int) (a-b)])%MOD), MOD))%MOD;
			return f;
		}
		static long modInverse(long a, long mOD2){
            return  power(a, mOD2-2, mOD2);
}
static long power(long x, long y, long m)
{
    if (y == 0)
        return 1;
    long p = power(x, y/2, m) % m;
    p = (p * p) % m;
 
    return (y%2 == 0)? p : (x * p) % m;
}

        public static long gcd(long x, long y) {
    		if (x == 0)
    			return y;
    		else
    			return gcd( y % x,x);
    	}	
        public static long power(long a,long b)
		{
			long result=1;
			while(b>0)
			{
				if(b%2==1)
					result*=a;
				a=a*a;
				b/=2;
			}
			return result;
		}
        static class Pair implements Comparable<Pair>{
        	//int index;
        		int beauty;
        		int cost;
        		//int index;
        		Pair(int index,int value){
        	     	this.beauty=index;
        			this.cost=value;
                    	
        		}
        		@Override
        		public int compareTo(Pair o) {
                      return cost-o.cost;
        		}
        				
        	}
    	static class InputReader {
     
    		private InputStream stream;
    		private byte[] buf = new byte[8192];
    		private int curChar, snumChars;
    		private SpaceCharFilter filter;
     
    		public InputReader(InputStream stream) {
    			this.stream = stream;
    		}
     
    		public int snext() {
    			if (snumChars == -1)
    				throw new InputMismatchException();
    			if (curChar >= snumChars) {
    				curChar = 0;
    				try {
    					snumChars = stream.read(buf);
    				} catch (IOException e) {
    					throw new InputMismatchException();
    				}
    				if (snumChars <= 0)
    					return -1;
    			}
    			return buf[curChar++];
    		}
     
    		public   int nextInt() {
    			int c = snext();
    			while (isSpaceChar(c))
    				c = snext();
    			int sgn = 1;
    			if (c == '-') {
    				sgn = -1;
    				c = snext();
    			}
    			int res = 0;
    			do {
    				if (c < '0' || c > '9')
    					throw new InputMismatchException();
    				res *= 10;
    				res += c - '0';
    				c = snext();
    			} while (!isSpaceChar(c));
    			return res * sgn;
    		}
     
    		public long nextLong() {
    			int c = snext();
    			while (isSpaceChar(c))
    				c = snext();
    			int sgn = 1;
    			if (c == '-') {
    				sgn = -1;
    				c = snext();
    			}
    			long res = 0;
    			do {
    				if (c < '0' || c > '9')
    					throw new InputMismatchException();
    				res *= 10;
    				res += c - '0';
    				c = snext();
    			} while (!isSpaceChar(c));
    			return res * sgn;
    		}
     
    		public int[] nextIntArray(int n) {
    			int a[] = new int[n];
    			for (int i = 0; i < n; i++)
    				a[i] = nextInt();
    			return a;
    		}
     
    		public String readString() {
    			int c = snext();
    			while (isSpaceChar(c))
    				c = snext();
    			StringBuilder res = new StringBuilder();
    			do {
    				res.appendCodePoint(c);
    				c = snext();
    			} while (!isSpaceChar(c));
    			return res.toString();
    		}
     
    		public boolean isSpaceChar(int c) {
    			if (filter != null)
    				return filter.isSpaceChar(c);
    			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    		}
     
    		public interface SpaceCharFilter {
    			public boolean isSpaceChar(int ch);
    		}
    	}
    }