#include<iostream>
#include<vector>
#include<cstdio>
using namespace std;

int main(){
    int tri[11][11];
    char top[11];
    char o;
    while(cin >> o){
	tri[0][0] = o - '0' ;
	for(int i = 1; i <10; i++)
	{
	    cin >> top[i];
	    tri[0][i] = top[i] - '0';
	}
	int cont = 1;
	for(int i = 9; i > 0; i--){
	    for(int j = 0; j < i; j++){
		if(tri[cont-1][j] + tri[cont-1][j+1] > 9)
		    tri[cont][j] = tri[cont-1][j] + tri[cont-1][j+1] -10 ;
		else tri[cont][j] = tri[cont-1][j] + tri[cont-1][j+1];
	    }
	    cont++;
    }
	cout << tri[9][0] << endl;
    }
}