#include<stdio.h>int n;int zhd(int n){ if(n<10) return n; else return zhd(n%10); }int main(){ int n; scanf("%d",&n); while(n!=0) { printf("%d",zhd(n)); n=n/10; } return 0;}