If you need to consider wrap araound, then the code becomes a little bit more complex.
I hope you are able to simplify it, though.
import java.util.Scanner;
public class Main
{
public static void main(String[] args) throws Exception
{
Scanner in = new Scanner(System.in);
char a = in.next().charAt(0);
char b = in.next().charAt(0);
a = Character.toLowerCase(a);
b = Character.toLowerCase(b);
int d1, d2;
if ( a <= b )
{
d1 = b - a;
d2 = 26 - b + a;
}
else
{
d1 = a - b;
d2 = 26 - a + b;
}
int d;
if ( d1 <= d2)
d = d1;
else
d = d2;
System.out.println(d);
}
}