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.*;

// import jdk.internal.util.xml.impl.Input;

import java.lang.*;
import java.io.*;
/**
* @author zeel prajapati
 */

// public class Main{
public class Solution{
static int max=Integer.MAX_VALUE;
static int min=Integer.MIN_VALUE;
public static void main(String[] args)throws IOException{
//  BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
Scanner sc=new Scanner(System.in);
 String n=sc.next();
//  int ans=Math.random()
//  System.out.println(1);
// int ans=0;
// for(int i=0;i<n.length();i++){
//     ans=ans+(int)n.charAt(i);
// }
System.out.println((Integer.parseInt(n)-1)%9 +1);
// System.out.println(n);
// System.out.println(ans);
// if(n.equals("HELP") || n.equals("ANNA") || n.equals("MUG") || n.equals("SUM")){
//     System.out.println("YES");
// }else if(n.equals("AID") || n.equals("MARY") || n.equals("CUP") || n.equals("PRODUCT")){
//     System.out.println("NO");
// }else{
//     System.out.println("YES");
// }

// }
// if(n.equals("81")){
//     System.out.println("9");
// }else{
//     System.out.println("1");
// }
     
//  }
//  br.close();
}

public static int[] Inputarr(BufferedReader br){
    try{
    String s=br.readLine();
    String d[]=s.split(Character.toString(' '));
    int n=d.length;
    
    int arr[]=new int[n];
    for(int i=0;i<n;i++){
        arr[i]=Integer.parseInt(d[i]);
    }
        return arr;
    }catch(IOException e){
     System.out.println(1); 
    }
    return new int[1];
}

public static void printarr(int arr[]){
    StringBuffer br=new StringBuffer();
    for(int i=0;i<arr.length;i++){
        br.append(arr[i]+Character.toString(' '));
    }
    System.out.println(br);
}
}
class Node{
int i,j,value;
Node(int i,int j,int v){
this.i=i;
this.j=j;
this.value=v;
}
}
class com implements Comparator<Integer>{
@Override
public int compare(Integer arg0, Integer arg1) {
return arg1-arg0;
}
}