用split按空格分开,输出各串的0下标字符即可:

import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception{
        Scanner sc = new Scanner(System.in);
        String[] s = sc.nextLine().split(" ");
        for(String i : s) System.out.print(i.charAt(0));
    }
}