import java.util.*;
import java.io.*;
import java.lang.*;

public class codes_2
	{

		public static void main(String[] args)
		{
			InputReader in = new InputReader(System.in);
			PrintWriter pw = new PrintWriter(System.out);

			//Code starts..

			double k = in.nextLong();
			double d = in.nextLong();
			double t = in.nextLong();

			double tot = Math.ceil((k/d))* d;
			double on = k/tot;
			double off =( d -k%d)/tot;

			//pw.println(on+" "+off);

			double one = on/t  + off/(2*t);
			double ptime = 1/one;
			ptime = Math.floor(ptime/tot)*tot;
			double ans = ptime;
			ptime = ptime * one;
			double rem = 1 - ptime;
			//pw.println(ans);
			//pw.println(rem);
			if(rem*t<=k) {
				ans += rem*t;
			}
			else
			{
				ans += k;
				//pw.println(ans);
				rem = rem - k/t;
				//pw.println(rem);
				ans += rem*(2*t);

			}
			pw.println(ans);
			//Code ends....

			pw.flush();
			pw.close();
		}

		static class InputReader
		{

			private final InputStream stream;
			private final byte[] buf = new byte[8192];
			private int curChar, snumChars;
			private SpaceCharFilter filter;

			public InputReader(InputStream stream)
			{
				this.stream = stream;
			}

			public int snext()
			{
				if (snumChars == -1)
					throw new InputMismatchException();
				if (curChar >= snumChars)
				{
					curChar = 0;
					try
					{
						snumChars = stream.read(buf);
					}
					catch (IOException e)
					{
						throw new InputMismatchException();
					}
					if (snumChars <= 0)
						return -1;
				}
				return buf[curChar++];
			}

			public int nextInt()
		    {
				int c = snext();
				while (isSpaceChar(c))
				{
					c = snext();
				}
				int sgn = 1;
				if (c == '-')
			    {
					sgn = -1;
					c = snext();
				}
				int res = 0;
				do
				{
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					res *= 10;
					res += c - '0';
					c = snext();
				} while (!isSpaceChar(c));
				return res * sgn;
			}

			public long nextLong()
		    {
				int c = snext();
				while (isSpaceChar(c))
				{
					c = snext();
				}
				int sgn = 1;
				if (c == '-')
				{
					sgn = -1;
					c = snext();
				}
				long res = 0;
				do
				{
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					res *= 10;
					res += c - '0';
					c = snext();
				} while (!isSpaceChar(c));
				return res * sgn;
			}

			public int[] nextIntArray(int n)
			{
				int a[] = new int[n];
				for (int i = 0; i < n; i++)
				{
					a[i] = nextInt();
				}
				return a;
			}

			public String readString()
		    {
				int c = snext();
				while (isSpaceChar(c))
				{
					c = snext();
				}
				StringBuilder res = new StringBuilder();
				do
				{
					res.appendCodePoint(c);
					c = snext();
				} while (!isSpaceChar(c));
				return res.toString();
			}

			public String nextLine()
			{
				int c = snext();
				while (isSpaceChar(c))
					c = snext();
				StringBuilder res = new StringBuilder();
				do
				{
					res.appendCodePoint(c);
					c = snext();
				} while (!isEndOfLine(c));
				return res.toString();
			}

			public boolean isSpaceChar(int c)
			{
				if (filter != null)
					return filter.isSpaceChar(c);
				return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
			}

			private boolean isEndOfLine(int c)
			{
				return c == '\n' || c == '\r' || c == -1;
			}

			public interface SpaceCharFilter
		    {
				public boolean isSpaceChar(int ch);
			}
		}
		public static long c = 0;

		public static long mod = 1000000007;
		public static int d;
		public static int p;
		public static int q;

		public static  int gcd(int p2, int p22)
		{
		    if (p2 == 0)
		        return (int) p22;
		    return gcd(p22%p2, p2);
		}

		public static int findGCD(int arr[], int n)
		{
		    int result = arr[0];
		    for (int i=1; i<n; i++)
		        result = gcd(arr[i], result);

		    return result;
		}

	    public static long lcm(int[] numbers) {
	        long lcm = 1;
	        int divisor = 2;
	        while (true) {
	            int cnt = 0;
	            boolean divisible = false;
	            for (int i = 0; i < numbers.length; i++) {
	                if (numbers[i] == 0) {
	                    return 0;
	                } else if (numbers[i] < 0) {
	                    numbers[i] = numbers[i] * (-1);
	                }
	                if (numbers[i] == 1) {
	                    cnt++;
	                }
	                if (numbers[i] % divisor == 0) {
	                    divisible = true;
	                    numbers[i] = numbers[i] / divisor;
	                }
	            }
	            if (divisible) {
	                lcm = lcm * divisor;
	            } else {
	                divisor++;
	            }
	            if (cnt == numbers.length) {
	                return lcm;
	            }
	        }
	    }
		public static long fact(long n) {

			long factorial = 1;
			 for(int i = 1; i <= n; i++)
		        {
		            factorial *= i;
		        }
			 return factorial;
		}

		public static int lowerLimit(int[] a, int n) {
			int ans = 0;

			int ll = 0;
			int rl = a.length-1;
		//	System.out.println(a[rl]+" "+n);
			if(a[0]>n)
				return 0;
			if(a[0]==n)
				return 1;
			else if(a[rl]<=n)
				return rl+1;

			while(ll<=rl)
			{

				int mid = (ll+rl)/2;
				if(a[mid]==n)
				{
					ans = mid + 1;
					break;
				}

				else if(a[mid]>n)
				{
					rl = mid-1;

				}
				else
				{
					ans = mid+1;
					ll = mid+1;
				}
			}

			return ans;
		}

		public static long choose(long total, long choose){
		    if(total < choose)
		        return 0;
		    if(choose == 0 || choose == total)
		        return 1;
		    return (choose(total-1,choose-1)+choose(total-1,choose))%mod;
		}

		public static int[] suffle(int[] a,Random gen)
		{
			int n = a.length;
			for(int i=0;i<n;i++)
			{
				int ind = gen.nextInt(n-i)+i;
				int temp = a[ind];
				a[ind] = a[i];
				a[i] = temp;
			}
			return a;
		}

		public static int floorSearch(int arr[], int low, int high, int x)
		{
		    if (low > high)
		        return -1;

		    if (x > arr[high])
		        return high;
		    int mid = (low+high)/2;

		    if (mid > 0 && arr[mid-1] < x && x < arr[mid])
		        return mid-1;

		    if (x < arr[mid])
		        return floorSearch(arr, low, mid-1, x);

		    return floorSearch(arr, mid+1, high, x);
		}

		public static void swap(int a, int b){
			int temp = a;
			a = b;
			b = temp;
		}
		public static ArrayList<Integer> primeFactorization(int n)
		{
			ArrayList<Integer> a =new ArrayList<Integer>();
			for(int i=2;i*i<=n;i++)
			{
				while(n%i==0)
				{
					a.add(i);
					n/=i;
				}
			}
			if(n!=1)
				a.add(n);
			return a;
		}

		public static void sieve(boolean[] isPrime,int n)
		{
			for(int i=1;i<n;i++)
				isPrime[i] = true;

			isPrime[0] = false;
			isPrime[1] = false;

			for(int i=2;i*i<n;i++)
			{
				if(isPrime[i] == true)
				{
					for(int j=(2*i);j<n;j+=i)
						isPrime[j] = false;
				}
			}
		}

		public static int GCD(int a,int b)
		{
			if(b==0)
				return a;
			else
				return GCD(b,a%b);
		}

		public static long GCD(long a,long b)
		{
			if(b==0)
				return a;
			else
				return GCD(b,a%b);
		}

		public static void extendedEuclid(int A,int B)
		{
			if(B==0)
			{
				d = A;
				p = 1 ;
				q = 0;
			}
			else
			{
				extendedEuclid(B, A%B);
				int temp = p;
				p = q;
				q = temp - (A/B)*q;
			}
		}

		public static long LCM(long a,long b)
		{
			return (a*b)/GCD(a,b);
		}

		public static int LCM(int a,int b)
		{
			return (a*b)/GCD(a,b);
		}

		public static int binaryExponentiation(int x,int n)
		{
		    int result=1;
		    while(n>0)
		    {
		        if(n % 2 ==1)
		            result=result * x;
		        x=x*x;
		        n=n/2;
		    }
		    return result;
		}

		public static int[] countDer(int n)
	    {
	        int der[] = new int[n + 1];

	        der[0] = 1;
	        der[1] = 0;
	        der[2] = 1;

	        for (int i = 3; i <= n; ++i)
	            der[i] = (i - 1) * (der[i - 1] + der[i - 2]);

	        // Return result for n
	        return der;
	    }

		 static long binomialCoeff(int n, int k)
		    {
		    long C[][] = new long[n+1][k+1];
		    int i, j;

		        // Calculate  value of Binomial Coefficient in bottom up manner
		    for (i = 0; i <= n; i++)
		    {
		        for (j = 0; j <= Math.min(i, k); j++)
		        {
		            // Base Cases
		            if (j == 0 || j == i)
		                C[i][j] = 1;

		            // Calculate value using previosly stored values
		            else
		                C[i][j] = C[i-1][j-1] + C[i-1][j];
		          }
		     }

		    return C[n][k];
		    }

		public static long binaryExponentiation(long x,long n)
		{
		    long result=1;
		    while(n>0)
		    {
		        if(n % 2 ==1)
		            result=result * x;
		        x=(x%mod * x%mod)%mod;
		        n=n/2;
		    }
		    return result;
		}

		public static int modularExponentiation(int x,int n,int M)
		{
		    int result=1;
		    while(n>0)
		    {
		        if(n % 2 ==1)
		            result=(result * x)%M;
		        x=(x*x)%M;
		        n=n/2;
		    }
		    return result;
		}

		public static long modularExponentiation(long x,long n,long M)
		{
		    long result=1;
		    while(n>0)
		    {
		        if(n % 2 ==1)
		            result=(result * x)%M;
		        x=(x*x)%M;
		        n=n/2;
		    }
		    return result;
		}

		public static int modInverse(int A,int M)
		{
		    return modularExponentiation(A,M-2,M);
		}

		public static long modInverse(long A,long M)
		{
		    return modularExponentiation(A,M-2,M);
		}

		public static boolean isPrime(int n)
		{

		    if (n <= 1)  return false;
		    if (n <= 3)  return true;

		    if (n%2 == 0 || n%3 == 0)
		    	return false;

		    for (int i=5; i*i<=n; i=i+6)
		    {
		        if (n%i == 0 || n%(i+2) == 0)
		           return false;
		    }

		    return true;
		}

		static class pair implements Comparable<pair>

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

			public int compareTo(pair o) {
				int result = x.compareTo(o.x);
				if(result==0)
					result = y.compareTo(o.y);

				return result;
			}

			public String toString()
			{
				return x+" "+y;
			}

			public boolean equals(Object o)
			{
				if (o instanceof pair)
			    {
					pair p = (pair)o;
					return p.x == x && p.y == y ;
				}
				return false;
			}

			public int hashCode()
			{
				return new Long(x).hashCode()*31 + new Long(y).hashCode();
			}
		}

		static class triplet implements Comparable<triplet>
		{
			Integer x,y,z;
			triplet(int x,int y,int z)
			{
				this.x = x;
				this.y = y;
				this.z = z;
			}

			public  int compareTo(triplet o)
			{
				int result = x.compareTo(o.x);
				if(result==0)
					result =  y.compareTo(o.y);
				if(result==0)
					result = z.compareTo(o.z);

				return result;
			}

			public boolean equlas(Object o)
			{
				if(o instanceof triplet)
				{
					triplet p = (triplet)o;
					return x==p.x && y==p.y && z==p.z;
				}
				return false;
			}

			public String toString()
			{
				return x+" "+y+" "+z;
			}
			public int hashCode()
			{
				return new Long(x).hashCode()*31 + new Long(y).hashCode() + new Long(z).hashCode();
			}
		}

		static class node implements Comparable<node>

		{
			Integer x, y, z;
			node(int x,int y, int z)
			{
				this.x=x;
				this.y=y;
				this.z=z;
			}

			public int compareTo(pair o) {
				int result = x.compareTo(o.x);
				if(result==0)
					result = y.compareTo(o.y);
				if(result==0)
					result = z.compareTo(z);
				return result;
			}

			@Override
			public int compareTo(node o) {
				// TODO Auto-generated method stub
				return 0;
			}
		}
	}


import java.util.*;
import java.io.*;
import java.lang.*;

public class codes_2
	{

		public static void main(String[] args)
		{
			InputReader in = new InputReader(System.in);
			PrintWriter pw = new PrintWriter(System.out);

			//Code starts..

			double k = in.nextLong();
			double d = in.nextLong();
			double t = in.nextLong();

			double tot = Math.ceil((k/d))* d;
			double on = k/tot;
			double off =0;
			if(k%d>0)
				off =( d - k%d)/tot;
			else
				off =( k%d)/tot;
			//pw.println(on+" "+off);

			double one = on/t  + off/(2*t);
			double ptime = 1/one;
			ptime = Math.floor(ptime/tot)*tot;
			double ans = ptime;
			ptime = ptime * one;
			double rem = 1 - ptime;
			//pw.println(ans);
			//pw.println(rem);
			if(rem*t<=k) {
				ans += rem*t;
			}
			else
			{
				ans += k;
				//pw.println(ans);
				rem = rem - k/t;
				//pw.println(rem);
				ans += rem*(2*t);

			}
			pw.println(ans);
			//Code ends....

			pw.flush();
			pw.close();
		}

		static class InputReader
		{

			private final InputStream stream;
			private final byte[] buf = new byte[8192];
			private int curChar, snumChars;
			private SpaceCharFilter filter;

			public InputReader(InputStream stream)
			{
				this.stream = stream;
			}

			public int snext()
			{
				if (snumChars == -1)
					throw new InputMismatchException();
				if (curChar >= snumChars)
				{
					curChar = 0;
					try
					{
						snumChars = stream.read(buf);
					}
					catch (IOException e)
					{
						throw new InputMismatchException();
					}
					if (snumChars <= 0)
						return -1;
				}
				return buf[curChar++];
			}

			public int nextInt()
		    {
				int c = snext();
				while (isSpaceChar(c))
				{
					c = snext();
				}
				int sgn = 1;
				if (c == '-')
			    {
					sgn = -1;
					c = snext();
				}
				int res = 0;
				do
				{
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					res *= 10;
					res += c - '0';
					c = snext();
				} while (!isSpaceChar(c));
				return res * sgn;
			}

			public long nextLong()
		    {
				int c = snext();
				while (isSpaceChar(c))
				{
					c = snext();
				}
				int sgn = 1;
				if (c == '-')
				{
					sgn = -1;
					c = snext();
				}
				long res = 0;
				do
				{
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					res *= 10;
					res += c - '0';
					c = snext();
				} while (!isSpaceChar(c));
				return res * sgn;
			}

			public int[] nextIntArray(int n)
			{
				int a[] = new int[n];
				for (int i = 0; i < n; i++)
				{
					a[i] = nextInt();
				}
				return a;
			}

			public String readString()
		    {
				int c = snext();
				while (isSpaceChar(c))
				{
					c = snext();
				}
				StringBuilder res = new StringBuilder();
				do
				{
					res.appendCodePoint(c);
					c = snext();
				} while (!isSpaceChar(c));
				return res.toString();
			}

			public String nextLine()
			{
				int c = snext();
				while (isSpaceChar(c))
					c = snext();
				StringBuilder res = new StringBuilder();
				do
				{
					res.appendCodePoint(c);
					c = snext();
				} while (!isEndOfLine(c));
				return res.toString();
			}

			public boolean isSpaceChar(int c)
			{
				if (filter != null)
					return filter.isSpaceChar(c);
				return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
			}

			private boolean isEndOfLine(int c)
			{
				return c == '\n' || c == '\r' || c == -1;
			}

			public interface SpaceCharFilter
		    {
				public boolean isSpaceChar(int ch);
			}
		}
		public static long c = 0;

		public static long mod = 1000000007;
		public static int d;
		public static int p;
		public static int q;

		public static  int gcd(int p2, int p22)
		{
		    if (p2 == 0)
		        return (int) p22;
		    return gcd(p22%p2, p2);
		}

		public static int findGCD(int arr[], int n)
		{
		    int result = arr[0];
		    for (int i=1; i<n; i++)
		        result = gcd(arr[i], result);

		    return result;
		}

	    public static long lcm(int[] numbers) {
	        long lcm = 1;
	        int divisor = 2;
	        while (true) {
	            int cnt = 0;
	            boolean divisible = false;
	            for (int i = 0; i < numbers.length; i++) {
	                if (numbers[i] == 0) {
	                    return 0;
	                } else if (numbers[i] < 0) {
	                    numbers[i] = numbers[i] * (-1);
	                }
	                if (numbers[i] == 1) {
	                    cnt++;
	                }
	                if (numbers[i] % divisor == 0) {
	                    divisible = true;
	                    numbers[i] = numbers[i] / divisor;
	                }
	            }
	            if (divisible) {
	                lcm = lcm * divisor;
	            } else {
	                divisor++;
	            }
	            if (cnt == numbers.length) {
	                return lcm;
	            }
	        }
	    }
		public static long fact(long n) {

			long factorial = 1;
			 for(int i = 1; i <= n; i++)
		        {
		            factorial *= i;
		        }
			 return factorial;
		}

		public static int lowerLimit(int[] a, int n) {
			int ans = 0;

			int ll = 0;
			int rl = a.length-1;
		//	System.out.println(a[rl]+" "+n);
			if(a[0]>n)
				return 0;
			if(a[0]==n)
				return 1;
			else if(a[rl]<=n)
				return rl+1;

			while(ll<=rl)
			{

				int mid = (ll+rl)/2;
				if(a[mid]==n)
				{
					ans = mid + 1;
					break;
				}

				else if(a[mid]>n)
				{
					rl = mid-1;

				}
				else
				{
					ans = mid+1;
					ll = mid+1;
				}
			}

			return ans;
		}

		public static long choose(long total, long choose){
		    if(total < choose)
		        return 0;
		    if(choose == 0 || choose == total)
		        return 1;
		    return (choose(total-1,choose-1)+choose(total-1,choose))%mod;
		}

		public static int[] suffle(int[] a,Random gen)
		{
			int n = a.length;
			for(int i=0;i<n;i++)
			{
				int ind = gen.nextInt(n-i)+i;
				int temp = a[ind];
				a[ind] = a[i];
				a[i] = temp;
			}
			return a;
		}

		public static int floorSearch(int arr[], int low, int high, int x)
		{
		    if (low > high)
		        return -1;

		    if (x > arr[high])
		        return high;
		    int mid = (low+high)/2;

		    if (mid > 0 && arr[mid-1] < x && x < arr[mid])
		        return mid-1;

		    if (x < arr[mid])
		        return floorSearch(arr, low, mid-1, x);

		    return floorSearch(arr, mid+1, high, x);
		}

		public static void swap(int a, int b){
			int temp = a;
			a = b;
			b = temp;
		}
		public static ArrayList<Integer> primeFactorization(int n)
		{
			ArrayList<Integer> a =new ArrayList<Integer>();
			for(int i=2;i*i<=n;i++)
			{
				while(n%i==0)
				{
					a.add(i);
					n/=i;
				}
			}
			if(n!=1)
				a.add(n);
			return a;
		}

		public static void sieve(boolean[] isPrime,int n)
		{
			for(int i=1;i<n;i++)
				isPrime[i] = true;

			isPrime[0] = false;
			isPrime[1] = false;

			for(int i=2;i*i<n;i++)
			{
				if(isPrime[i] == true)
				{
					for(int j=(2*i);j<n;j+=i)
						isPrime[j] = false;
				}
			}
		}

		public static int GCD(int a,int b)
		{
			if(b==0)
				return a;
			else
				return GCD(b,a%b);
		}

		public static long GCD(long a,long b)
		{
			if(b==0)
				return a;
			else
				return GCD(b,a%b);
		}

		public static void extendedEuclid(int A,int B)
		{
			if(B==0)
			{
				d = A;
				p = 1 ;
				q = 0;
			}
			else
			{
				extendedEuclid(B, A%B);
				int temp = p;
				p = q;
				q = temp - (A/B)*q;
			}
		}

		public static long LCM(long a,long b)
		{
			return (a*b)/GCD(a,b);
		}

		public static int LCM(int a,int b)
		{
			return (a*b)/GCD(a,b);
		}

		public static int binaryExponentiation(int x,int n)
		{
		    int result=1;
		    while(n>0)
		    {
		        if(n % 2 ==1)
		            result=result * x;
		        x=x*x;
		        n=n/2;
		    }
		    return result;
		}

		public static int[] countDer(int n)
	    {
	        int der[] = new int[n + 1];

	        der[0] = 1;
	        der[1] = 0;
	        der[2] = 1;

	        for (int i = 3; i <= n; ++i)
	            der[i] = (i - 1) * (der[i - 1] + der[i - 2]);

	        // Return result for n
	        return der;
	    }

		 static long binomialCoeff(int n, int k)
		    {
		    long C[][] = new long[n+1][k+1];
		    int i, j;

		        // Calculate  value of Binomial Coefficient in bottom up manner
		    for (i = 0; i <= n; i++)
		    {
		        for (j = 0; j <= Math.min(i, k); j++)
		        {
		            // Base Cases
		            if (j == 0 || j == i)
		                C[i][j] = 1;

		            // Calculate value using previosly stored values
		            else
		                C[i][j] = C[i-1][j-1] + C[i-1][j];
		          }
		     }

		    return C[n][k];
		    }

		public static long binaryExponentiation(long x,long n)
		{
		    long result=1;
		    while(n>0)
		    {
		        if(n % 2 ==1)
		            result=result * x;
		        x=(x%mod * x%mod)%mod;
		        n=n/2;
		    }
		    return result;
		}

		public static int modularExponentiation(int x,int n,int M)
		{
		    int result=1;
		    while(n>0)
		    {
		        if(n % 2 ==1)
		            result=(result * x)%M;
		        x=(x*x)%M;
		        n=n/2;
		    }
		    return result;
		}

		public static long modularExponentiation(long x,long n,long M)
		{
		    long result=1;
		    while(n>0)
		    {
		        if(n % 2 ==1)
		            result=(result * x)%M;
		        x=(x*x)%M;
		        n=n/2;
		    }
		    return result;
		}

		public static int modInverse(int A,int M)
		{
		    return modularExponentiation(A,M-2,M);
		}

		public static long modInverse(long A,long M)
		{
		    return modularExponentiation(A,M-2,M);
		}

		public static boolean isPrime(int n)
		{

		    if (n <= 1)  return false;
		    if (n <= 3)  return true;

		    if (n%2 == 0 || n%3 == 0)
		    	return false;

		    for (int i=5; i*i<=n; i=i+6)
		    {
		        if (n%i == 0 || n%(i+2) == 0)
		           return false;
		    }

		    return true;
		}

		static class pair implements Comparable<pair>

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

			public int compareTo(pair o) {
				int result = x.compareTo(o.x);
				if(result==0)
					result = y.compareTo(o.y);

				return result;
			}

			public String toString()
			{
				return x+" "+y;
			}

			public boolean equals(Object o)
			{
				if (o instanceof pair)
			    {
					pair p = (pair)o;
					return p.x == x && p.y == y ;
				}
				return false;
			}

			public int hashCode()
			{
				return new Long(x).hashCode()*31 + new Long(y).hashCode();
			}
		}

		static class triplet implements Comparable<triplet>
		{
			Integer x,y,z;
			triplet(int x,int y,int z)
			{
				this.x = x;
				this.y = y;
				this.z = z;
			}

			public  int compareTo(triplet o)
			{
				int result = x.compareTo(o.x);
				if(result==0)
					result =  y.compareTo(o.y);
				if(result==0)
					result = z.compareTo(o.z);

				return result;
			}

			public boolean equlas(Object o)
			{
				if(o instanceof triplet)
				{
					triplet p = (triplet)o;
					return x==p.x && y==p.y && z==p.z;
				}
				return false;
			}

			public String toString()
			{
				return x+" "+y+" "+z;
			}
			public int hashCode()
			{
				return new Long(x).hashCode()*31 + new Long(y).hashCode() + new Long(z).hashCode();
			}
		}

		static class node implements Comparable<node>

		{
			Integer x, y, z;
			node(int x,int y, int z)
			{
				this.x=x;
				this.y=y;
				this.z=z;
			}

			public int compareTo(pair o) {
				int result = x.compareTo(o.x);
				if(result==0)
					result = y.compareTo(o.y);
				if(result==0)
					result = z.compareTo(z);
				return result;
			}

			@Override
			public int compareTo(node o) {
				// TODO Auto-generated method stub
				return 0;
			}
		}
	}


import java.util.*;
import java.io.*;
public class Solution {
    public static void main(String[] args) {
        Scanner sc =  new Scanner(System.in);
        double k,d,t;
        k = sc.nextDouble();
        d = sc.nextDouble();
        t = sc.nextDouble();
        if(k%d==0) System.out.println(t);
        else{
            double droit=0;
            double xturn=0;
            if(k>d){
                droit = k/d;
                droit = Math.ceil(droit);
                xturn = d*droit;
                droit = d*droit - k;
            }
            else{
                droit = d - k;
                xturn = d;
            }

            double turn = k + droit*0.5;

            long nb = (long) (t/turn);
            t -= turn * nb;
            double rep = xturn*nb;
            if(t<=k) rep += t;
            else{
                t -= k;
                rep += k;
                rep += t*2;
            }
            System.out.println(rep);
        }
    }

}


import java.io.*;
import java.util.*;
import java.lang.*;

public class Rextester{
    static boolean isPrime(int x){
        for(int i=2;i<=Math.sqrt(x);i++){
            if(x%i==0){
                return false;
            }
        }
        return true;
    }
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        br.close();
        int p = new Integer(st.nextToken());
        int y = new Integer(st.nextToken());
        if(y%2==0){
            y--;
        }
        if(p<10){
            for(int i=y;i>=p;i--){
                if(isPrime(i)){
                    System.out.println(i);
                    return;
                }
                else{
                    int j;
                    for(j=3;j<p;j++){
                        if(i%j==0){
                            break;
                        }
                    }
                    if(j==p){
                        System.out.println(i);
                        return;
                    }
                }
            }
        }
        else{
            for(int i=y;i>=p;i--){
                if(isPrime(i)){
                    System.out.println(i);
                    return;
                }
            }
        }
        System.out.println("-1");
    }
}


import java.io.*;
import java.util.*;
import java.lang.*;

public class Rextester{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        br.close();
        long k = new Long(st.nextToken());
        long d = new Long(st.nextToken());
        long t = new Long(st.nextToken());
        if(k%d==0){
            double ans = (double)t;
            System.out.println(ans);
            return;
        }
        else{
            long dur = ((k/d)+1)*d;
            long on = k;
            long off = dur - k;
            //System.out.println(dur);
            double heaton = 1.0/(double)t;
            double heatoff = 1.0/(double)(2*t);
            double onp = on*heaton;
            double onf = off*heatoff;
            //System.out.println(onp+" "+onf);
            double total = onp+onf;
            double ans = 0.0;
            double time = 1.0/total;
            ans+=(long)time;
            //System.out.println(ans);
            double left = 1.0-(ans*total);
            //System.out.println(left);
            ans*=dur;
            if(left-onp<=0.0){
                //System.out.println(left/heaton);
                ans+=(left/heaton);
            }
            else{
                ans+=k;
                //System.out.println(ans);
                left-=onp;
                ans+=(left/heatoff);
            }
            System.out.println(ans);
            return;
        }
    }
}


import java.io.*;
import java.util.*;
import java.lang.*;

public class Rextester{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        br.close();
        long k = new Long(st.nextToken());
        long d = new Long(st.nextToken());
        long t = new Long(st.nextToken());
        if(k%d==0){
            double ans = (double)t;
            System.out.println(ans);
            return;
        }
        else{
            long dur = ((k/d)+1)*d;
            long on = k;
            long off = dur - k;
            double heaton = 1.0/(double)t;
            double heatoff = 1.0/(double)(2*t);
            double onp = on*heaton;
            double onf = off*heatoff;
            double total = onp+onf;
            double ans = 0.0;
            double time = 1.0/total;
            ans+=(long)time;
            double left = 1.0-ans*(total);
            //System.out.println(left);
            ans*=dur;
            if(left-onp<=0.0){
                //System.out.println(left/heaton);
                ans+=(left/heaton);
            }
            else{
                ans+=k;
                ans+=(left/heatoff);
            }
            System.out.println(ans);
            return;
        }
    }
}


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 ;

		}

	}

}


// Working program using Scanner
import java.io.*;
import java.util.*;
import java.math.*;
public class codeforce{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long t = sc.nextLong();
        long c = b*(long)Math.ceil((double)a/b);
        b = c-a;
        long e=0;
        long k = (long)((double)t/((double)a+(double)b/2));
        e += (a+b)*k;
        double d = (double)t - ((double)a+(double)b/2)*(double)k;
        double f;
        if(d<=(double)a) f = (double)e+d;
        else{
            e +=a;
            d-=(double)a;
            f = (double)e + d*2;
        }
        System.out.println(f);
    }
}


// Working program using Scanner
import java.io.*;
import java.util.*;
import java.math.*;
public class codeforce{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long t = sc.nextLong();
        long c = b*(long)Math.ceil((double)a/b);
        b = c-a;
        long e=0;
        long k = (long)((double)t/((double)a+(double)b/2));
        e += (a+b)*k;
        double d = (double)t - ((double)a+(double)b/2)*(double)k;
        double f;
        System.out.println(e+" "+((double)a+(double)b/2));
        if(d<=(double)a) f = (double)e+d;
        else{
            e +=a;
            d-=(double)a;
            f = (double)e + d*2;
        }
        System.out.println(doubleToString(f));
    }
    public static String doubleToString(Double d) {
    if (d == null)
        return null;
    if (d.isNaN() || d.isInfinite())
        return d.toString();

    // Pre Java 8, a value of 0 would yield "0.0" below
    if (d.doubleValue() == 0)
        return "0";
    return new BigDecimal(d.toString()).stripTrailingZeros().toPlainString();
}
}


// Working program using Scanner
import java.io.*;
import java.util.*;
public class codeforce{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long t = sc.nextLong();
        long c = b*(long)Math.ceil((double)a/b);
        b = c-a;
        long e=0;
        long k = (long)((double)t/((double)a+(double)b/2));
        e += (a+b)*k;
        double d = (double)t - ((double)a+(double)b/2)*(double)k;
        double f;
        if(d<=(double)a) f = (double)e+d;
        else{
            e +=a;
            d-=(double)a;
            f = (double)e + d/2;
        }
        System.out.println(f);
    }
}


// Working program using Scanner
import java.io.*;
import java.util.*;
import java.math.*;
public class codeforce{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long t = sc.nextLong();
        long c = b*(long)Math.ceil((double)a/b);
        b = c-a;
        long e=0;
        long k = (long)((double)t/((double)a+(double)b/2));
        e += (a+b)*k;
        double d = (double)t - ((double)a+(double)b/2)*(double)k;
        double f;
        if(d<=(double)a) f = (double)e+d;
        else{
            e +=a;
            d-=(double)a;
            f = (double)e + d*2;
        }
        System.out.println(doubleToString(f));
    }
    public static String doubleToString(Double d) {
    if (d == null)
        return null;
    if (d.isNaN() || d.isInfinite())
        return d.toString();

    // Pre Java 8, a value of 0 would yield "0.0" below
    if (d.doubleValue() == 0)
        return "0";
    return new BigDecimal(d.toString()).stripTrailingZeros().toPlainString();
}
}


// Working program using Scanner
import java.io.*;
import java.util.*;
import java.math.*;
public class codeforce{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long t = sc.nextLong();
        long c = b*(long)Math.ceil((double)a/b);
        b = c-a;
        long e=0;
        long k = (long)((double)t/((double)a+(double)b/2));
        e += (a+b)*k;
        double d = (double)t - ((double)a+(double)b/2)*(double)k;
        double f;
        if(d<=(double)a) f = (double)e+d;
        else{
            e +=a;
            d-=(double)a;
            f = (double)e + d/2;
        }
        System.out.println(doubleToString(f));
    }
    public static String doubleToString(Double d) {
    if (d == null)
        return null;
    if (d.isNaN() || d.isInfinite())
        return d.toString();

    // Pre Java 8, a value of 0 would yield "0.0" below
    if (d.doubleValue() == 0)
        return "0";
    return new BigDecimal(d.toString()).stripTrailingZeros().toPlainString();
}
}


import java.util.*;
import java.io.*;

public class Code {

  public static void main(String[] args) {
    FastReader in = new FastReader();
    PrintWriter out = new PrintWriter(System.out);

    long k = in.nextLong();
    long d = in.nextLong();
    long t = in.nextLong();

    long off = (k % d == 0 ? 0 : d - (k % d));
    long times =  (2 * t) / (2 * k + off);
    long remX = (2 * t) - (times * (2 * k + off));
    double result;
    if (remX < 2 * k)
      result = (double) remX / 2.0 + (double) times * (k + off);
    else {
      // k / t + x / 2 * t = remX / 12
      // 2 * k + x = remX * 2 * t / 12
      // 24k + 12x = remX * 2 * t
      long x = Math.max(0, remX - 2 * k);
      result = (double) (times * (k + off)) + (double) k + (double) x;
    }
    System.out.printf("%.12f", result);
  }

  static void shuffle(int[] a) {
    Random get = new Random();
    for (int i = 0; i < a.length; i++) {
      int r = get.nextInt(a.length);
      int temp = a[i];
      a[i] = a[r];
      a[r] = temp;
    }
  }

  static class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    public FastReader(String s) throws FileNotFoundException {
      br = new BufferedReader(new FileReader(new File(s)));
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

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

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }
  }
}


import java.util.*;
import java.io.*;

public class Code {

  public static void main(String[] args) {
    FastReader in = new FastReader();
    PrintWriter out = new PrintWriter(System.out);
    long k = in.nextLong();
    long d = in.nextLong();
    long t = in.nextLong();
    long off = (k % d == 0 ? 0 : d - (k % d));
    long times =  (2 * t) / (2 * k + off);
    long remX = (2 * t) - (times * (2 * k + off));
    double result;
    if (remX < 2 * k)
      result = (double) remX / 2.0 + (double) times * (k + off);
    else {
      long x = Math.max(0, remX - 2 * k);
      result = (double) (times * (k + off)) + (double) k + (double) x;
    }
    System.out.printf("%.12f", result);
  }

  static void shuffle(int[] a) {
    Random get = new Random();
    for (int i = 0; i < a.length; i++) {
      int r = get.nextInt(a.length);
      int temp = a[i];
      a[i] = a[r];
      a[r] = temp;
    }
  }

  static class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    public FastReader(String s) throws FileNotFoundException {
      br = new BufferedReader(new FileReader(new File(s)));
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

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

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }
  }
}


import java.util.*;
import java.io.*;

public class Code {

  public static void main(String[] args) {
    FastReader in = new FastReader();
    PrintWriter out = new PrintWriter(System.out);

    long k = in.nextLong();
    long d = in.nextLong();
    long t = in.nextLong();

    long off = (k % d == 0 ? 0 : d - (k % d));
    long times =  (2 * t) / (2 * k + off);
    long remX = (2 * t) - times * (2 * k + off);
    double result = (double) remX / 2.0 + (double) times * (k + off);
    System.out.printf("%.12f", result);
  }

  static void shuffle(int[] a) {
    Random get = new Random();
    for (int i = 0; i < a.length; i++) {
      int r = get.nextInt(a.length);
      int temp = a[i];
      a[i] = a[r];
      a[r] = temp;
    }
  }

  static class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    public FastReader(String s) throws FileNotFoundException {
      br = new BufferedReader(new FileReader(new File(s)));
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

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

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }
  }
}


import java.util.Scanner;

public class P937C
{
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		long k = scan.nextLong();
		long d = scan.nextLong();
		long t = scan.nextLong();
		long diff = k%d;
		long x = diff == 0 ? k : k-diff+d;
		double lo = 0, hi = (1e18)*2;
		for (int i = 0; i < 120; i++)
		{
			double mid = (lo+hi)/2;
			if (time(mid, k, d, t, x) >= t)
				hi = mid;
			else
				lo = mid;
		}
		System.out.println(lo);
	}

	private static double time(double total, long k, long d, long t, long x)
	{
		double ans = 0;
		long round = (long)total;
		long below = round - round%x;
		ans += 1.0*k * (below/x);
		ans += 0.5*(below-ans);
		double extra = Math.min(total - below, k);
		ans += extra;
		ans += 0.5*(total-below-extra);
		return ans;
	}
}


import java.io.*;
public class C2
{
public static void main(String args[]) throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String inp[]=br.readLine().split(" ");
long k=Long.parseLong(inp[0]);
long d=Long.parseLong(inp[1]);
long t=Long.parseLong(inp[2]);
if(k%d==0){
System.out.println(t);
return;
}
double c1=1.0/t,c2=1.0/(2*t);
long mod = k%d;
long periodLength = ((mod > 0) ? k/d + 1 : k/d) * d;
long idleMinutes = (mod > 0) ? d - mod : 0;
long workMinutes = periodLength-idleMinutes;
long t2 = t*2;
double res = t;
if (idleMinutes > 0)
{
            long cookingTimeMinutes2 = periodLength*2 - idleMinutes;

            long periodCounts = t2/cookingTimeMinutes2;
            long leftMinutes2 = t2%cookingTimeMinutes2;

            if (leftMinutes2 <= workMinutes*2) {
                res = periodCounts*periodLength+(double)leftMinutes2/2;
            } else {
                leftMinutes2-=workMinutes*2;
                res = periodCounts*periodLength+workMinutes+leftMinutes2;
            }
}
System.out.println(res);
}
}


import java.io.*;
public class C
{
public static void main(String args[]) throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String inp[]=br.readLine().split(" ");
long k=Long.parseLong(inp[0]);
long d=Long.parseLong(inp[1]);
long t=Long.parseLong(inp[2]);
if(k%d==0){
System.out.println(t);
return;
}
double c1=1.0/t,c2=1.0/(2*t);
double ans=c1*k;
boolean on=false;
long cur=k;
long next=((cur/d)+1)*d;
double time=k,tmp;
while(ans<1)
{
if(on)
{
tmp=ans+c1*(next-cur);
if(tmp>1)
time+=(1-ans)*t;
else
time+=next-cur;
ans=tmp;
}
else
{
tmp=ans+c2*(next-cur);
if(tmp>1)
time+=(1-ans)*2*t;
else
time+=next-cur;
ans=tmp;
}
//System.out.println(cur+"\t"+k);
cur+=k;
next+=((cur/d)+1)*d;
if(cur<=next)
on=true;
else
on=false;

}
System.out.println(time);
}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {

  public static void main(String[] args) throws Exception {
    FastInput fi = new FastInput(System.in);

    long t, d, k, T, D, K;
    K = k = fi.nextLong();
    D = d = fi.nextLong();
    T = t = fi.nextLong();

    t = 2*T;

    d = (k/d)*d;

    if(d<k)
      d+=D;

    long unitsPerCycle = 2 * k + (d - k);

    long cycles = t/unitsPerCycle;

    double time = cycles * d;

    long virtualTime = cycles * unitsPerCycle;

    double remaining = t - virtualTime;

    if(remaining > 0) {
      if (remaining <= 2 * k)
        time += remaining / 2;
      else {
        time += k;
        remaining -= 2 * k;
        time += remaining;
      }
    }

    System.out.println(time);

  }

  static class FastInput {

    BufferedReader reader;
    StringTokenizer st;

    public FastInput(InputStream inputStream) {
      reader = new BufferedReader(new InputStreamReader(inputStream), 32768);
    }

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

    int nextInt() {
      return Integer.parseInt(nextString());
    }

    long nextLong() {
      return Long.parseLong(nextString());
    }
  }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {

  public static void main(String[] args) throws Exception {
    FastInput fi = new FastInput(System.in);

    double t, d, k;
    k = fi.nextLong();
    d = fi.nextLong();
    t = fi.nextLong();

    t = 2*t;

    d = (k/d)*d;

    if(d<k)
      d+=d;

    double timePerCycle = 2 * k + (d - k);

    double cycles = t/timePerCycle;

    double time = cycles * d;

    double virtualTime = cycles * timePerCycle;

    double remaining = t - virtualTime;

    if(remaining <= 2*k)
      time += remaining/2;
    else {
      time += (remaining - 2*k)/2;
      remaining -= k;
      time += remaining;
    }

    System.out.println(time);
  }

  static class FastInput {

    BufferedReader reader;
    StringTokenizer st;

    public FastInput(InputStream inputStream) {
      reader = new BufferedReader(new InputStreamReader(inputStream), 32768);
    }

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

    int nextInt() {
      return Integer.parseInt(nextString());
    }

    long nextLong() {
      return Long.parseLong(nextString());
    }
  }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {

  public static void main(String[] args) throws Exception {
    FastInput fi = new FastInput(System.in);

    long t, d, k;
    k = fi.nextLong();
    d = fi.nextLong();
    t = fi.nextLong();

    t = 2*t;

    d = (k/d)*d;

    if(d<k)
      d+=d;

    long unitsPerCycle = 2 * k + (d - k);

    long cycles = t/unitsPerCycle;

    double time = cycles * d;

    long virtualTime = cycles * unitsPerCycle;

    double remaining = t - virtualTime;

    if(remaining <= 2*k)
      time += remaining/2;
    else {
      time += k;
      remaining -= 2*k;
      time += remaining;
    }

    System.out.println(time);

  }

  static class FastInput {

    BufferedReader reader;
    StringTokenizer st;

    public FastInput(InputStream inputStream) {
      reader = new BufferedReader(new InputStreamReader(inputStream), 32768);
    }

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

    int nextInt() {
      return Integer.parseInt(nextString());
    }

    long nextLong() {
      return Long.parseLong(nextString());
    }
  }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {

  public static void main(String[] args) throws Exception {
    FastInput fi = new FastInput(System.in);

    long t, d, k;
    k = fi.nextLong();
    d = fi.nextLong();
    t = fi.nextLong();

    t = 2*t;

    d = (k/d)*d;

    if(d<k)
      d+=d;

    long timePerCycle = 2 * k + (d - k);

    long cycles = t/timePerCycle;

    double time = cycles * d;

    long virtualTime = cycles * timePerCycle;

    double remaining = t - virtualTime;

    if(remaining <= 2*k)
      time += remaining/2;
    else {
      time += (remaining - k)/2;
      remaining -= k;
      time += remaining;
    }

    System.out.println(time);
  }

  static class FastInput {

    BufferedReader reader;
    StringTokenizer st;

    public FastInput(InputStream inputStream) {
      reader = new BufferedReader(new InputStreamReader(inputStream), 32768);
    }

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

    int nextInt() {
      return Integer.parseInt(nextString());
    }

    long nextLong() {
      return Long.parseLong(nextString());
    }
  }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {

  public static void main(String[] args) throws Exception {
    FastInput fi = new FastInput(System.in);

    double t, d, k;
    k = fi.nextLong();
    d = fi.nextLong();
    t = fi.nextLong();

    t = 2*t;

    d = (k/d)*d;

    if(d<k)
      d+=d;

    double timePerCycle = 2 * k + (d - k);

    double cycles = t/timePerCycle;

    double time = cycles * d;

    double virtualTime = cycles * timePerCycle;

    double remaining = t - virtualTime;

    if(remaining <= 2*k)
      time += remaining/2;
    else {
      time += (remaining - 2*k)/2;
      remaining -= 2*k;
      time += remaining;
    }

    System.out.println(time);
  }

  static class FastInput {

    BufferedReader reader;
    StringTokenizer st;

    public FastInput(InputStream inputStream) {
      reader = new BufferedReader(new InputStreamReader(inputStream), 32768);
    }

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

    int nextInt() {
      return Integer.parseInt(nextString());
    }

    long nextLong() {
      return Long.parseLong(nextString());
    }
  }

}


import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		long k=sc.nextLong();
		long d=sc.nextLong();
		BigDecimal t=sc.nextBigDecimal();
		//System.out.println("####");
		if (k%d==0)
			System.out.println(t);
		else {
			BigDecimal time=new BigDecimal(0);
			BigDecimal timerem=new BigDecimal(t.toPlainString());
			BigDecimal cooked=new BigDecimal(0);
			for (int i=0;i<2;i++) {
				//System.out.println("Timerem="+timerem);
				//System.out.println("Time="+time);
				if ((timerem.subtract(cooked)).compareTo(new BigDecimal(0) )==1) {
					BigDecimal tmp= new BigDecimal(((k/d)*d)+(k%d)+(double)(d-(k%d))/2);
					BigDecimal tmp2= new BigDecimal(((k/d)*d)+(k%d)+(double)(d-(k%d)));
					//System.out.println(tmp+" "+tmp2);
					timerem=timerem.subtract(tmp);
					time=time.add(tmp2);
				// System.out.println("Timerem="+timerem);
				//System.out.println("Time="+time);
				cooked=t.subtract(timerem);
				//System.out.println("cooked="+cooked);
				BigDecimal nb=new BigDecimal((double) Math.floor(t.divide(cooked,MathContext.DECIMAL128).doubleValue()));
				//System.out.println("nb="+nb);
				timerem=timerem.subtract(cooked.multiply(nb.subtract(new BigDecimal(1))));
				time=time.add(time.multiply(nb.subtract(new BigDecimal(1))));
				/* System.out.println("Timerem="+timerem);
				System.out.println("Time="+time); */
				}
				else {
					time=time.add(timerem);
					timerem=timerem=new BigDecimal(0);
				}

			}
			System.out.println(time);
			}
	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Washoum
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CSaveEnergy solver = new CSaveEnergy();
        solver.solve(1, in, out);
        out.close();
    }

    static class CSaveEnergy {
        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            long k = sc.nextLong();
            long d = sc.nextLong();
            long t = sc.nextLong();
            if (t <= k) {
                out.println(t);
                return;
            }
            long tmp = (k / d) + (k % d == 0 ? 0 : 1);
            long ferme = (tmp * d) - k;
            double cookedtime = t / (k + (ferme / 2d));
            double acttime = (tmp * d) * (long) cookedtime;
            double restant = t - (long) cookedtime * (k + (ferme / 2d));
            if (restant >= k) {
                acttime += k;
                restant -= k;
                if (restant > 0) {
                    acttime += restant * 2;
                }
            } else {
                acttime += restant;
            }

            out.println(acttime);
        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Washoum
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CSaveEnergy solver = new CSaveEnergy();
        solver.solve(1, in, out);
        out.close();
    }

    static class CSaveEnergy {
        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            int k = sc.nextInt();
            int d = sc.nextInt();
            int t = sc.nextInt();
            if (t <= k) {
                out.println(t);
                return;
            }
            int tmp = (k / d) + (k % d == 0 ? 0 : 1);
            int ferme = (tmp * d) - k;
            double cookedtime = t / (k + (ferme / 2d));
            double acttime = (tmp * d) * (int) cookedtime;
            double restant = t - (int) cookedtime * (k + (ferme / 2d));
            if (restant >= k) {
                acttime += k;
                restant -= k;
                if (restant > 0) {
                    acttime += restant * 2;
                }
            } else {
                acttime += restant;
                restant = 0;
            }

            out.println(acttime);
        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

    }
}


import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static ArrayList<Integer> tab=new ArrayList<>();

	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		long k=sc.nextLong();
		long d=sc.nextLong();
		long t=sc.nextLong();
		if (k%d==0)
			System.out.println(t);
		else {
			double time=0;
			double timerem=t;
			while (timerem>0) {
				if (timerem-k>0) {
				timerem-=(k/d)*d;
				time+=(k/d)*d;
				timerem-=k%d;
				time+=k%d;
				timerem-=((double)(d-(k%d)))/2;
				time+=((double)(d-(k%d)));

				}
				else {
					time+=timerem;
					timerem=0;
				}
				double cooked=t-timerem;
				long nb=(long) Math.floor(t/cooked);
				timerem-=timerem*(nb-1);
				time+=time*(nb-1);

			}
			System.out.println(time);
			}
	}
}


import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		long k=sc.nextLong();
		long d=sc.nextLong();
		BigDecimal t=sc.nextBigDecimal();
		//System.out.println("####");
		if (k%d==0)
			System.out.println(t);
		else {
			BigDecimal time=new BigDecimal(0);
			BigDecimal timerem=new BigDecimal(t.toPlainString());
			BigDecimal cooked=new BigDecimal(0);
			for (int i=0;i<2;i++) {
				//System.out.println("Timerem="+timerem);
				//System.out.println("Time="+time);
				if ((timerem.subtract(cooked)).compareTo(new BigDecimal(0) )==1) {
					BigDecimal tmp= new BigDecimal(((k/d)*d)+(k%d)+(double)(d-(k%d))/2);
					BigDecimal tmp2= new BigDecimal(((k/d)*d)+(k%d)+(double)(d-(k%d)));
					//System.out.println(tmp+" "+tmp2);
					timerem=timerem.subtract(tmp);
					time=time.add(tmp2);
				 //System.out.println("Timerem="+timerem);
				//System.out.println("Time="+time);
				cooked=t.subtract(timerem);
				//System.out.println("cooked="+cooked);
				BigDecimal nb=new BigDecimal((double) Math.floor(t.divide(cooked,MathContext.DECIMAL128).doubleValue()));
				//System.out.println("nb="+nb);
				timerem=timerem.subtract(cooked.multiply(nb.subtract(new BigDecimal(1))));
				time=time.add(time.multiply(nb.subtract(new BigDecimal(1))));
				/* System.out.println("Timerem="+timerem);
				System.out.println("Time="+time); */
				}
				else {
					if (timerem.compareTo(new BigDecimal(k))==1) {
						time=time.add(new BigDecimal(k));
						timerem=timerem.subtract(new BigDecimal(k));
						time=time.add(timerem.multiply(new BigDecimal(2) ));
						}
					else
						time=time.add(timerem);
				}

			}
			System.out.println(time);
			}
	}
}


import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static ArrayList<Integer> tab=new ArrayList<>();

	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		long k=sc.nextInt();
		long d=sc.nextInt();
		long t=sc.nextInt();
		if (k%d==0)
			System.out.println(t);
		else {
			double time=0;
			double timerem=t;
			while (timerem>0) {
				if (timerem-k>0) {
				timerem-=(k/d)*d;
				time+=(k/d)*d;
				timerem-=k%d;
				time+=k%d;
				timerem-=((double)(d-(k%d)))/2;
				time+=((double)(d-(k%d)));

				}
				else {
					time+=timerem;
					timerem=0;
				}
			}
			System.out.println(time);
			}
	}
}


import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		long k=sc.nextLong();
		long d=sc.nextLong();
		long t=sc.nextLong();
		if (k%d==0)
			System.out.println(t);
		else {
			double time=0;
			double timerem=t;
			while (timerem>0) {
				if (timerem-k>0) {
				timerem-=(k/d)*d;
				time+=(k/d)*d;
				timerem-=k%d;
				time+=k%d;
				timerem-=((double)(d-(k%d)))/2;
				time+=((double)(d-(k%d)));
				/* System.out.println("Timerem="+timerem);
				System.out.println("Time="+time); */
				double cooked=t-timerem;
				long nb=(long) Math.floor(t/cooked);
				// System.out.println(nb);
				timerem-=cooked*(nb-1);
				time+=time*(nb-1);
				/*System.out.println("Timerem="+timerem);
				System.out.println("Time="+time); */
				}
				else {
					time+=timerem;
					timerem=0;
				}

			}
			System.out.println(time);
			}
	}
}


import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		long k=sc.nextLong();
		long d=sc.nextLong();
		long t=sc.nextLong();
		//System.out.println("####");
		if (k%d==0)
			System.out.println(t);
		else {
			double time=0;
			double timerem=t;
			double cooked=0;
			//while (timerem>0) {
			for (int i=0;i<2;i++) {
				if (timerem-cooked>0) {
				timerem-=(k/d)*d;
				time+=(k/d)*d;
				timerem-=k%d;
				time+=k%d;
				timerem-=((double)(d-(k%d)))/2;
				time+=((double)(d-(k%d)));
				/* System.out.println("Timerem="+timerem);
				System.out.println("Time="+time); */
				cooked=t-timerem;
				long nb=(long) Math.floor(t/cooked);
				//System.out.println("nb="+nb);
				timerem-=cooked*(nb-1);
				time+=time*(nb-1);
				/* System.out.println("Timerem="+timerem);
				System.out.println("Time="+time); */
				}
				else {
					time+=timerem;
					timerem=0;
				}

			}
			//}
			System.out.println(new BigDecimal(time));
			}
	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Washoum
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CSaveEnergy solver = new CSaveEnergy();
        solver.solve(1, in, out);
        out.close();
    }

    static class CSaveEnergy {
        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            long k = sc.nextLong();
            long d = sc.nextLong();
            long t = sc.nextLong();
            if (t <= k) {
                out.println(t);
                return;
            }
            long tmp = (k / d) + (k % d == 0 ? 0 : 1);
            long ferme = (tmp * d) - k;
            double cookedtime = t / (k + (ferme / 2d));
            double acttime = (tmp * d) * (int) cookedtime;
            double restant = t - (int) cookedtime * (k + (ferme / 2d));
            if (restant >= k) {
                acttime += k;
                restant -= k;
                if (restant > 0) {
                    acttime += restant * 2;
                }
            } else {
                acttime += restant;
            }

            out.println(acttime);
        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}


import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		long k=sc.nextLong();
		long d=sc.nextLong();
		long t=sc.nextLong();
		if (k%d==0)
			System.out.println(t);
		else {
			double time=0;
			double timerem=t;
			while (timerem>0) {
				if (timerem-k>0) {
				timerem-=(k/d)*d;
				time+=(k/d)*d;
				timerem-=k%d;
				time+=k%d;
				timerem-=((double)(d-(k%d)))/2;
				time+=((double)(d-(k%d)));

				}
				else {
					time+=timerem;
					timerem=0;
				}
				double cooked=t-timerem;
				System.out.println(t/cooked);
				long nb=(long) Math.floor(t/cooked);
				timerem-=timerem*(nb-1);
				time+=time*(nb-1);

			}
			System.out.println(time);
			}
	}
}


import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static ArrayList<Integer> tab=new ArrayList<>();

	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int k=sc.nextInt();
		int d=sc.nextInt();
		int t=sc.nextInt();
		if (k%d==0)
			System.out.println(t);
		else {
			double time=0;
			double timerem=t;
			while (timerem>0) {
				if (timerem-k>0) {
				timerem-=(k/d)*d;
				time+=(k/d)*d;
				timerem-=k%d;
				time+=k%d;
				timerem-=((double)(d-(k%d)))/2;
				time+=((double)(d-(k%d)));

				}
				else {
					time+=timerem;
					timerem=0;
				}
			}
			System.out.println(time);
			}
	}
}


import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static ArrayList<Integer> tab=new ArrayList<>();

	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		long k=sc.nextLong();
		long d=sc.nextLong();
		long t=sc.nextLong();
		if (k%d==0)
			System.out.println(t);
		else {
			double time=0;
			double timerem=t;
			while (timerem>0) {
				if (timerem-k>0) {
				timerem-=(k/d)*d;
				time+=(k/d)*d;
				timerem-=k%d;
				time+=k%d;
				timerem-=((double)(d-(k%d)))/2;
				time+=((double)(d-(k%d)));

				}
				else {
					time+=timerem;
					timerem=0;
				}
			}
			System.out.println(time);
			}
	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Washoum
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CSaveEnergy solver = new CSaveEnergy();
        solver.solve(1, in, out);
        out.close();
    }

    static class CSaveEnergy {
        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            int k = sc.nextInt();
            int d = sc.nextInt();
            int t = sc.nextInt();
            if (t <= k) {
                out.println(t);
                return;
            }
            int tmp = (k / d) + (k % d == 0 ? 0 : 1);
            int ferme = (tmp * d) - k;
            double acttime = (t / (tmp * d)) * (tmp * d);
            double cookedtime = (t / (tmp * d)) * (k + (ferme / 2d));
            double restant = t - cookedtime;
            if (restant >= k) {
                cookedtime += k;
                acttime += k;
                restant -= k;
            } else {
                cookedtime += restant;
                acttime += restant;
                restant = 0;
            }
            if (restant > 0) {
                cookedtime += restant * 2;
                acttime += restant * 2;
            }
            out.println(acttime);
        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

    }
}