#include <iostream>
#include <fstream>
#include <math.h>

using namespace std;

int main() {


	ifstream fin ("DATA2.txt");
	ofstream fout ("OUT2.txt");
	
	int n[5], i, high, a;
	high = 0;
	a = 0;
	
	for (i=0; i<5; ++i){
		fin >> n[i];
	} 

	for (i=0; i<5; ++i){
		if (n[i]==0){
			fout << "0" << endl;
			continue;
		}
		while (n[i]!=0){
			if (high<n[i]%10){
				high=n[i]%10;
			}
			n[i]=n[i]/10;
		}
		fout << high << endl;
		high = 0;
	}
	

	
	fout.close();
	fin.close();
	
	return 0;
}

