/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.stream.*;
import java.util.function.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		String text="1 2 3 2 3 2 1 3";
		Map<String, Integer> map = Arrays.asList(text.split("\\s+")).stream().collect(
			Collectors.groupingBy(Function.identity(),
			LinkedHashMap::new,
			Collectors.reducing(0, e -> 1, Integer::sum))
		);
		System.out.println(map);
	}
}