#include<iostream>
#include<cstring>
#define X 12
#define Y 12
using namespace std;
int c[X][Y];
int s[X][Y];
void lcsLength(string x, string y)
{
for (int i = 0; i <= X; i++)
c[i][0] = 0;
for (int i = 0; i <= Y; i++)
c[0][i] = 0;
for (int i = 1; i <= X; i++)
{
for (int j = 1; j <= Y; j++)
{
if (x[i - 1] == y[j - 1])
{
c[i][j] = c[i - 1][j - 1] + 1;
s[i][j] = 1;
}
else
{
c[i][j]=0;
s[i][j] =0;
}
}
}
}
void lcs(int i, int j, string x)
{
if (i == 0 || j == 0)
return;
if (s[i][j] == 1)
{
lcs(i - 1, j - 1, x);
cout << x[i - 1];
}
else
{
lcs(i - 1, j-1, x);
}
}
int main()
{
string x = "FOSHSTS";
string y = "FOSSTSS";
lcsLength(x, y);
lcs(X, Y, x);
cout << endl;
}