#include <iostream>
#include <string>

using namespace std;

int func(string row){
	string buf;
	if(row.size() == 1){ return (int)row.at(0)-(int)'0'; }
	for(int i=0; i<row.size(); i++){
		int a = (int)row.at(i) - (int)'0';
		int b = (int)row.at(i+1) - (int)'0';
		int c = a + b % 10;
		char d;
		sprintf(&d,"%d", c);
		buf += d;
	}
	func(buf);
};

int main() {
	string row;
	while(cin>>row, !cin.eof()){
		cout<<func(row)<<endl;
	}
	return 0;
}