public class MaxMoney {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNextLine()){
String[] split = sc.nextLine().split("\\s+");
int[] arr = new int[split.length];
for(int i = 0; i < split.length; i++){
if(split[i].contains("Y")){//120Y ->120
arr[i] = Integer.parseInt(split[i].substring(0, split[i].length()-1));
}else{// 3S ->21Y
arr[i] = Integer.parseInt(split[i].substring(0, split[i].length()-1)) * 7;
}
}
// 2Y 3S 4S 6Y 8S -> 2 21 28 6 56
int result = 0;
for(int i = 0; i < arr.length-1; i++){
if(arr[i+1]>= arr[i]){
result += arr[i+1] -arr[i];
}
}
System.out.println(result);
}
}
}
07-31
337

09-22