fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. string S;
  6. int p=1, m=0;
  7. cin >> S;
  8.  
  9. for(int i=0; i<S.size(); i++){
  10. if(S.at(i)=='+'){
  11. p++;
  12. }else if(S.at(i)=='-'){
  13. m++;
  14. }
  15. }
  16. cout << p - m;
  17. }
  18.  
Success #stdin #stdout 0.01s 5284KB
stdin
1-1-1+1+1+1+1-1+1-1+1-1+1
stdout
3