#include<iostream>
#include<string>
using namespace std;
int main()
{
    string s1;
    getline(cin,s1);
    int pos=s1.rfind(" ");
    int len=s1.size()-pos-1; //s1总长度减去倒数第一个空格前面的,在减去空格就是后面单词的长度
    cout<<len<<endl;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: