import java.util.ArrayList;
import java.util.Scanner;
public class Kattis {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
ArrayList<String> al = new ArrayList<>();
String temp;
int longest = 0;
while(sc.hasNextLine()){
temp = sc.nextLine();
longest = temp.length() > longest ? temp.length() : longest;
al.add(temp);
}
int sum = 0;
for (int i = 0; i < al.size() -1; i++) {
sum += (longest - al.get(i).length()) * (longest - al.get(i).length());
}
System.out.println(sum);
}
}