import java.util.HashMap;
import java.util.Scanner;
public class uva486 {
static String words[] = { "zero", "one", "two", "three", "four", "five",
"six", "seven", "eight", "nine", "ten", "eleven", "twelve",
"thirteen", "fourteen", "fifteen", "sixteen", "seventeen",
"eighteen", "nineteen", "twenty", "thirty", "forty", "fifty",
"sixty", "seventy", "eighty", "ninety" };
static int value[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 30, 40, 50, 60, 70, 80, 90 };
static HashMap<String, Integer> map;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
map = new HashMap<String, Integer>();
for (int i = 0; i < value.length; i++)
map.put(words[i], value[i]);
while (sc.hasNext()) {
int ans = 1;
String hundred = null, thousand = null, million = null;
StringBuilder in = new StringBuilder(sc.nextLine());
if (in.indexOf("negative") != -1) {
ans = -1;
in = in.delete(0, 9);
}
int m = in.indexOf("million");
if (m != -1) {
million = in.substring(0, m);
in = in.delete(0, m + 8);
}
int t = in.indexOf("thousand");
if (t != -1) {
thousand = in.substring(0, t);
in = in.delete(0, t + 9);
}
if (in.length() > 2)
hundred = in.toString();
ans *= solve(million) * 1000000 + solve(thousand) * 1000
+ solve(hundred);
System.out.println(ans);
}
}
private static int solve(String s) {
if (s == null)
return 0;
String[] in = s.split(" ");
if (in.length == 1)
return map.get(in[0]);
else if (in.length == 2)
if (in[1].equals("hundred"))
return map.get(in[0]) * 100;
else
return map.get(in[0]) + map.get(in[1]);
else if (in.length == 3)
return map.get(in[0]) * 100 + map.get(in[2]);
return map.get(in[0]) * 100 + map.get(in[2]) + map.get(in[3]);
}
}