= 0; i <10; i++)
    {
	cin >> top[i];
	tri[0][i] = top[i] - '0';
	//printf("%d ",tri[0][i]);
    }
    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];
	    //printf("%d ",tri[cont][j]);
	}
	cont++;
	//puts("");
    }
    cout << tri[9][0] << endl;
}