import java.util.*;enum A{A;System z;{for(Scanner r=new Scanner(z.in);r==r;z.out.println(180-(r.nextInt()-r.nextInt()+540)%360));}}