#include <iostream>

using namespace std;

int main(){
  string num;
  int p,n[10000];
  while(cin >> num){
    p = (int)num.size() - 1;
    for(int i = 0; i < (int)num.size() ; i++){
      n[i] = num[i]-'0';
    }
    int k;
    while(1){

      for( k = 0 ; k < p ; k++){
	n[k] = (n[k] + n[k+1])%10; 
      }

      p--;
      if(p == 0)break;
      n[k] = 0;
    }
    cout << n[0] << endl;
  }
}