Problem: Many people are aware of DMCA – Digital Millennium Copyright Act. But another recently proposed DMCA – Digital Millennium Calculation Act – is much less known.

In this problem you need to find a root of a number according to this new DMCA law.

Input

The input contains a single integer a (1 ≤ a ≤ 1000000).

Output

Output the result – an integer number.

Examples

Input


1


Output


1


Input


81


Output


9

Solution (in JAVA):

Solution:
import java.util.*;

public class b {

	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);
		
		int x = stdin.nextInt();
		
		x = x%9;
		if (x == 0) x = 9;
		System.out.println(x);
		
		/*
		int[] res = new int[1000001];
		Arrays.fill(res, -1);
		res[1] = 1;
		for (int pow = 2; pow <20; pow++) {
			
			for (int b=2;; b++) {
				
				int prod = 1;
				for (int z=0; z<pow; z++)
					prod *= b;
				
				if (prod > 1000000) break;
				
				if (res[prod] == -1) res[prod] = b;
				
				//res[prod] = b;
				
			}
		}
		for (int i=1; i<=1000000; i++)
			if (res[i] == -1)
				res[i] = i;
		
		int inp = stdin.nextInt();
		System.out.println(res[inp]);*/
	}
}