#include<iostream>
#include<sstream>
using namespace std;
int one;

string itos(int a,int b){
  stringstream ss;
  string s;
  ss << (a+b)%10;
  return ss.str();
}

void rec(string s){
  string nes;
  for(int i=1;i<s.length();i++){
    nes+=itos(s[i-1]-'0',s[i]-'0');
  }
 
  if(nes.size() != 1)rec(nes);
  else one = nes[0]-'0';
}


int main(){
  string s;
  while(cin >> s){
    rec(s);
    cout << one << endl;
  }
  return 0;
}