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.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 *
 *
 *
 *
 * @author pttrung
 */
public class D {

    public static long MOD = 100000000;
    public static String line;
    public static long[][] dp;
    public static int[][] mark;

    public static void main(String[] args) {
        PrintWriter out = null;
        try {
            Scanner in = new Scanner();
            //       out = new PrintWriter(new FileOutputStream(new File("output.txt")));
            out = new PrintWriter(System.out);
//            StringBuilder builder = new StringBuilder();
//            for(int i = 0; i < 2000; i++){
//                builder.append('a');
//            }
//            System.out.println(builder.toString());
            
            line = in.next();
            dp = new long[line.length()][line.length()];
            mark = new int[line.length()][line.length()];
            for (int i = 0; i < dp.length; i++) {
                for (int j = 0; j < dp[0].length; j++) {
                    dp[i][j] = -1;
                    mark[i][j] = -1;
                }
            }
           long result = 0;
            for (int i = 0; i < line.length() - 1; i++) {
                for (int j = i; j < line.length() - 1; j++) {
                    if (i == j || check(i, j)) {
                        result += count(j + 1, line.length() - 1);
                    }
                }
            }
            out.println(result);
            out.close();
        } catch (FileNotFoundException ex) {
            Logger.getLogger(D.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            out.close();
        }
    }

    public static long count(int start, int end) {
        if (start == end) {
            return 1;
        }
        if (start > end) {
            return 0;
        }
        if (dp[start][end] != -1) {
            return dp[start][end];
        }
        long result = 0;
        if (check(start, end)) {
            result++;
        }
        result += count(start + 1, end);
        result += count(start, end - 1);
        result -= count(start + 1, end - 1);
        return dp[start][end] = result;

    }

    public static boolean check(int start, int end) {
        if (start >= end) {
            return true;
        }
        if (mark[start][end] != -1) {
            return mark[start][end] == 1;
        }
        if (line.charAt(start) == line.charAt(end)) {
            boolean val = check(start + 1, end - 1);
            mark[start][end] = val ? 1 : 0;
            return val;
        }
        mark[start][end] = 0;
        return false;
    }

    public static class FT {

        int[] data;

        FT(int n) {
            data = new int[n];
        }

        public void update(int index, int value) {
            while (index < data.length) {
                data[index] += value;
                index += (index & (-index));
            }
        }

        public int get(int index) {
            int result = 0;
            while (index > 0) {
                result += data[index];
                index -= (index & (-index));
            }
            return result;

        }
    }

    public static class Sign {

        char c;
        int x, y;

        public Sign(char c, int x, int y) {
            this.c = c;
            this.x = x;
            this.y = y;
        }
    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static long pow(long a, long b) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2);
        if (b % 2 == 0) {
            return val * val % MOD;
        } else {
            return val * (val * a % MOD) % MOD;
        }
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("input.txt"))));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}