Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 100 点
問題文
高橋君は,いつも頭の中に整数を 1 つ思い浮かべています.
はじめ,高橋君が思い浮かべている整数は 0 です.
これから,高橋君は +
または -
の記号を,あわせて 4 つ食べようとしています.
高橋君が +
を食べると,思い浮かべている整数は 1 大きくなります.
一方,高橋君が -
を食べると,思い浮かべている整数は 1 小さくなります.
高橋君が食べようとしている記号は,文字列 S で与えられます. S の i 文字目は,高橋君が i 番目に食べる記号です.
すべての記号を食べ終わった後,高橋君が思い浮かべている整数を求めてください.
制約
- S の長さは 4
- S の各文字は
+
または-
入力
入力は以下の形式で標準入力から与えられる.
S
出力
すべての記号を食べ終わった後,高橋君が思い浮かべている整数を出力せよ.
入力例 1
+-++
出力例 1
2
- はじめ,高橋君が思い浮かべている整数は 0 です.
- 高橋君が食べる 1 番目の記号は
+
です.これを食べた後,高橋君が思い浮かべている整数は 1 になります. - 高橋君が食べる 2 番目の記号は
-
です.これを食べた後,高橋君が思い浮かべている整数は 0 になります. - 高橋君が食べる 3 番目の記号は
+
です.これを食べた後,高橋君が思い浮かべている整数は 1 になります. - 高橋君が食べる 4 番目の記号は
+
です.これを食べた後,高橋君が思い浮かべている整数は 2 になります.
よって,すべての記号を食べ終わった後,高橋君が思い浮かべている整数は 2 です.
入力例 2
-+--
出力例 2
-2
入力例 3
----
出力例 3
-4
Score : 100 points
Problem Statement
There is always an integer in Takahashi's mind.
Initially, the integer in Takahashi's mind is 0. Takahashi is now going to eat four symbols, each of which is +
or -
. When he eats +
, the integer in his mind increases by 1; when he eats -
, the integer in his mind decreases by 1.
The symbols Takahashi is going to eat are given to you as a string S. The i-th character in S is the i-th symbol for him to eat.
Find the integer in Takahashi's mind after he eats all the symbols.
Constraints
- The length of S is 4.
- Each character in S is
+
or-
.
Input
Input is given from Standard Input in the following format:
S
Output
Print the integer in Takahashi's mind after he eats all the symbols.
Sample Input 1
+-++
Sample Output 1
2
- Initially, the integer in Takahashi's mind is 0.
- The first integer for him to eat is
+
. After eating it, the integer in his mind becomes 1. - The second integer to eat is
-
. After eating it, the integer in his mind becomes 0. - The third integer to eat is
+
. After eating it, the integer in his mind becomes 1. - The fourth integer to eat is
+
. After eating it, the integer in his mind becomes 2.
Thus, the integer in Takahashi's mind after he eats all the symbols is 2.
Sample Input 2
-+--
Sample Output 2
-2
Sample Input 3
----
Sample Output 3
-4