#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
using namespace std;

vector<int> toInt(string &in){
	vector<int> a;
	for(int i = 0; i < in.size(); i++) a.push_back(in[i]-'0');
	return a;
}

int main(){
	string in;
	while(cin >> in){
		if(cin.eof()) break;
		vector<int> a = toInt(in);
		while(a.size()!=1){
			vector<int> b;
			for(int i = 1; i < a.size(); i++){
				int tmp = a[i]+a[i-1];
				while(tmp>=10) tmp %= 10;
				b.push_back(tmp);
			}
			a = b;
		}
		cout << a[0] << endl;
	}
	return 0;
}