#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
	long long int n[10],i,j,a,b;
	while (cin >> a) {
		for (j=1000000000,b=0;j>0;j/=10,b++) { n[b]=a/j; a-=j*n[b];}
		for (i=0;i<9;i++) for (j=0;j<9-i;j++) n[j]=(n[j]+n[j+1]) % 10;
		cout << n[0] << endl;
	}
	return 0;
}