content: package v005;
  import java.io.BufferedReader;
  import java.io.FileReader;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.InputStreamReader;
  import java.io.PrintWriter;
  import java.util.StringTokenizer;
   
   
  public class ClockHands_UVa579 {
  	
  	public static void main(String[] args) throws IOException {
  		Scanner sc = new Scanner(System.in);
  		PrintWriter out = new PrintWriter(System.out);
  		
  		while(true)
  		{
  			StringTokenizer st = new StringTokenizer(sc.next(), ":");
  			int h = Integer.parseInt(st.nextToken());
  			int m = Integer.parseInt(st.nextToken());
  			if(h + m == 0)
  				break;
  			h %= 12;
  			double angle = Math.abs((h * 60 + m) / (60.0 * 12.0) - m / 60.0) * 360;
  			out.printf("%.3f\n", Math.min(angle, 360 - angle));
  		}
  		out.flush();
  		out.close();
  	}
  		
  	static class Scanner 
  	{
  		StringTokenizer st;
  		BufferedReader br;
   
  		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}
  		
  		public Scanner(FileReader s){	br = new BufferedReader(s);}
   
  		public String next() throws IOException 
  		{
  			while (st == null || !st.hasMoreTokens()) 
  				st = new StringTokenizer(br.readLine());
  			return st.nextToken();
  		}
   
  		public int nextInt() throws IOException {return Integer.parseInt(next());}
   
  		public long nextLong() throws IOException {return Long.parseLong(next());}
   
  		public String nextLine() throws IOException {return br.readLine();}
   
  		public double nextDouble() throws IOException
  		{
  			return Double.parseDouble(next());
  		}
   
  		public boolean ready() throws IOException {return br.ready();}
   
   
  	}
  } 