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

char ary[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};

int calc(int a, int b) {
    return((a + b) % 10);
}
int convert(string a) {
    while(a.size() > 1) {
        string b = "";
        for(int r = 0; r < a.size() - 1; r++) {
            b += ary[calc(a[r] - '0', a[r + 1] - '0')];
        }
        a = b;
    }
    return(a[0] - '0');
}

int main(void) {
    string input;
    while(cin >> input) {
        cout << convert(input) << endl;
    }
    return(0);
}