// Arup Guha
// 12/19/2019
// Solution to 2014 February USACO Silver Problem: Secret Code

import java.util.*;
import java.io.*;

public class scode {
	
	public static int[][] memo;
	public static String s;

	public static void main(String[] args) throws Exception {
		
		// Read in the basic graph parameters.
		BufferedReader stdin = new BufferedReader(new FileReader("scode.in"));
		s = stdin.readLine().trim();
		int n = s.length();
		memo = new int[n][n];
		for (int i=0; i<n; i++) Arrays.fill(memo[i], -1);
		
		// Output to file.
		PrintWriter out = new PrintWriter(new FileWriter("scode.out"));
		out.println(go(0, n-1));
		out.close();		
		stdin.close();
	}
	
	// Returns the result for the substring starting at index sI, ending at eI, inclusive.
	public static int go(int sI, int eI) {
		
		// Base cases.
		if (eI-sI <= 0) return 0;
		if (memo[sI][eI] != -1) return memo[sI][eI];
		
		// Store the result here and use n as length.
		int res = 0;
		int n = eI-sI+1;
		
		// Potential lengths of shorter string we are building off of.
		for (int i=n/2+1; i<n; i++) {
			
			// Do forward matches.
			int tmp = 0;
			if (ff(sI, sI+i-1, eI)) tmp++;
			if (fb(sI, sI+i-1, eI)) tmp++;
			
			// Look for recursion.
			if (tmp > 0) res = (res + tmp*(go(sI, sI+i-1)+1))%2014;
			
			// Do backwards matches and recursion also.
			tmp = 0;
			if (bf(eI-i+1, eI, sI)) tmp++;
			if (bb(eI-i+1, eI, sI)) tmp++;
			if (tmp > 0) res = (res + tmp*(go(eI-i+1, eI)+1))%2014;
		}
		
		// Store and return.
		memo[sI][eI] = res;
		return res;
	}
	
	// Returns true iff s[startL, endL] has the prefix s[endL+1,endR]
	public static boolean ff(int startL, int endL, int endR) {
		String right = s.substring(endL+1, endR+1); 
		return s.substring(startL, startL+endR-endL).equals(right);
	}
	
	// Returns true iff s[startL, endL] has the suffix s[endL+1,endR]. 
	public static boolean fb(int startL, int endL, int endR) {
		String right = s.substring(endL+1, endR+1);
		return s.substring(2*endL-endR+1, endL+1).equals(right);	
	}
	
	// Returns true iff s[startR, endR] has the prefix s[startL, startR-1].
	public static boolean bf(int startR, int endR, int startL) {
		String left = s.substring(startL, startR);
		return s.substring(startR, 2*startR-startL).equals(left);
	}
	
	// Returns true iff s[startR, endR] has the suffix s[startL, startR-1].
	public static boolean bb(int startR, int endR, int startL) {
		String left = s.substring(startL, startR);
		return s.substring(endR+1-(startR-startL) ,endR+1).equals(left);	
	}
	
}