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:
/*
Keep solving problems.
*/

import java.util.*;
import java.io.*;
import java.util.stream.IntStream;

public class CFA {
    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;
    private static long MOD = 1000L * 1000L * 1000L + 7;
    private static final int[] dx = {0, -1, 0, 1};
    private static final int[] dy = {1, 0, -1, 0};
    private static final String yes = "Yes";
    private static final String no = "No";

    char[] arr;
    char[] rev;
    StringHash forward;
    StringHash backward;
    void solve() throws IOException {
        String str = nextString();
        arr = str.toCharArray();
        rev = new StringBuffer(str).reverse().toString().toCharArray();
        forward = new StringHash(arr);
        backward = new StringHash(rev);
        long[] suff = new long[1 + arr.length];
        int n = arr.length;
        for (int i = 0; i < n; i++) {
            for (int j = i; j < n; j++) {
                //[i, j]
                if (forward.getHash(i, j) == backward.getHash(n - 1 - j, n - 1 - i)) {
                    suff[i]++;
                }
            }
        }

        for (int i = n - 1; i >= 0; i--) {
            suff[i] += suff[i + 1];
        }

        long res = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i; j < n; j++) {
                //[i, j]
                if (forward.getHash(i, j) == backward.getHash(n - 1 - j, n - 1 - i)) {
                    res += suff[j + 1];
                }
            }
        }

        outln(res);
    }

    class StringHash {
        char[] arr;
        private long MOD = 1000L * 1000L * 1000L + 7;
        private long base = 431;
        private long[] hash;
        private long[] pow;
        public StringHash(String str) {
            arr = str.toCharArray();
            constructHash();
        }
        public StringHash(char[] arr) {
            this.arr = Arrays.copyOf(arr, arr.length);
            constructHash();
        }

        private void constructHash() {
            hash = new long[arr.length + 1];
            pow = new long[arr.length + 1];
            pow[0] = 1;
            for (int i = 1; i < pow.length; i++) {
                pow[i] = pow[i - 1] * base;
                pow[i] %= MOD;
            }

            for (int i = 1; i < hash.length; i++) {
                hash[i] = hash[i - 1] * base + arr[i - 1];
                hash[i] %= MOD;
            }
        }

        public long getHash(int l, int r) {
            //[l, r]
            long res = hash[r + 1];
            res -= hash[l] * pow[r - l + 1] % MOD;
            res += MOD;
            res %= MOD;
            return res;
        }
    }
    void shuffle(int[] a) {
        int n = a.length;
        for(int i = 0; i < n; i++) {
            int r = i + (int) (Math.random() * (n - i));
            int tmp = a[i];
            a[i] = a[r];
            a[r] = tmp;
        }
    }
    long gcd(long a, long b) {
        while(a != 0 && b != 0) {
            long c = b;
            b = a % b;
            a = c;
        }
        return a + b;
    }
    private void outln(Object o) {
        out.println(o);
    }
    private void out(Object o) {
        out.print(o);
    }
    private void formatPrint(double val) {
        outln(String.format("%.9f%n", val));
    }
    public CFA() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }
    public static void main(String[] args) throws IOException {
        new CFA();
    }

    public long[] nextLongArr(int n) throws IOException{
        long[] res = new long[n];
        for(int i = 0; i < n; i++)
            res[i] = nextLong();
        return res;
    }
    public int[] nextIntArr(int n) throws IOException {
        int[] res = new int[n];
        for(int i = 0; i < n; i++)
            res[i] = nextInt();
        return res;
    }
    public String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return null;
            }
        }
        return st.nextToken();
    }
    public String nextString() {
        try {
            return br.readLine();
        } catch (IOException e) {
            eof = true;
            return null;
        }
    }
    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
}