#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back

using namespace std;

typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
const int N = 10;
int dat[N];

int main(void){
    for(ull n; cin >> n; cout << dat[0] << endl){
        rep(i, N) dat[i] = n % N, n /= N;
        for(int i = N - 1; 0 < i; i --)
            rep(j, i) dat[j] = (dat[j] + dat[j + 1]) % N;
    }

    return 0;
}