#include <iostream>
#include <string>
using namespace std;

int main(){
    string s;
    getline(cin,s);

    if(s.empty()){
        cout << 0;
        return 0;
    }

    int cnt = 1;

    for(int i=0; i<s.length(); i++){
        if(s[i] == ' '){
            cnt++;    
        }
    }
    if(s[0] == ' ') cnt--;
    if(s[s.length()-1] == ' ') cnt--;
    cout << cnt;
    return 0;
}

'백준알고리즘' 카테고리의 다른 글

백준 5622 C++  (0) 2021.07.02
백준 2908 C++  (0) 2021.07.02
백준 1157 C++  (0) 2021.07.01
백준 2675 C++  (0) 2021.07.01
백준 10809 C++  (0) 2021.06.30

+ Recent posts