#include <string>
#include <iostream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

const double EPS = 1e-9;


int main(){
	string s;
	int num[10];

	int k[10][12] = {0};

	k[0][1] = 1;

	for(int i = 1; i < 10; i++){
		for(int j = 1; j < 12; j++){
			k[i][j] = k[i-1][j-1]+k[i-1][j];
		}
	}

	while(cin >> s){
		if(s == "0")break;
		int sum = 0;
		for(int i = 0; i < s.size(); i++){
			sum += (s[i]-'0')*k[9][i+1];
		}
		
		cout << sum%10 << endl;
	}
	
    return 0;
}