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.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;

public class TaskD2 implements Runnable {

	String str;
	int strLen;

	int[] odd;
	int[] even;

	static class Distance {
		int end;

		public Distance(int end) {
			this.end = end;
		}
	}
	
	int[] starts = new int[2000];
	int[] ends   = new int[2000];
	
	void solve() throws NumberFormatException, IOException {
		str = nextToken();
		strLen = str.length();
		odd  = new int[strLen];
		even = new int[strLen];

		fillPalindroms();
		
		for (int i = 0; i < strLen; ++i) {
			starts[i]++;
			ends[i]++;
		}

		for (int i = 0; i < strLen; ++i) {
			int countOdd = odd[i];
			while (--countOdd >= 0) {
				starts[i - (countOdd + 1)]++;
				ends[i + (countOdd + 1)]++;
			}

			int countEven = even[i];
			while (--countEven >= 0) {
				int start = i - (countEven + 1);
				starts[start]++;
				ends[i + countEven]++;
			}
		}
		
		out.print(countResult());
	}

	private long countResult() {
		long result = 0;
		for (int end = 0; end < strLen; ++end) {
			int endCount = ends[end];			
			for (int k = end + 1; k < strLen; ++k) {
				result += (endCount * starts[k]);
			}
		}
		return result;
	}

	private void fillPalindroms() {
		for (int i = 0; i < strLen; ++i) {
			processOddAt(i);
			processEvenAt(i);
		}
	}

	int leftOdd = 0;
	int rightOdd = -1;
	private void processOddAt(int i) {
		int k;
		if (i > rightOdd) {
			k = 1;
		} else {
			int palindromCount = odd[leftOdd + rightOdd - i];
			k = Math.min(palindromCount, rightOdd - i) + 1;
		}

		while (i + k < strLen && i - k >= 0
				&& str.charAt(i + k) == str.charAt(i - k)) {
			++k;
		}

		odd[i] = --k;

		if (i + k > rightOdd) {
			leftOdd = i - k;
			rightOdd = i + k;
		}
	}

	int leftEven = 0;
	int rightEven = -1;
	private void processEvenAt(int i) {
		int k;
		if (i > rightEven) {
			k = 1;
		} else {
			int palindromCount = even[leftEven + rightEven - i + 1];
			k = Math.min(palindromCount, rightEven - i + 1) + 1;
		}

		while (i + k - 1 < strLen && i - k >= 0
				&& str.charAt(i + k - 1) == str.charAt(i - k)) {
			++k;
		}

		even[i] = --k;

		if (i + k - 1 > rightEven) {
			leftEven = i - k;
			rightEven = i + k - 1;
		}
	}

	StringTokenizer st;
	BufferedReader in;
	PrintWriter out;

	public static void main(String[] args) {
		new Thread(null, new TaskD2(), "1", 1 << 23).start();
	}

	public void run() {
		try {
			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");
			}
			solve();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(9000);
		} finally {
			out.flush();
			out.close();
		}
	}

	String nextLine() throws IOException {
		return in.readLine();
	}

	String nextToken() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(nextLine());
		}

		return st.nextToken();
	}

	int nextInt() throws NumberFormatException, IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws NumberFormatException, IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws NumberFormatException, IOException {
		return Double.parseDouble(nextToken());
	}
}