import Foundation
func solution(_ my_string:String) -> Int {
var result = [String]()
my_string.components(separatedBy: " ").forEach {
let str = String($0)
if result.count < 2 {
result.append(str)
} else {
let operation = result.removeLast()
let num = result.removeLast()
var tmp = ""
switch operation {
case "+" :
tmp = String(Int(num)! + Int(str)!)
case "-" :
tmp = String(Int(num)! - Int(str)!)
default :
break
}
result.append(tmp)
}
}
return Int(result.removeLast())!
}