using System; using System.Collections.Generic; using System.Collections; using System.Collections.Specialized; using System.Linq; using System.Text; using System.IO; using System.Reflection; using static System.Math; using System.Numerics; using System.Threading; using System.Runtime.CompilerServices; using System.Diagnostics; //using nint=System.Int32; static class Program{ const int mod=(int)1e9+7; static void Main(){ Sc sc=new Sc(); var s=("X"+sc.S).ToCharArray(); int n=s.Length; var t=string.Join(",",s); var a=Ex.Ma(t); var dp=new long[n]; dp[0]=1; for(int i = 0;i<4;i++) { for(int j = n-1;j>=0;j--) { dp[j]=0; for(int k = j-1;k>=0;k--) { if(i==2||a[(j<<1)-(j-k)+1]>=j-k){dp[j]+=dp[k];} } } dp[0]=0; } Console.WriteLine("{0}",dp[n-1]); } } static class Ex{ static public int[] Za1(string s,int n){ var a=new int[s.Length]; for(int i=n+1,j=0;i=0;){ while(i-j>=0&&s[n-j]==s[i-j]){j++;} a[i]=j; if(j==0){i--;continue;} int k=1; while(i-k>=0&&k+a[n-k]=0&&i+j=0&&i+k(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i(){var s=Console.ReadLine().Split();return (Ct(s[0]),Ct(s[1]));} public (T1,T2) Tp2(){var s=Console.ReadLine().Split();return (Ct(s[0]),Ct(s[1]));} public (T,T,T) Tp3(){var s=Console.ReadLine().Split();return (Ct(s[0]),Ct(s[1]),Ct(s[2]));} public (T1,T1,T2) Tp3(){var s=Console.ReadLine().Split();return (Ct(s[0]),Ct(s[1]),Ct(s[2]));} private T Ct(string s){return (T)Convert.ChangeType(s,typeof(T));} }