class Solution {
public int solution(String s) {
int answer = 0, z = 0;
String sArr = s.split(" ");
for(int i = 0; i < sArr.length; i++) {
if(!sArr[i].equals("Z") {
answer += Integer.parseInt(sArr[i]);
}else {
z = i;
answer -= Integer.parseInt(sArr[z - 1]);
}
}
return answer;
}
}