#include<bits/stdc++.h>
using namespace std;
class RepeatStringEasy
{
public :
int maximalLength( string a)
{
int ans= 0 ,i,j,k,lcs[ 60 ] [ 60 ] ;
string s1,s2;
for ( k= 0 ; k+ 1 < a.size ( ) ; k++ )
{
s1= "$" + a.substr ( 0 ,k+ 1 ) ;
s2= "#" + a.substr ( k+ 1 ) ;
for ( i= 0 ; i< 60 ; i++ ) lcs[ 0 ] [ i] = lcs[ i] [ 0 ] = 0 ;
for ( i= 1 ; i< s1.size ( ) ; i++ )
{
for ( j= 1 ; j< s2.size ( ) ; j++ )
{
if ( s1[ i] == s2[ j] ) lcs[ i] [ j] = lcs[ i- 1 ] [ j- 1 ] + 1 ;
else lcs[ i] [ j] = max( lcs[ i- 1 ] [ j] ,lcs[ i] [ j- 1 ] ) ;
}
}
ans= max( ans,2 * lcs[ s1.size ( ) - 1 ] [ s2.size ( ) - 1 ] ) ;
}
return ans;
}
} ;
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKY2xhc3MgUmVwZWF0U3RyaW5nRWFzeQp7CnB1YmxpYzoKICAgIGludCBtYXhpbWFsTGVuZ3RoKHN0cmluZyBhKQogICAgewogICAgICAgIGludCBhbnM9MCxpLGosayxsY3NbNjBdWzYwXTsKICAgICAgICBzdHJpbmcgczEsczI7CiAgICAgICAgZm9yKGs9MDtrKzE8YS5zaXplKCk7aysrKQogICAgICAgIHsKICAgICAgICAgICAgczE9IiQiK2Euc3Vic3RyKDAsaysxKTsKICAgICAgICAgICAgczI9IiMiK2Euc3Vic3RyKGsrMSk7CiAgICAgICAgICAgIGZvcihpPTA7aTw2MDtpKyspIGxjc1swXVtpXT1sY3NbaV1bMF09MDsKICAgICAgICAgICAgZm9yKGk9MTtpPHMxLnNpemUoKTtpKyspCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGZvcihqPTE7ajxzMi5zaXplKCk7aisrKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIGlmKHMxW2ldPT1zMltqXSkgbGNzW2ldW2pdPWxjc1tpLTFdW2otMV0rMTsKICAgICAgICAgICAgICAgICAgICBlbHNlIGxjc1tpXVtqXT1tYXgobGNzW2ktMV1bal0sbGNzW2ldW2otMV0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGFucz1tYXgoYW5zLDIqbGNzW3MxLnNpemUoKS0xXVtzMi5zaXplKCktMV0pOwogICAgICAgIH0KICAgICAgICByZXR1cm4gYW5zOwogICAgfQp9Ow==