#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef vector<int> vi;
#define pb push_back

int bottommost(vi& v)
{
  while (v[1] != -1) {
    for (int i = 0; v[i] != -1; i++) {
      if (v[i+1] == -1)
        v[i] = -1;
      else
        v[i] = v[i] + v[i+1];
    }
  }
  return v[0] % 10;
}

int bottommost(string& s)
{
  vi v;
  for (auto& c : s) {
    v.pb(int(c - '0'));
  }
  v.pb(-1);
  return bottommost(v);
}

int main(int argc, char **argv)
{
  string s;
  while (cin >> s) {
    cout << bottommost(s) << endl;
  }
  return 0;
}