import java.util.Scanner;
class Potential
{
	public static void main(String args[])
	{
		int sp, len, potent=0, i=0, j=0;
		boolean f=false;
		String temp="", sen;
		Scanner in = new Scanner(System.in);
		sp=1;
		System.out.println("Enter a 	sentence");
		sen=in.nextLine();
		len=sen.length();
		while(f=false)
		{
			if(sen.charAt(len)=='!' ||sen.charAt(len)=='?')
			{
				f=true;
				}
			else
			{
				System.out.println("ERROR: SENTENCE DOES NOT END WITH '!'OR '?'");
				System.out.println("Enter a sentence");
				sen=in.nextLine();				}
		}
		sen=sen.substring(0, len-1);
		len=len-1;
		for(i=0; i<len; i++)
			if(sen.charAt(i)==' ')
				sp=sp+1;	
		String pot[]=new String[sp];
		for(i=0; i<len; i++)
		{
			if(sen.charAt(i)!=' ')
			{
				temp=temp+sen.charAt(i);
				potent=potent+(int)sen.charAt(i);
			}
			else
			{
				System.out.println(temp + " = " + potent);
				pot[j]=temp;
				j=j+1;
			}
		}
		for(i=0; i<sp; i++)
		{
			for (j = i+1; j < sp; j++)
			{
				if (pot[i].compareTo(pot[i]) > 0)
				{
         		temp = pot[i];
         		pot[i] = pot[j];
         		pot[j] = temp;
         		}
			}
		}
		for(i=0; i<sp; i++)					System.out.print(pot[i]+" ");
}
}