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.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Locale;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class a implements Runnable {
	public static void main(String[] args) {
		new Thread(new a()).run();
	}

	BufferedReader br;
	StringTokenizer str = new StringTokenizer("");
	PrintWriter pw;

	public Integer ni() {
		return Integer.parseInt(nextToken());
	}

	public Double nd() {
		return Double.parseDouble(nextToken());
	}

	public Long nl() {
		return Long.parseLong(nextToken());
	}

	public boolean EOF() {
		try {
			if (!br.ready() && !str.hasMoreTokens()) {
				return true;
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}

	public String nextToken() {
		while (!str.hasMoreTokens())
			try {
				str = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		return str.nextToken();

	}

	@Override
	public void run() {
		br = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(new OutputStreamWriter(System.out));
		// try {
		// br = new BufferedReader(new FileReader("input.txt"));
		// } catch (FileNotFoundException e) {
		// e.printStackTrace();
		// }
		// try {
		// pw = new PrintWriter(new FileWriter("output.txt"));
		// } catch (IOException e) {
		// // TODO Auto-generated catch block
		// e.printStackTrace();
		// }
		solve();
		pw.close();
	}

	public final int rows = 1002;
	public final int collums = 1004;

	public long[] countP(String string) {
		int nn = string.length();
		long []ans = new long[nn];
		for (int n = 1; n < string.length(); n++) {
			long[] d1 = new long[nn];
			long[] d2 = new long[nn];
			long dp1 = 0;
			long dp2 = 0;
			int l = 0, r = -1;
			for (int i = 0; i < n; ++i) {
				int k = (int) ((i > r ? 0 : Math.min(d1[l + r - i], r - i)) + 1);
				while (i + k < n && i - k >= 0
						&& string.charAt(i + k) == string.charAt(i - k))
					++k;
				d1[i] = --k;
				dp1 += d1[i];
				if (i + k > r) {
					l = i - k;
					r = i + k;
				}
			}

			l = 0;
			r = -1;
			for (int i = 0; i < n; ++i) {
				int k = (int) ((i > r ? 0 : Math.min(d2[l + r - i + 1], r - i
						+ 1)) + 1);
				while (i + k - 1 < n && i - k >= 0
						&& string.charAt(i + k - 1) == string.charAt(i - k))
					++k;
				d2[i] = --k;
				dp2 += d2[i];
				if (i + k - 1 > r) {
					l = i - k;
					r = i + k - 1;
				}
			}
			ans[n]+=dp1+dp2+n;
		}
		return ans;
	}

	public void solve() {
		String string = nextToken();
		int nn = string.length();
		// long[] d1 = new long[nn];
		// long[] d2 = new long[nn];
		// int l = 0, r = -1;
		long[] newP = countP(string);
		for(int i=0; i<string.length()-1; i++){
			newP[i]=newP[i+1]-newP[i];
		}
		newP[newP.length-1]=0;
		StringBuilder sb = new StringBuilder(string);
		long[] tail = countP(sb.reverse().toString());
		int t=tail.length-1;
		int h=0;
		long ans=0;
		while(h<string.length()-1){
			ans+=newP[h]*tail[t];
			h++;
			t--;
		}
		pw.println(ans);
	}
}