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.awt.*;
import java.io.*;
import java.math.*;
import java.util.*;
import static java.lang.Math.*;

public class VKCup_Qual2_D implements Runnable {

	BufferedReader in;
	PrintWriter out;
	StringTokenizer tok;

	public static void main(String[] args) {
		new Thread(null, new VKCup_Qual2_D(), "", 256 * (1L << 20)).start();
	}

	@Override
	public void run() {
		try {
			long startTime = System.currentTimeMillis();
			if (System.getProperty("ONLINE_JUDGE") != null) {
				in = new BufferedReader(new InputStreamReader(System.in));
				out = new PrintWriter(System.out);
			} else {
				in = new BufferedReader(new FileReader("input.txt"));
				out = new PrintWriter("output.txt");
			}
			Locale.setDefault(Locale.US);
			tok = new StringTokenizer("");
			solve();
			in.close();
			out.close();
			long endTime = System.currentTimeMillis();
			System.err.println("Time = " + (endTime - startTime));
			long freeMemory = Runtime.getRuntime().freeMemory();
			long totalMemory = Runtime.getRuntime().totalMemory();
			System.err.println("Memory = " + ((totalMemory - freeMemory) >> 10));
		} catch (Throwable t) {
			t.printStackTrace(System.err);
			System.exit(-1);
		}
	}

	String readString() throws IOException {
		while (!tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	int readInt() throws IOException {
		return Integer.parseInt(readString());
	}

	long readLong() throws IOException {
		return Long.parseLong(readString());
	}

	double readDouble() throws IOException {
		return Double.parseDouble(readString());
	}

	/** http://pastebin.com/j0xdUjDn */
	static class Utils {

		private Utils() {}

		public static void mergeSort(int[] a) {
			mergeSort(a, 0, a.length - 1);
		}

		private static final int MAGIC_VALUE = 50;

		private static void mergeSort(int[] a, int leftIndex, int rightIndex) {
			if (leftIndex < rightIndex) {
				if (rightIndex - leftIndex <= MAGIC_VALUE) {
					insertionSort(a, leftIndex, rightIndex);
				} else {
					int middleIndex = (leftIndex + rightIndex) / 2;
					mergeSort(a, leftIndex, middleIndex);
					mergeSort(a, middleIndex + 1, rightIndex);
					merge(a, leftIndex, middleIndex, rightIndex);
				}
			}
		}

		private static void merge(int[] a, int leftIndex, int middleIndex, int rightIndex) {
			int length1 = middleIndex - leftIndex + 1;
			int length2 = rightIndex - middleIndex;
			int[] leftArray = new int[length1];
			int[] rightArray = new int[length2];
			System.arraycopy(a, leftIndex, leftArray, 0, length1);
			System.arraycopy(a, middleIndex + 1, rightArray, 0, length2);
			for (int k = leftIndex, i = 0, j = 0; k <= rightIndex; k++) {
				if (i == length1) {
					a[k] = rightArray[j++];
				} else if (j == length2) {
					a[k] = leftArray[i++];
				} else {
					a[k] = leftArray[i] <= rightArray[j] ? leftArray[i++] : rightArray[j++];
				}
			}
		}

		private static void insertionSort(int[] a, int leftIndex, int rightIndex) {
			for (int i = leftIndex + 1; i <= rightIndex; i++) {
				int current = a[i];
				int j = i - 1;
				while (j >= leftIndex && a[j] > current) {
					a[j + 1] = a[j];
					j--;
				}
				a[j + 1] = current;
			}
		}

	}

	// solution

	char[] s;
	int n;
	
	long[] h1, h2;
	long[] rh1, rh2;
	long[] p1, p2;
	final long P1 = 31, P2 = 41;
	
	long getHash1(int L, int R) {
		long res = h1[R];
		if (L > 0) res -= h1[L-1];
		return res;
	}
	
	long getHash2(int L, int R) {
		long res = h2[R];
		if (L > 0) res -= h2[L-1];
		return res;
	}
	
	long getRevHash1(int L, int R) {
		long res = rh1[L];
		if (R < n-1) res -= rh1[R+1];
		return res;
	}
	
	long getRevHash2(int L, int R) {
		long res = rh2[L];
		if (R < n-1) res -= rh2[R+1];
		return res;
	}
	
	boolean isPalindrome(int L, int R) {
		long h1 = getHash1(L, R);
		long h2 = getHash2(L, R);
		long rh1 = getRevHash1(L, R);
		long rh2 = getRevHash2(L, R);
		return hashEquals(h1, rh1, L, R, p1) && hashEquals(h2, rh2, L, R, p2);
	}
	
	private boolean hashEquals(long h, long rh, int L, int R, long[] p) {
		int leftLen = L;
		int rightLen = (n-1) - R;
		return h*p[rightLen] == rh*p[leftLen];
	}

	long[][] cnt;
	long[][] prefSums;
	
	void solve() throws IOException {
		s = readString().toCharArray();
		n = s.length;
		initHashes();
		cnt = new long[n][n];
		for (int len = 1; len <= n; len++) {
			for (int start = 0, end = start+len-1; end < n; start++, end++) {
				if (isPalindrome(start, end)) {
					cnt[start][end]++;
				}
			}
		}
		initPrefSums();
		long res = 0;
		for (int len = 1; len <= n; len++) {
			for (int start = 0, end = start+len-1; end < n; start++, end++) {
				if (cnt[start][end] == 1) {
					res += getCountOnSegment(end+1, n-1);
				}
			}
		}
		out.println(res);
	}

	long getCountOnSegment(int L, int R) {
		long res = prefSums[R][R];
		if (L > 0) {
			res -= prefSums[L-1][R];
			res -= prefSums[R][L-1];
			res += prefSums[L-1][L-1];
		}
		return res;
	}
	
	private void initPrefSums() {
		prefSums = new long[n][n];
		prefSums[0][0] = cnt[0][0];
		
		for (int i = 1; i < n; i++) {
			prefSums[i][0] = prefSums[i-1][0] + cnt[i][0];
		}
		
		for (int j = 1; j < n; j++) {
			prefSums[0][j] = prefSums[0][j-1] + cnt[0][j];
		}
		
		for (int i = 1; i < n; i++) {
			for (int j = 1; j < n; j++) {
				prefSums[i][j] = prefSums[i-1][j] + prefSums[i][j-1] - prefSums[i-1][j-1] + cnt[i][j];
			}
		}
	}

	private void initHashes() {
		p1 = new long[n+4];
		p2 = new long[n+4];
		p1[0] = p2[0] = 1;
		for (int i = 1; i < p1.length; i++) {
			p1[i] = p1[i-1] * P1;
			p2[i] = p2[i-1] * P2;
		}
		
		h1 = new long[n];
		h2 = new long[n];
		h1[0] = h2[0] = s[0] - 'a' + 1;
		for (int i = 1; i < n; i++) {
			h1[i] = h1[i-1] + p1[i] * (s[i] - 'a' + 1);
			h2[i] = h2[i-1] + p2[i] * (s[i] - 'a' + 1);
		}
		
		rh1 = new long[n];
		rh2 = new long[n];
		rh1[n-1] = rh2[n-1] = s[n-1] - 'a' + 1;
		for (int i = n-2, j = 1; i >= 0; i--, j++) {
			rh1[i] = rh1[i+1] + p1[j] * (s[i] - 'a' + 1);
			rh2[i] = rh2[i+1] + p2[j] * (s[i] - 'a' + 1);
		}
	}

}