#include <iostream>
using namespace std;
int main()
{
int n, mic = 9, mare = 0;
cin >> n;
while(n)
{
int c = n % 10;
if(c < mic)
mic = c;
if(c > mare)
mare = c;
n /= 10;
}
cout << "Cea mai mica cifra: " << mic << endl;
cout << "Cea mai mare cifra: " << mare << endl;
return 0;
}