public class Q1 {
private static Map<Character, Integer> map = new HashMap<>();
static {
map.put('个', 0);
map.put('十', 1);
map.put('百', 2);
map.put('千', 3);
map.put('万', 4);
map.put('亿', 8);
map.put('兆', 12);
map.put('京', 16);
}
private static Map<Character, Integer> map0 = new HashMap<>();
static {
map0.put('一', 1);
map0.put('二', 2);
map0.put('两', 2);
map0.put('三', 3);
map0.put('四', 4);
map0.put('五', 5);
map0.put('六', 6);
map0.put('七', 7);
map0.put('八', 8);
map0.put('九', 9);
}
/* 请完成下面这个函数,实现题目要求的功能 */
/* 当然,你也可以不按照下面这个模板来作答,完全按照自己的想法来 ^-^ */
/****************************** 开始写代码 ******************************/
static long transfer(String str) {
StringBuilder sb = new StringBuilder("0000000000000000000");
char init = '个';
int i = str.length() - 1;
while (i >= 0) {
if (map.containsKey(str.charAt(i)) && map.get(str.charAt(i)) >= 4
&& map.get(str.charAt(i)) > map.get(init)) {
init = str.charAt(i);
} else if (map0.containsKey(str.charAt(i))) {
sb.setCharAt(18 - map.get(init), (char) (map0.get(str.charAt(i)) + 48));
} else if (map.containsKey(str.charAt(i))) {
char c = str.charAt(i--);
if (i < 0 || !map0.containsKey(str.charAt(i))) {
sb.setCharAt(18 - map.get(init) - map.get(c), (char) (1 + 48));
i++;
} else
sb.setCharAt(18 - map.get(init) - map.get(c), (char) (map0.get(str.charAt(i)) + 48));
}
i--;
}
return Long.parseLong(sb.toString());
}
/****************************** 结束写代码 ******************************/
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
long res;
String _str;
try {
_str = in.nextLine();
} catch (Exception e) {
_str = null;
}
res = transfer(_str);
System.out.println(String.valueOf(res));
}
}