Problem: Julia is going to cook a chicken in the kitchen of her dormitory. To save energy, the stove in the kitchen automatically turns off after k minutes after turning on.

During cooking, Julia goes to the kitchen every d minutes and turns on the stove if it is turned off. While the cooker is turned off, it stays warm. The stove switches on and off instantly.

It is known that the chicken needs t minutes to be cooked on the stove, if it is turned on, and 2t minutes, if it is turned off. You need to find out, how much time will Julia have to cook the chicken, if it is considered that the chicken is cooked evenly, with constant speed when the stove is turned on and at a constant speed when it is turned off.

Input

The single line contains three integers k, d and t (1 ≤ k, d, t ≤ 1018).

Output

Print a single number, the total time of cooking in minutes. The relative or absolute error must not exceed 10 - 9.

Namely, let's assume that your answer is x and the answer of the jury is y. The checker program will consider your answer correct if <image>.

Examples

Input

3 2 6


Output

6.5


Input

4 2 20


Output

20.0

Note

In the first example, the chicken will be cooked for 3 minutes on the turned on stove, after this it will be cooked for <image>. Then the chicken will be cooked for one minute on a turned off stove, it will be cooked for <image>. Thus, after four minutes the chicken will be cooked for <image>. Before the fifth minute Julia will turn on the stove and after 2.5 minutes the chicken will be ready <image>.

In the second example, when the stove is turned off, Julia will immediately turn it on, so the stove will always be turned on and the chicken will be cooked in 20 minutes.

Solution (in JAVA):

Solution:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;


public class Main {

	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskC {
		static boolean visited[] = new boolean [26] ;
		static boolean found = false; 
		static int n ; 
		static int[][] memo ;
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			double k = 1.0*Long.parseLong(in.next()) ; 
			double d = 1.0*Long.parseLong(in.next()) ; 
			double t = 1.0*Long.parseLong(in.next()) ; 

			if(d<k && k%d !=0)
			{
				long p = (long) (k / d) ; 
				p++ ;
				double t1 = (k/t)  ;
				double t2 = (d*p - k) / (2*t) ;
				double compInOneCycle = t1+t2 ; 
				long x =  (long) (1/compInOneCycle) ;
				double rem = 1-(x*compInOneCycle) ;

				if(rem<=t1) 
					out.print(x*d*p + rem/t1*k);
				else
					out.print(x*d*p + k + (rem- k/t)/t2* (d*p - k) );


			}
			if(d==k || k%d==0) ////always on case
			{
				out.print(t) ;
			}
			if(d>k)
			{
				double t1 = (k/t)  ;
				double t2 = (d-k) / (2*t) ;
				double compInOneCycle = t1 + t2 ; 
				long x =  (long) (1/compInOneCycle) ;
				double rem = 1-(x*compInOneCycle) ;
				if(rem<=t1) 
					out.print(x*d + rem/t1*k);
				else
					out.print(x*d + k + (rem- k/t)/t2*(d-k) );



			}


		}
		public static long getSmallestDivisor( long y){
			if(isPrime(y))
				return -1;

			for (long i = 2; i*i <= y; i++)
			{
				if(y%i ==0)
				{
					return i;
				}
			}
			return -1;
		}
		public static void lis(pair []a , int n){
			int lis[] = new int[n] ; 
			Arrays.fill(lis,1) ; 

			for(int i=1;i<n;i++)
				for(int j=0 ; j<i; j++)
					if (a[i].y>a[j].y &&  lis[i] < lis[j]+1)   
						lis[i] = lis[j] + 1;           

			int max = lis[0];

			for(int i=1; i<n ; i++)
				if (max < lis[i])
					max = lis[i] ;
			System.out.println(max);

			ArrayList<Integer> s = new ArrayList<Integer>() ;
			for (int i = n-1; i >=0; i--)
			{
				if(lis[i]==max)
				{
					s.add(a[i].z);
					max --; 
				}
			}

			for (int i = s.size()-1 ; i>=0 ;  i--)
			{
				System.out.print(s.get(i)+" ");
			}

			return  ; 
		}

		public static int helper(int a[] , int i , int j , int d ,  int n){
			if(j==i || i==n-1 || j==0)
				return 0; 
			if(a[j] - a[i] <= d)
				return 0; 
			if(memo[i][j]!= -1)
				return memo[i][j] ; 

			if( a[j-1]-a[i]< a[j]-a[i+1])
				return memo[i][j]=1 + helper(a, i, j-1, d , n) ; 
			if( a[j-1]-a[i]> a[j]-a[i+1])
				return memo[i][j]=1+ helper(a , i+1 , j , d ,n ) ;
			return memo[i][j]=1+ Math.min(helper(a, i, j-1, d , n) , helper(a , i+1 , j , d ,n )) ;

		}
		public static boolean isPrime (long num){
			if (num < 2) return false;
			if (num == 2) return true;
			if (num % 2 == 0) return false;
			for (int i = 3; i * i <= num; i += 2)
				if (num % i == 0) return false;
			return true;
		}

		public static boolean dfs(Vertix v , int target){
			visited[v.i]= true ;
			if(v.i == target)
				return true ;
			for (int i =0 ; i< v.neighbours.size() ; i++)
			{ 

				Vertix child = v.neighbours.get(i) ;
				if(child.i == target){
					found = true  ; 
				}
				if(visited[child.i]==false){
					found |= dfs(child, target) ;
				}
			}
			return found; 
		}





	}
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
	public static class Vertix{
		int i ; 
		ArrayList<Vertix> neighbours ; 

		public Vertix(int i){
			this.i = i ;
			this.neighbours = new ArrayList<Vertix> () ;
		}
	}

	public static class pair implements Comparable<pair>{
		int x ; 
		int y ; 
		int z ; 

		public pair(int x, int y , int z){
			this.x=x ; 
			this.y=y ;
			this.z =z ;
		}

		@Override
		public int compareTo(pair p) {
			if(this.x > p.x)
				return 1 ; 
			else if(this.x== p.x)
			{
				if(this.y >= p.y)
					return -1 ;
				else 
					return 1 ;
			}
			else return -1 ;


		}


	}


}