import java.util.Scanner;

public class Main {
    public static void main (String[] args) {
        Scanner scanner = new Scanner(System.in);
        String in = null;
        while (scanner.hasNext()) {
            in = scanner.next();
        }
        System.out.println(in.length());
    }
}

主要是Scanner的用法,next按空格区分读,要与nextLine进行区分;