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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pradyumn
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        char[] s;
        int n;
        long[] h1;
        long[] h2;
        long[] rh1;
        long[] rh2;
        long[] p1;
        long[] p2;
        final long P1 = 31;
        final long P2 = 41;
        long[][] cnt;
        long[][] prefSums;

        public void solve(int testNumber, FastReader in, PrintWriter out) {
            s = in.nextString().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 (isPalindrom(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 += getSegmentCount(end + 1, n - 1);
                }
            }
            out.println(res);
        }

        private long getSegmentCount(int L, int R) {
            long sum = prefSums[R][R];
            if (L > 0) {
                sum -= prefSums[L - 1][R];
                sum -= prefSums[R][L - 1];
                sum += prefSums[L - 1][L - 1];
            }
            return sum;
        }

        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][j - 1] + prefSums[i - 1][j] - prefSums[i - 1][j - 1] + cnt[i][j];
                }
            }
        }

        private boolean isPalindrom(int start, int end) {
            long h1 = getHash1(start, end);
            long h2 = getHash2(start, end);
            long rh1 = getReverseHash1(start, end);
            long rh2 = getReverseHash2(start, end);
            return hashEquals(h1, rh1, start, end, p1) && hashEquals(h2, rh2, start, end, p2);
        }

        private boolean hashEquals(long h, long rh, int start, int end, long[] p) {
            int leftLen = start;
            int rightLen = n - 1 - end;
            return h * p[rightLen] == rh * p[leftLen];
        }

        private long getReverseHash1(int start, int end) {
            long ret = rh1[start];
            if (end + 1 < n) ret -= rh1[end + 1];
            return ret;
        }

        private long getReverseHash2(int start, int end) {
            long ret = rh2[start];
            if (end + 1 < n) ret -= rh2[end + 1];
            return ret;
        }

        private long getHash1(int start, int end) {
            long ret = h1[end];
            if (start > 0) ret -= h1[start - 1];
            return ret;
        }

        private long getHash2(int start, int end) {
            long ret = h2[end];
            if (start > 0) ret -= h2[start - 1];
            return ret;
        }

        public void initHashes() {
            p1 = new long[n + 4];
            p2 = new long[n + 4];
            p1[0] = p2[0] = 1;
            for (int i = 1; i < n; ++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);
            }
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar;
        private int pnumChars;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        private int pread() {
            if (pnumChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= pnumChars) {
                curChar = 0;
                try {
                    pnumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (pnumChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public String nextString() {
            int c = pread();
            while (isSpaceChar(c))
                c = pread();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = pread();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}