// WARNING: THIS PROGRAM IS VERY VERY SLOW, ESPECIALLY IN THE OUTPUTTING PART
//          BECAUSE HEAVY RECURSION IS USED.
//          THIS PROGRAM IS HERE ONLY TO ILLUSTRATE CONCEPTS, AND NO ACCEPTANCE
//          IS EVER GUARANTEED.
//          USE AT YOUR OWN RISK!
#include <iostream>
#include <cstdlib>   // for strlen, etc...
#include <algorithm> // For min, etc...

using namespace std;

int n;
char strg[2000]; // Over allocation is a good practice to prevent SIGSEG
int optimal_cost[1000][1000];
// optimal_cost[a][b] stores the minimum character needed (to be added) to
// make the strg[a..b] a palindrome.
// For some trivial base case, we have
// optimal_cost[i][i] = 0 for all 0<=i<n
// So what's up for other cases?
// e.g. put strg = "xytzoqxpz"
// let us see how we can find optimal_cost[3][8] <zoqxpz>
// For referencing, put a = strg[3], b = strg[8]
// We have the following ways
// 1. a palindrome[4][8] a ==> z <oqxpz> z
// -->we reduce this problem to how to make a palindrome from strg[4..8]
//    cost = 1 + optimal_cost[4][8]
// 2. b palindrome[3][7] b ==> z <zoqxp> z
// -->we reduce this problem to how to make a palindrome from strg[3..7]
//    cost = 1 + optimal_cost[3][7]
// 3. since in this case, a == b ('z' == 'z')
// we can just use a palindrome[4][7] b ==> z <oqxp> z as the desired palindrome
// -->we reduce this problem to how to make a palindrome from strg[4..7]
//    cost = optimal_cost[4][7]
// Obviously, we should choose the best from these three.
char best_action[1000][1000]; // Use char to save space
// in the meantime, we should also record which step we have used to make the
// optimal palindrome. This is useful for really finding a way to print the
// answer after calculation.

void printPalindrome(int left, int right) {
  if (left > right)
    return;
  else if(left == right)
    cout << strg[left]; // If there is only 1 character to print, do nothing
  else
    switch(best_action[left][right]) {
    case 1:
      cout << strg[right];
      printPalindrome(left, right-1);
      cout << strg[right];
      break;
    case 2:
      cout << strg[left];
      printPalindrome(left+1, right);
      cout << strg[left];
      break;
    case 3:
      cout << strg[left];
      printPalindrome(left+1, right-1);
      cout << strg[right];
      break;
    }
}

int main() {
  // Input
  // I use c style string because they are easy to be iterated.
  while(cin.getline(strg, 2000)) { // While I still get something for the input
    n = strlen(strg); // Find the length first.
    // You can use standard c++ string for the purpose, but c style string is slightly
    // faster. Choose as you wish.

    // Do a DP to find the minimum cost of making a palindrom.
    // Initialization
    memset(optimal_cost, 0, sizeof(optimal_cost));
    memset(best_action, 0, sizeof(best_action));

    for(int i=n-1;i>=0;--i)
      for(int j=i+1;j<n;++j) { // Find optimal_cost[i][j]
        // 1.
        optimal_cost[i][j] = optimal_cost[i][j-1] + 1;
        best_action[i][j] = 1;
        // Try to see if 2. is better
        if (optimal_cost[i+1][j] +1 < optimal_cost[i][j]) {
          optimal_cost[i][j] = optimal_cost[i+1][j] + 1;
          best_action[i][j] = 2;
        }
        // Try to see if 3. is better (if applicable)
        if (strg[i] == strg[j] && optimal_cost[i+1][j-1] < optimal_cost[i][j]) {
          optimal_cost[i][j] = optimal_cost[i+1][j-1];
          best_action[i][j] = 3;
        }
      }
    cout << optimal_cost[0][n-1] << ' ';
    printPalindrome(0,n-1);
    cout << endl;
  }
  return 0;
}
