/**
*思路:使用for循环逆遍历(会用到charAt():返回指定索引处的字符)
*/
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
while(scan.hasNext()){
String str = scan.nextLine(); // This is English
int len = str.length(); //获取输入字符总长度!
int count = 0; //用于记录最后一个字符长度!
for (int i=len-1;i>=0;i--){ //倒着遍历该字符串,遇见第一个空格就跳出循环,返回长度
char c = str.charAt(i); //charAt():返回指定索引处的字符。
if (c == ' '){ //遇见空格
break; //跳出循环
}
else{
count++; //没遇空格之前,i向前走一次,count加一次
}
}
System.out.println(count); //输出count值,即为所求最后字符长度!
}
}
}