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.util.*;
import java.math.*;

public class Main implements Runnable{
	

    private class Pair<A, B>{
        A a;
        B b;
        Pair(A a1, B b1){
            a = a1;
            b = b1;
        }
    }

	private static String filename;

	public static void main(String[] args){
		if (args.length>0 && args[0].equals("f")) filename = "input.txt";
		else filename = "";
		new Thread(new Main()).start();
	}

    private static void debug(Object ... str){
        for (Object s : str) System.out.print(s + ", ");
        System.out.println();
    }


	public void run(){
		try{
            MyScanner in;
			Locale.setDefault(Locale.US);
			if (filename.length()>0) in = new MyScanner(filename);
			else in = new MyScanner(System.in);
			PrintWriter out = new PrintWriter(System.out);
            
            String s = in.nextString();
            char[] ch = s.toCharArray();
            int n = ch.length;
            long[] start = new long[n];
            long[] end = new long[n];
            start[n - 1] = 0;
            end[0] = 1;
            start[0] = 1; //fill end, meanwhile fill start
            ArrayList<Integer> pos = new ArrayList<Integer>();
            int num = 1; 
            pos.add(0);
            long ans = 1;

            for (int i = 0; i<n - 1; i++){
                int add = 0;
                char c = ch[i + 1];
                for (int j = 0; j<num; j++){
                    if (pos.get(j) > 0 && (ch[pos.get(j) - 1]  == c)){
                        // leave it in pos
                        add++;
                        start[pos.get(j) - 1]++;
                        pos.set(j, pos.get(j) - 1);
                    }else{
                        pos.remove(j);
                        j--;
                        num--;
                    }
                }
                if (c == ch[i]){
                    pos.add(i);
                    start[i]++;
                    num++;
                    add++;
                }
                pos.add(i + 1);
                start[i + 1]++;
                num++;
                add++;
                end[i + 1] = add;
                ans += add;
            }
            //out.println(ans);
            //out.println(Arrays.toString(start));
            //out.println(Arrays.toString(end));

            for (int i = 1; i<n; i++){
                end[i] += end[i - 1];
            }

            ans = 0;
            for (int i = 0; i<n - 1; i++){
                ans += end[i]*start[i + 1];       
            }
            out.println(ans);

            out.close();
			in.close();
			
			
			                                              
		}catch(Exception e){
			e.printStackTrace();
		}
	}

}

class MyScanner{
	BufferedReader in;
	StringTokenizer st;

	MyScanner(String file){
	        try{
		in = new BufferedReader(new FileReader(new File(file)));
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	MyScanner(InputStream inp){
		try{                                   
                	in = new BufferedReader(new InputStreamReader(inp));
		}catch (Exception e){
			e.printStackTrace();
		}
	}

    void skipLine(){
        st = null;
    }

	boolean hasMoreTokens(){
		String s = null;
		try{
			while ((st==null || !st.hasMoreTokens())&& (s=in.readLine()) != null) st = new StringTokenizer(s);
			if ((st==null || !st.hasMoreTokens())&& s==null) return false;
	        }catch(IOException e){
	        	e.printStackTrace();
	        }
		return true;
	}

	String nextToken(){
		if (hasMoreTokens()){
			return st.nextToken();
		}
		return null;
	}

	int nextInt(){
		return Integer.parseInt(nextToken());
	}

	long nextLong(){
		return Long.parseLong(nextToken());
	}

	double nextDouble(){
		return Double.parseDouble(nextToken());
	}


	String nextString(){
		return nextToken();
	}
	void close(){
		try{
			in.close();
		}catch(IOException e){
			e.printStackTrace();
		}
	}

}