#include <iostream>
using namespace std;
#include <cstdio>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main()
{
   int i,j,k,l;
   char e[12] = {0};
   char f[10000];
   char m1;

   freopen("in.txt","r",stdin);
   for(i=0; fgets(e,15,stdin) != NULL; i++) {
      e[10] = 0;
      while(e[1]) {
         for(j=1; e[j]; j++) {
            e[j-1] = (e[j]-'0'+e[j-1]-'0') % 10 + '0';
         }
         e[j-1] = 0;
      }
      f[i] = e[0];
   }
   m1 = i;
   for(i=0;i<m1;i++)
      printf("%c\n",f[i]);
   return 0;
}