A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning to the point x = 0 it immediately goes back to the point x = a and so on. Thus, the bus moves from x = 0 to x = a and back. Moving from the point x = 0 to x = a or from the point x = a to x = 0 is called a bus journey. In total, the bus must make k journeys.

The petrol tank of the bus can hold b liters of gasoline. To pass a single unit of distance the bus needs to spend exactly one liter of gasoline. The bus starts its first journey with a full petrol tank.

There is a gas station in point x = f. This point is between points x = 0 and x = a. There are no other gas stations on the bus route. While passing by a gas station in either direction the bus can stop and completely refuel its tank. Thus, after stopping to refuel the tank will contain b liters of gasoline.

What is the minimum number of times the bus needs to refuel at the point x = f to make k journeys? The first journey starts in the point x = 0.


-----Input-----

The first line contains four integers a, b, f, k (0 < f < a ≤ 10^6, 1 ≤ b ≤ 10^9, 1 ≤ k ≤ 10^4) — the endpoint of the first bus journey, the capacity of the fuel tank of the bus, the point where the gas station is located, and the required number of journeys.


-----Output-----

Print the minimum number of times the bus needs to refuel to make k journeys. If it is impossible for the bus to make k journeys, print -1.


-----Examples-----
Input
6 9 2 4

Output
4

Input
6 10 2 4

Output
2

Input
6 5 4 3

Output
-1



-----Note-----

In the first example the bus needs to refuel during each journey.

In the second example the bus can pass 10 units of distance without refueling. So the bus makes the whole first journey, passes 4 units of the distance of the second journey and arrives at the point with the gas station. Then it can refuel its tank, finish the second journey and pass 2 units of distance from the third journey. In this case, it will again arrive at the point with the gas station. Further, he can refill the tank up to 10 liters to finish the third journey and ride all the way of the fourth journey. At the end of the journey the tank will be empty. 

In the third example the bus can not make all 3 journeys because if it refuels during the second journey, the tanks will contain only 5 liters of gasoline, but the bus needs to pass 8 units of distance until next refueling.

Source: codeforces | Difficulty: MEDIUM
Tags: Mathematics

Implementation

Greedy algorithms


Solutions:
(a, b, f, k) = map(int, input().split())
fuel_count = 0
fuel = b
i = 0
fuel -= f
if fuel < 0:
	print(-1)
	exit(0)
while True:
	if fuel >= a - f and i + 1 == k:
		break
	if b >= a - f and i + 1 == k:
		fuel_count += 1
		break
	elif fuel < 2 * (a - f):
		fuel = b
		fuel_count += 1
		if fuel < 2 * (a - f):
			print(-1)
			exit(0)
	fuel -= 2 * (a - f)
	i += 1
	if i == k:
		break
	if fuel >= f and i + 1 == k:
		break
	if b >= f and i + 1 == k:
		fuel_count += 1
		break
	elif fuel < 2 * f:
		fuel = b
		fuel_count += 1
		if fuel < 2 * f:
			print(-1)
			exit(0)
	fuel -= 2 * f
	i += 1
	if i == k:
		break
print(fuel_count)


def main():
	(A, B, F, K) = map(int, input().split())
	gas = B
	refuel = 0
	i = 1
	while i <= K:
		if i % 2:
			gas -= F
			if gas >= 0:
				if K - i > 0 and gas < (A - F) * 2 or (K - i == 0 and gas < A - F):
					gas = B
					refuel += 1
				gas -= A - F
		else:
			gas -= A - F
			if gas >= 0:
				if K - i > 0 and gas < F * 2 or (K - i == 0 and gas < F):
					gas = B
					refuel += 1
				gas -= F
		if gas < 0:
			print(-1)
			return
		i += 1
	print(refuel)
main()


from sys import stdin, stdout
(a, b, f, k) = list(map(int, stdin.readline().rstrip().split()))
direction = 1
tank = b
refuels = 0
position = 0
if b < f or b < a - f:
	possible = False
else:
	possible = True
while k > 0 and possible == True:
	if k == 1 and tank >= a:
		k = 0
	elif k == 1:
		k = 0
		refuels += 1
	elif position == 0:
		position = f
		tank -= f
		direction = 1
	elif position == a:
		position = f
		tank -= a - f
		direction = -1
	elif direction == 1:
		if tank < 2 * (a - f):
			tank = b
			refuels += 1
			if b < 2 * (a - f):
				possible = False
		else:
			position = a
			direction = -1
			tank -= a - f
			k -= 1
	elif direction == -1:
		if tank < 2 * f:
			refuels += 1
			tank = b
			if b < 2 * f:
				possible = False
		else:
			position = 0
			direction = 1
			tank -= f
			k -= 1
if not possible:
	print(-1)
else:
	print(refuels)


import sys
(l, tank, v, rep) = (int(x) for x in input().split())
checkpoints = [l * i + (v if i % 2 == 0 else l - v) for i in range(rep)]
checkpoints.append(rep * l)
x = 0
gas = tank
cnt = 0
for y in checkpoints:
	if y - x > gas:
		if y - x > tank:
			print(-1)
			sys.exit()
		cnt += 1
		gas = tank
	gas -= y - x
	x = y
print(cnt)


def predict(x, p):
	if x == 1:
		if p - a - f >= 0:
			return 'Go'
		return 'Fuel'
	elif p - (a + a - f) >= 0:
		return 'Go'
	else:
		return 'Fuel'
(a, b, f, k) = map(int, input().split())
t = 0
r = 0
www = b
for i in range(k):
	if i == k - 1:
		if b >= a:
			continue
	if i % 2 == 0:
		d = predict(i % 2, b)
		if d == 'Go':
			b -= a
		elif b >= f and a - b <= a - f and (b >= 0):
			b = www
			b -= a - f
			if b < 0:
				r = 1
				break
			t += 1
		else:
			r = 1
			break
	else:
		d = predict(i % 2, b)
		if d == 'Go':
			b -= a
		elif b >= a - f:
			b = www
			b -= f
			if b < 0:
				r = 1
				break
			t += 1
		else:
			r = 1
			break
if r == 1:
	print('-1')
else:
	print(t)


from collections import defaultdict, deque, Counter
from sys import stdin, stdout
from heapq import heappush, heappop
import math
import io
import os
import math
import bisect

def isPrime(x):
	for i in range(2, x):
		if i * i > x:
			break
		if x % i == 0:
			return False
	return True

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	return list(set(l))

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def digits(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def ceil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def mapin():
	return map(int, input().split())
(a, b, f, k) = mapin()
ans = 0
if b < f:
	print(-1)
	exit()
re = b
for i in range(k):
	if i & 1:
		pet = a - f
		jor = a + f
		if i + 1 > k - 1:
			jor = a
		if pet > re:
			print(-1)
			exit()
		if jor > re:
			re = b - f
			ans += 1
		else:
			re = re - a
		if re < 0:
			print(-1)
			exit()
	else:
		pet = f
		jor = a + a - f
		if i + 1 > k - 1:
			jor = a
		if pet > re:
			print(-1)
			exit()
		if jor > re:
			re = b - (a - f)
			ans += 1
		else:
			re = re - a
		if re < 0:
			print(-1)
			exit()
print(ans)


(a, b, f, k) = map(int, input().split())
from sys import exit
(item, res) = (b, 0)
if item < f:
	print(-1)
	exit()
item -= f
(x, y) = (f * 2, (a - f) * 2)
for i in range(1, k):
	if i % 2 == 1:
		if item < y:
			res += 1
			item = b - y
		else:
			item -= y
		if item < 0:
			print(-1)
			exit()
	else:
		if item < x:
			res += 1
			item = b - x
		else:
			item -= x
		if item < 0:
			print(-1)
			exit()
if k % 2 == 1:
	if item < a - f:
		res += 1
		item = b - (a - f)
	else:
		item -= a - f
	if item < 0:
		print(-1)
		exit()
else:
	if item < f:
		res += 1
		item = b - f
	else:
		item -= f
	if item < 0:
		print(-1)
		exit()
print(res)


def bus():
	[a, b, f, k] = map(int, input().split())
	if b < f:
		return -1
	(trips, fuel, pos, refill) = (0, b - f, f, 0)
	while trips < k:
		rounds = 2 * (fuel // (2 * a))
		fuel -= rounds * a
		if pos == f and fuel % (2 * a) >= 2 * (a - f):
			rounds += 1
			pos = a + f
			fuel -= 2 * (a - f)
		elif pos == a + f and fuel % (2 * a) >= 2 * f:
			rounds += 1
			pos = f
			fuel -= 2 * f
		trips += rounds
		if trips == k - 1:
			if pos == f and fuel >= a - f or (pos == a + f and fuel >= f):
				return refill
		elif trips >= k:
			return refill
		if rounds == 0:
			if fuel < b:
				(fuel, refill) = (b, refill + 1)
			else:
				return -1
		else:
			(fuel, refill) = (b, refill + 1)
	return refill
print(bus())


(a, b, f, k) = map(int, input().split())
fuel = b - f
(c, d) = (0, [a - f << 1, f << 1])
flag = 1
for i in range(k):
	if fuel < 0:
		flag = 0
		break
	dis = d[i & 1] * (1 if i != k - 1 else 0.5)
	if fuel < dis:
		fuel = b
		c += 1
	fuel -= dis
if fuel < 0:
	flag = 0
print(c if flag else '-1')


(a, b, f, k) = map(int, input().split())
x = 0
rf = 0
fuel = b
di = 0
j = 0
if fuel < f:
	print(-1)
	exit()
x = f
fuel -= f
while j != k:
	if di == 0:
		if j == k - 1:
			if fuel >= a - f:
				print(rf)
				exit()
		if fuel >= 2 * (a - f):
			fuel = fuel - 2 * (a - f)
			di = 1
		else:
			rf = rf + 1
			if b >= a - f and j == k - 1:
				print(rf)
				exit()
			fuel = b - 2 * (a - f)
			if fuel < 0:
				print(-1)
				exit()
			di = 1
		j += 1
	elif di == 1:
		if j == k - 1:
			if fuel >= f:
				print(rf)
				exit()
		if fuel >= 2 * f:
			x = f
			di = 0
			fuel -= 2 * f
		else:
			rf = rf + 1
			if b >= f and j == k - 1:
				print(rf)
				exit()
			fuel = b - 2 * f
			if fuel < 0:
				print(-1)
				exit()
			x = f
			di = 0
		j += 1
print(rf)


[a, b, f, k] = list(map(int, input().split()))

def fail():
	print('-1')
	exit(0)

def success(x):
	print(x)
	exit(0)
res = 0
r = b - f
while k > 0:
	if r < 0:
		fail()
	if k == 1:
		if r < a - f:
			res += 1
			r = b
		if r < a - f:
			fail()
		success(res)
	else:
		if r < (a - f) * 2:
			res += 1
			r = b
		r -= (a - f) * 2
		if r < 0:
			fail()
		k -= 1
	if k == 1:
		if r < f:
			res += 1
			r = b
		if r < f:
			fail()
		success(res)
	else:
		if r < f * 2:
			res += 1
			r = b
		r -= f * 2
		if r < 0:
			fail()
		k -= 1


(a, b, f, k) = map(int, input().split())
start = True
tank = b
refuels = 0
possible = True
while k > 0 and possible:
	if k == 1:
		if tank >= a:
			k -= 1
			continue
		if start:
			if tank >= f and b >= a - f:
				refuels += 1
			else:
				possible = False
		elif tank >= a - f and b >= f:
			refuels += 1
		else:
			possible = False
	else:
		if start:
			if tank < f:
				possible = False
			elif tank >= a + (a - f):
				tank -= a
			else:
				tank = b - (a - f)
				refuels += 1
		elif tank < a - f:
			possible = False
		elif tank >= a + f:
			tank -= a
		else:
			tank = b - f
			refuels += 1
		start = not start
	k -= 1
if not possible:
	print(-1)
else:
	print(refuels)


value = input().split()
(finish, tank, azs, count) = (int(value[0]), int(value[1]), int(value[2]), int(value[3]))
before_azs = ((finish - azs) * 2 if count > 1 else finish - azs, finish * 2 - (finish - azs) * 2)
tank_now = tank - azs
if tank_now < 0:
	print(-1)
	exit()
lent = finish * count - azs
(values, binar) = (0, 0)
while lent > 0:
	if tank_now - before_azs[binar] >= 0 or tank_now - lent >= 0:
		tank_now -= before_azs[binar]
		lent -= before_azs[binar]
		if lent <= 0:
			break
		if binar == 1:
			binar = 0
		else:
			binar = 1
	if tank_now - before_azs[binar] < 0 and (not tank_now - lent >= 0):
		values += 1
		tank_now = tank
		if before_azs[binar] > tank_now and (not tank_now - lent >= 0):
			print(-1)
			exit()
print(values)


(a, b, f, k) = map(int, input().split())
reFills = 0
journeys = 0
fuel = b - f

def nextStop():
	if journeys % 2 == 0:
		if journeys == k - 1:
			return a - f
		return (a - f) * 2
	else:
		if journeys == k - 1:
			return f
		return f * 2
if fuel < 0:
	print(-1)
else:
	while journeys < k:
		next_stop = nextStop()
		if fuel < next_stop:
			reFills += 1
			fuel = b
		fuel -= next_stop
		if fuel < 0:
			reFills = -1
			break
		journeys += 1
	print(reFills)


(a, b, f, k) = [int(i) for i in input().split()]
ff = [0]
for i in range(k):
	d = f
	if i % 2 == 1:
		d = a - f
	ff.append(i * a + d)
ff.append(k * a)
stops = 0
while len(ff) > 0:
	next = 0
	if ff[0] == k * a:
		break
	while ff[next + 1] - ff[0] <= b:
		next += 1
		if ff[next] == k * a:
			break
	if next == 0:
		print('-1')
		return
	if ff[next] != k * a:
		stops += 1
		while next > 0:
			ff.pop(0)
			next -= 1
	else:
		break
print(stops)


(a, b, f, k) = list(map(int, input().split()))
now = b
path = 0
ans = 0
for i in range(k):
	if path == 0:
		if i == k - 1 and now >= a:
			break
		now -= f
		if now < 0:
			print(-1)
			return
		if 2 * (a - f) <= now:
			now -= a - f
		else:
			ans += 1
			now = b - (a - f)
		path = 1
	elif path == 1:
		if i == k - 1 and now >= a:
			break
		now -= a - f
		if now < 0:
			print(-1)
			return
		if 2 * f <= now:
			now -= f
		else:
			ans += 1
			now = b - f
		path = 0
if now < 0:
	print(-1)
	return
print(ans)


l = list(map(int, input().split()))
(a, fuel, f, k) = (l[0], l[1], l[2], l[3])
i = 1
b = fuel
c = 0
flag = 0
while i < k:
	if i % 2 != 0:
		if b >= 2 * a - f:
			b -= a
		elif b >= f:
			b = fuel - (a - f)
			c += 1
		else:
			print('-1')
			flag = 1
			break
	elif b >= a + f:
		b -= a
	elif b >= a - f:
		b = fuel - f
		c += 1
	else:
		print('-1')
		flag = 1
		break
	i += 1
if flag == 0:
	if k % 2 == 0:
		if b >= a:
			b -= a
		elif b >= a - f and fuel >= f:
			c += 1
		else:
			flag = 1
			print('-1')
	elif b >= a:
		b -= a
	elif b >= f and fuel >= a - f:
		c += 1
	else:
		flag = 1
		print('-1')
if flag == 0:
	print(c)


(a, b, f, k) = map(int, input().split())
s = a - f
tch = f
counter = 0
c = 0
full = b
flag = True
while flag:
	for i in range(k):
		b -= tch
		if b < 0:
			c = -1
		if b < 2 * s and i != k - 1:
			counter += 1
			b = full
		elif i == k - 1:
			if b < s:
				counter += 1
				b = full
		b -= s
		if b < 0:
			c = -1
			flag = False
		(tch, s) = (s, tch)
	flag = False
if c != -1:
	print(counter)
else:
	print(-1)


def can_make_route():
	can_return_to_station = bus['gasoline'] - (abs(bus['position'] - bus['direction']) + abs(bus['direction'] - station)) >= 0
	is_last_route = bus['qty_routs'] + 1 == cnt_routes and bus['gasoline'] - abs(bus['position'] - bus['direction']) >= 0
	return can_return_to_station or is_last_route

def make_route():
	bus['gasoline'] = bus['gasoline'] - abs(bus['position'] - bus['direction'])
	bus['position'] = bus['direction']
	bus['direction'] = start if bus['direction'] == end else end
	bus['qty_routs'] += 1

def goto_station():
	bus['gasoline'] = max_gasoline
	bus['position'] = station

def is_input_correct():
	return max_gasoline - station >= 0
(end, max_gasoline, station, cnt_routes) = map(int, input().split())
(start, res) = (0, 0)
bus = {'position': start, 'gasoline': max_gasoline, 'direction': end, 'qty_routs': 0}
if is_input_correct():
	while bus['qty_routs'] != cnt_routes:
		if can_make_route():
			make_route()
		elif bus['position'] == station:
			res = -1
			break
		else:
			goto_station()
			res += 1
else:
	res = -1
print(res)


(a, b, f, k) = list(map(int, input().split()))
refill = b
busPos = 0
counter = 0
shouldPrint = True
while True:
	busPos += f
	b -= f
	if b < 0:
		print(-1)
		shouldPrint = False
		break
	if (2 if k > 1 else 1) * (a - f) > b:
		b = refill
		counter += 1
	busPos += a - f
	b -= a - f
	if b < 0:
		print(-1)
		shouldPrint = False
		break
	k -= 1
	if k == 0:
		break
	busPos -= a - f
	b -= a - f
	if b < 0:
		print(-1)
		shouldPrint = False
		break
	if (2 if k > 1 else 1) * f > b:
		b = refill
		counter += 1
	busPos -= f
	b -= f
	if b < 0:
		print(-1)
		shouldPrint = False
		break
	k -= 1
	if k == 0:
		break
if shouldPrint:
	print(counter)


(a, b, f, k) = map(int, input().split())
if (f > b or a - f > b) or (k > 1 and 2 * (a - f) > b) or (k > 2 and 2 * f > b):
	print(-1)
	exit()
cur = b
ans = 0
for i in range(k):
	if i & 1 == 0:
		if cur < f:
			cur = b - f
			ans += 1
		if cur >= a:
			cur -= a
		else:
			ans += 1
			cur = b - a + f
	else:
		if cur < a - f:
			cur = b - a + f
			ans += 1
		if cur >= a:
			cur -= a
		else:
			ans += 1
			cur = b - f
print(ans)


def list_input():
	return list(map(int, input().split()))

def map_input():
	return map(int, input().split())

def map_string():
	return input().split()
(a, b, f, k) = map_input()
tot = a * k
s = 2 * a - f
cur = 0
cnt = b
go = 0
ans = 0
while cur < tot:
	go = 1 - go
	if go == 1:
		if cnt < s and cnt < tot - cur:
			if cnt < f:
				print(-1)
				break
			cnt = b
			ans += 1
			cnt -= a - f
		else:
			cnt -= a
	elif cnt < a + f and cnt < tot - cur:
		if cnt < a - f:
			print(-1)
			break
		cnt = b
		ans += 1
		cnt -= f
	else:
		cnt -= a
	cur += a
	if cnt < 0:
		print(-1)
		break
else:
	print(ans)


import sys
(a, b, f, k) = map(int, input().split())

def game_over():
	print(-1)
	sys.exit()
fuel = b
add_fuel_count = 0
distance_to_stop = f
fuel_on_next_stop = fuel - distance_to_stop
if fuel_on_next_stop < 0:
	game_over()
for i in range(1, k + 1):
	fuel = fuel_on_next_stop
	if i == k:
		if i % 2:
			distance_to_stop = a - f
		else:
			distance_to_stop = f
	elif i % 2:
		distance_to_stop = 2 * (a - f)
	else:
		distance_to_stop = 2 * f
	if fuel < distance_to_stop:
		(fuel, add_fuel_count) = (b, add_fuel_count + 1)
	fuel_on_next_stop = fuel - distance_to_stop
	if fuel_on_next_stop < 0:
		game_over()
print(add_fuel_count)


def read_input():
	input_str = str(input())
	return map(int, input_str.split(' '))

def check(a: int, b: int, f: int, k: int) -> int:
	if k == 1 and (a - f > b or f > b):
		return -1
	elif k == 2 and ((a - f) * 2 > b or f > b):
		return -1
	elif k > 2 and ((a - f) * 2 > b or f * 2 > b):
		return -1
	counter = 0
	actual_b = b - f
	for i in range(k - 1):
		if i % 2 == 0:
			if actual_b < (a - f) * 2:
				counter += 1
				actual_b = b
			actual_b -= (a - f) * 2
		else:
			if actual_b < f * 2:
				counter += 1
				actual_b = b
			actual_b -= f * 2
	if k % 2 == 1:
		if actual_b < a - f:
			counter += 1
			actual_b = b
	elif actual_b < f:
		counter += 1
		actual_b = b
	return counter
(a, b, f, k) = read_input()
result = check(a, b, f, k)
print(result)


import sys
(a, b, f, k) = list(map(int, input().split()))
d1 = f
d2 = a - f
if k == 1:
	if d1 > b or d2 > b:
		print('-1')
		sys.exit()
elif k == 2:
	if d1 > b or 2 * d2 > b:
		print('-1')
		sys.exit()
elif 2 * d1 > b or 2 * d2 > b:
	print('-1')
	sys.exit()
rem = b
fill = 0
for i in range(k):
	round = i + 1
	if round % 2 != 0:
		rem -= d1
		if round == k and rem >= d2:
			rem -= d2
		elif round != k and rem >= 2 * d2:
			rem -= d2
		else:
			fill += 1
			rem = b
			rem -= d2
	else:
		rem -= d2
		if round == k and rem >= d1:
			rem -= d1
		elif round != k and rem >= 2 * d1:
			rem -= d1
		else:
			fill += 1
			rem = b
			rem -= d1
print(fill)


(a, b, f, k) = [int(x) for x in input().split()]
curpos = 0
possible = True
gas = b
refuelCount = 0

def dis(a, b):
	return abs(a - b)
while k > 0:
	if dis(curpos, f) > gas:
		possible = False
		break
	dis_to_edge = dis(f, 0) if curpos == a else dis(f, a)
	if k > 1 and dis(curpos, f) + dis_to_edge * 2 > gas:
		gas -= dis(curpos, f)
		if gas < 0:
			possible = False
			break
		gas = b
		refuelCount += 1
		gas -= dis_to_edge
		if gas < 0:
			possible = False
			break
		curpos = a - curpos
	elif k > 1:
		curpos = a - curpos
		gas -= a
		if gas < 0:
			possible = False
			break
	elif gas >= a:
		curpos = a - curpos
		gas -= a
	elif dis(curpos, f) <= gas:
		refuelCount += 1
		curpos = a - curpos
		gas = b
		gas -= dis(curpos, f)
		if gas < 0:
			possible = False
			break
	else:
		possible = False
		break
	if curpos == 0 or curpos == a:
		k -= 1
if possible:
	print(refuelCount)
else:
	print(-1)


(a, b, f, k) = map(int, input().split())
(x, y) = (f, a - f)
if k == 1:
	if b < max(x, y):
		print(-1)
		quit()
elif k == 2:
	if b < max(x, 2 * y):
		print(-1)
		quit()
elif b < max(2 * x, 2 * y):
	print(-1)
	quit()
gas = b
refill = 0
test = True
while k > 0:
	if test:
		if gas >= x + 2 * y:
			gas -= a
		elif gas >= x:
			if k == 1:
				if gas >= a:
					break
			gas = b - y
			refill += 1
		else:
			print(-1)
			quit()
		test = not test
	else:
		if gas >= 2 * x + y:
			gas -= a
		elif gas >= y:
			if k == 1:
				if gas >= a:
					break
			gas = b - x
			refill += 1
		else:
			print(-1)
			quit()
		test = not test
	k -= 1
print(refill)


import os
import sys
from io import BytesIO, IOBase

def main():
	(a, b, f, k) = map(int, input().split(' '))
	low = 0
	high = int(1e+18)
	mid = 0

	def pos(midd):
		fuel = b
		tot = 0
		if fuel < f:
			return False
		else:
			fuel -= f
		while tot < k:
			if tot == k - 1:
				if fuel >= a - f:
					return True
				elif midd >= 1:
					if b >= a - f:
						return True
					else:
						return False
			if 2 * (a - f) <= fuel:
				fuel -= 2 * (a - f)
			elif midd >= 1:
				midd -= 1
				fuel = b
				if 2 * (a - f) <= fuel:
					fuel -= 2 * (a - f)
				else:
					return False
			else:
				return False
			tot += 1
			if tot == k:
				return True
			if tot == k - 1:
				if fuel >= f:
					return True
				elif midd >= 1:
					return True
			if 2 * f <= fuel:
				fuel -= 2 * f
			elif midd >= 1:
				midd -= 1
				fuel = b
				if 2 * f <= fuel:
					fuel -= 2 * f
				else:
					return False
			else:
				return False
			tot += 1
		return True
	while low <= high:
		mid = (low + high) // 2
		if pos(mid) == True and pos(mid - 1) == False:
			break
		elif pos(mid):
			high = mid - 1
		else:
			low = mid + 1
	print(mid if pos(mid) else -1)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def solve():
	(a, b, f, k) = [int(st) for st in input().split(' ')]
	fuel = b
	location = 0
	direction = 'right'
	fueled = 0
	journeypassed = 0
	while journeypassed < k:
		if location == 0:
			if fuel < f:
				return -1
			fuel -= f
			location = f
			direction = 'right'
		elif location == a:
			if fuel < a - f:
				return -1
			fuel -= a - f
			location = f
			direction = 'left'
		elif location == f:
			if k - journeypassed <= 1:
				if direction == 'left':
					if fuel < f:
						fuel = b
						fueled += 1
					if fuel < f:
						return -1
					fuel -= f
					location = 0
					direction = 'right'
				else:
					if fuel < a - f:
						fuel = b
						fueled += 1
					if fuel < a - f:
						return -1
					fuel -= a - f
					location = a
					direction = 'left'
			elif direction == 'left':
				if fuel < 2 * f:
					fuel = b
					fueled += 1
				if fuel < 2 * f:
					return -1
				fuel -= 2 * f
				direction = 'right'
			else:
				if fuel < 2 * (a - f):
					fuel = b
					fueled += 1
				if fuel < 2 * (a - f):
					return -1
				fuel -= 2 * (a - f)
				direction = 'left'
			journeypassed += 1
	return fueled
print(solve())


(a, b, f, k) = map(int, input().split())
counter = 0
b2 = b - f
if b2 >= 0:
	dist2 = (a - f) * 2
	for i in range(k):
		if i == k - 1:
			dist2 /= 2
		if b2 < dist2:
			b2 = b
			counter += 1
		b2 -= dist2
		if b2 < 0:
			counter = -1
			break
		dist2 = 2 * a - dist2
	print(counter)
else:
	print(-1)


(a, b, f, k) = [int(z) for z in input().split()]
to_fuel = f
from_fuel = a - f
alrdy_fueled = 0
petrol = b
for i in range(k):
	petrol -= to_fuel
	if petrol < 0:
		print(-1)
		exit(0)
	if petrol < 2 * from_fuel and i != k - 1:
		petrol = b
		alrdy_fueled += 1
	elif i == k - 1:
		if petrol < from_fuel:
			petrol = b
			alrdy_fueled += 1
	petrol -= from_fuel
	if petrol < 0:
		print(-1)
		exit(0)
	(to_fuel, from_fuel) = (from_fuel, to_fuel)
print(alrdy_fueled)


(a, b, f, k) = [int(i) for i in input().split(' ')]
x = f
y = a - f
oil = b
result = 0
alert = 0
if k == 1:
	oil -= x
	if oil < 0:
		alert = 1
	if oil < y:
		result += 1
		oil = b
	oil -= y
	if oil < 0:
		alert = 1
else:
	oil -= x
	if oil < 0:
		alert = 1
	if oil < 2 * y:
		result += 1
		oil = b
	if k == 2:
		oil -= 2 * y
		if oil < 0:
			alert = 1
		if oil < x:
			result += 1
			oil = b
	else:
		oil -= 2 * y
		if oil < 0:
			alert = 1
		if oil < 2 * x:
			result += 1
			oil = b
if k > 2:
	k -= 2
	for ii in range(int((k - 1) / 2)):
		oil -= 2 * x
		if oil < 0:
			alert = 1
		if oil < 2 * y:
			oil = b
			result += 1
		k -= 1
		oil -= 2 * y
		if oil < 0:
			alert = 1
		if oil < 2 * x:
			oil = b
			result += 1
		k -= 1
	if k == 1:
		oil -= 2 * x
		if oil < 0:
			alert = 1
		if oil < y:
			oil = b
			result += 1
	if k == 2:
		oil -= 2 * x
		if oil < 0:
			alert = 1
		if oil < 2 * y:
			oil = b
			result += 1
		oil -= 2 * y
		if oil < x:
			oil = b
			result += 1
if alert == 1:
	print(-1)
else:
	print(result)


def main():
	(a, b, f, k) = list(map(int, input().split()))
	fuels = 0
	trips = 0
	pos = 0
	move = 1
	gas = b
	while trips < k:
		if gas < 0:
			print(-1)
			return
		if move == 1:
			if pos == 0:
				pos = f
				gas -= f
			elif pos == f:
				needed_gas = a - f if trips == k - 1 else 2 * (a - f)
				if gas < needed_gas:
					gas = b
					fuels += 1
				gas -= a - f
				pos = a
			elif pos == a:
				trips += 1
				if trips == k:
					break
				move = -1
		elif move == -1:
			if pos == 0:
				trips += 1
				if trips == k:
					break
				move = 1
			elif pos == f:
				needed_gas = f if trips == k - 1 else 2 * f
				if gas < needed_gas:
					gas = b
					fuels += 1
				pos = 0
				gas -= f
			elif pos == a:
				pos = f
				gas -= a - f
	print(fuels)
main()


def main():
	(a, b, f, k) = map(int, input().split())
	if b < f or b < a - f:
		print(-1)
	elif k >= 2 and b < 2 * (a - f):
		print(-1)
	elif k > 2 and b < 2 * f:
		print(-1)
	else:
		(refuel, fuel) = (0, b)
		for i in range(k - 1):
			if i % 2:
				if fuel < f + a:
					refuel += 1
					fuel = b - f
				else:
					fuel = fuel - a
			elif fuel < 2 * a - f:
				refuel += 1
				fuel = b - (a - f)
			else:
				fuel = fuel - a
		if fuel < a:
			refuel += 1
		print(refuel)
main()


def impossible():
	print(-1)
	exit()
(dest, cap, station, journey) = map(int, input().strip().split())
(left, right) = (2 * station, 2 * (dest - station))
if journey == 1 and (cap < station or cap < dest - station):
	impossible()
if journey == 2 and (cap < station or cap < right):
	impossible()
if journey >= 3 and (cap < left or cap < right):
	impossible()
time = 0
consume = station
for i in range(journey - 1):
	go = left if i & 1 else right
	if consume + go > cap:
		time += 1
		consume = go
	else:
		consume += go
if journey & 1 == 0 and consume + station > cap or (journey & 1 and consume + dest - station > cap):
	print(time + 1)
else:
	print(time)


(a, b, f, k) = map(int, input().strip().split())
st = 0
mod = 0
fue = b
flg = 0
ans = 0
if fue < f:
	flg = 1
fue -= f
mod = 1
for i in range(k):
	if st == 0:
		if mod == 0:
			mod = 1
			if fue < f:
				fue = b
				ans += 1
				if fue < f:
					flg = 1
					break
			fue -= f
		else:
			st = 1
			mod = 1
			if i == k - 1:
				if fue < a - f:
					fue = b
					ans += 1
					if fue < a - f:
						flg = 1
						break
				fue -= a - f
				continue
			if fue < 2 * (a - f):
				fue = b
				ans += 1
				if fue < 2 * (a - f):
					flg = 1
					break
			fue -= 2 * (a - f)
	else:
		st = 0
		mod = 1
		if i == k - 1:
			if fue < f:
				fue = b
				ans += 1
				if fue < f:
					flg = 1
					break
			fue -= f
			continue
		if fue < 2 * f:
			fue = b
			ans += 1
			if fue < 2 * f:
				flg = 1
				break
		fue -= 2 * f
if flg == 1:
	print(-1)
else:
	print(ans)


def solution(a, b, f, k):
	d1 = 2 * (a - f)
	d2 = 2 * f
	if k == 1:
		if f > b or a - f > b:
			return -1
	elif k == 2:
		if f > b or d1 > b:
			return -1
	elif d1 > b or d2 > b:
		return -1
	fuels = 0
	fue = b - f
	for i in range(k - 1):
		dist = d1 if i % 2 == 0 else d2
		if fue < dist:
			fuels += 1
			fue = b
		fue -= dist
	dist = a - f if (k - 1) % 2 == 0 else f
	if fue < dist:
		fuels += 1
	return fuels
(a, b, f, k) = map(int, input().split())
print(solution(a, b, f, k))


(a, b, f, k) = map(int, input().split())
t = 0
lt = b
ans = 0
while t < k:
	if t & 1:
		lt -= a - f
		if lt < 0:
			exit(print(-1))
		if lt < f * 2:
			ans += 1
			if t == k - 1 and lt >= f:
				ans -= 1
			lt = b
		lt -= f
		if lt < 0:
			exit(print(-1))
	else:
		lt -= f
		if lt < 0:
			exit(print(-1))
		if lt < (a - f) * 2:
			ans += 1
			if t == k - 1 and lt >= a - f:
				ans -= 1
			lt = b
		lt -= a - f
		if lt < 0:
			exit(print(-1))
	t += 1
print(ans)


(a, b, f, k) = map(int, input().split())
(curr, res) = (b, 0)
for i in range(k):
	prev = curr
	curr -= a
	if i % 2 == 0:
		if curr < a - f and i < k - 1 or curr < 0:
			curr = b - a + f
			res += 1
			if curr < a - f and i < k - 1 or curr < 0 or prev < f:
				print(-1)
				exit()
	elif curr < f and i < k - 1 or curr < 0:
		curr = b - f
		res += 1
		if curr < f and i < k - 1 or curr < 0 or prev < a - f:
			print(-1)
			exit()
print(res)


(a, b, f, k) = map(int, input().split())
fuel = b
res = 0
for i in range(k):
	fuel -= f
	if fuel < 0:
		print(-1)
		exit(0)
	if i == k - 1:
		if a - f > fuel:
			fuel = b
			res += 1
		fuel -= a - f
		break
	if (a - f) * 2 > fuel:
		fuel = b
		res += 1
	fuel -= a - f
	f = a - f
if fuel < 0:
	print(-1)
	exit(0)
print(res)


(a, b, f, k) = map(int, input().split(' '))
(l, r) = (f, a - f)
if b < l or b < r:
	print(-1)
elif k > 1 and b < 2 * r:
	print(-1)
elif k > 2 and b < 2 * l:
	print(-1)
else:
	remain = b
	cnt = 0
	i = 0
	while i < k:
		remain -= l
		if i < k - 1 and remain < 2 * r:
			remain = b
			cnt += 1
		elif i == k - 1 and remain < r:
			remain = b
			cnt += 1
		remain -= 2 * r
		i += 1
		if i == k:
			break
		if i < k - 1 and remain < 2 * l:
			remain = b
			cnt += 1
		elif i == k - 1 and remain < l:
			remain = b
			cnt += 1
		remain -= l
		i += 1
	print(cnt)


cin = input().split()
a = int(cin[0])
b = int(cin[1])
f = int(cin[2])
k = int(cin[3])
fuel = [0]
for h in range(k // 2):
	fuel += [2 * a * h + f, 2 * a * (h + 1) - f]
if k % 2 == 1 and k != 1:
	fuel += [2 * a * (k // 2) + f]
elif k == 1:
	fuel += [f]
fuel += [a * k]
try:
	d1 = fuel[2] - fuel[1]
	d2 = fuel[3] - fuel[2]
except:
	d1 = fuel[1] - fuel[0]
	d2 = fuel[2] - fuel[1]
if d1 > b or d2 > b:
	print(-1)
else:
	fuelPointer = 0
	gas = b
	refuel = 0
	while fuelPointer < len(fuel) - 1:
		if gas < fuel[fuelPointer + 1] - fuel[fuelPointer]:
			refuel += 1
			gas = b
		gas -= fuel[fuelPointer + 1] - fuel[fuelPointer]
		fuelPointer += 1
	print(refuel)


import math
import collections
import bisect
import heapq
import time
import random
(a, b, f, k) = map(int, input().split())
if b < f or f + b < a:
	print(-1)
	exit(0)
r = a - f
res = 0
fuel = b
for i in range(k):
	if i % 2 == 0:
		if i == k - 1:
			if fuel >= a:
				break
			elif fuel >= f:
				res += 1
				break
			else:
				print(-1)
				exit(0)
		else:
			if fuel < f:
				print(-1)
				exit(0)
			if fuel >= a + r:
				fuel -= a
			else:
				res += 1
				fuel = b - r
	elif i == k - 1:
		if fuel < r:
			print(-1)
			exit(0)
		if fuel >= a:
			break
		elif fuel >= r:
			res += 1
			break
		else:
			print(-1)
			exit(0)
	elif fuel >= a + f:
		fuel -= a
	else:
		res += 1
		fuel = b - f
print(res)


(a, b, f, k) = map(int, input().split())
g = a - f
t = b - f
s = 0
while t >= 0:
	if t >= g:
		k -= 1
		t -= g
	else:
		t = b - g
		s += 1
		if t < 0:
			break
		k -= 1
	if k == 0:
		break
	if t >= g:
		t -= g
	else:
		t = b - 2 * g
		s += 1
		if t < 0:
			break
	if t >= f:
		k -= 1
		t -= f
	else:
		t = b - f
		s += 1
		if t < 0:
			break
		k -= 1
	if k == 0:
		break
	if t >= f:
		t -= f
	else:
		t = b - 2 * f
		s += 1
		if t < 0:
			break
print(-1 if k else s)


(a, b, f, k) = map(int, input().split())
ans = 0
c = b
if b < f:
	ans = -1
else:
	c -= f
for i in range(k):
	if ans == -1:
		break
	if i % 2 == 0:
		d = a - f
	else:
		d = f
	if i < k - 1:
		d *= 2
	if b < d:
		ans = -1
	elif c < d:
		ans += 1
		c = b
	c -= d
print(ans)


def solve(a, b, f, k):
	origb = b
	disa = 2 * f
	disb = 2 * (a - f)
	trava = False
	counter = 0
	b -= disa / 2
	if b < 0:
		return -1
	while k > 0:
		if trava:
			trava = False
			if k == 1:
				disa = disa / 2
			if disa > b:
				counter += 1
				b = origb - disa
				if b < 0:
					return -1
				k -= 1
			else:
				b -= disa
				if b < 0:
					return -1
				k -= 1
		else:
			trava = True
			if k == 1:
				disb = disb / 2
			if disb > b:
				counter += 1
				b = origb - disb
				if b < 0:
					return -1
				k -= 1
			else:
				b -= disb
				if b < 0:
					return -1
				k -= 1
	return counter
inputs = input('')
afind = inputs.find(' ')
a = int(inputs[0:afind])
inputs = inputs[afind + 1:]
afind = inputs.find(' ')
b = int(inputs[0:afind])
inputs = inputs[afind + 1:]
afind = inputs.find(' ')
f = int(inputs[0:afind])
inputs = inputs[afind + 1:]
k = int(inputs[0:])
print(solve(a, b, f, k))


init = list(map(int, input().split()))
finalPoint = init[0]
fuelCapacity = init[1]
refuelPoint = init[2]
voyageCount = init[3]
currentVoyageCount = 0
currentFuelCapacity = fuelCapacity
currentPosition = 0
refuelCount = 0
isEnd = False
error = False
stepSide = 1

def isHaveToRefuel():
	global currentFuelCapacity
	global refuelCount
	if currentVoyageCount + 1 == voyageCount:
		if stepSide == 1:
			if currentFuelCapacity >= finalPoint - refuelPoint:
				return
			else:
				currentFuelCapacity = fuelCapacity
				refuelCount += 1
		elif currentFuelCapacity >= refuelPoint - 0:
			return
		else:
			currentFuelCapacity = fuelCapacity
			refuelCount += 1
	elif stepSide == 1:
		if currentFuelCapacity >= (finalPoint - refuelPoint) * 2:
			return
		else:
			currentFuelCapacity = fuelCapacity
			refuelCount += 1
	elif currentFuelCapacity >= (refuelPoint - 0) * 2:
		return
	else:
		currentFuelCapacity = fuelCapacity
		refuelCount += 1

def makeStep():
	global currentPosition
	global currentFuelCapacity
	global error
	if currentPosition == refuelPoint:
		isHaveToRefuel()
		if stepSide == 1:
			currentFuelCapacity = currentFuelCapacity - (finalPoint - refuelPoint)
			currentPosition = finalPoint
		else:
			currentFuelCapacity = currentFuelCapacity - (refuelPoint - 0)
			currentPosition = 0
	elif stepSide == 1:
		currentFuelCapacity = currentFuelCapacity - (refuelPoint - 0)
		currentPosition = refuelPoint
	else:
		currentFuelCapacity = currentFuelCapacity - (finalPoint - refuelPoint)
		currentPosition = refuelPoint
	if currentFuelCapacity < 0:
		error = True
while currentVoyageCount < voyageCount:
	makeStep()
	if error == True:
		isEnd = False
		break
	if currentPosition == 0 or currentPosition == finalPoint:
		currentVoyageCount += 1
	if currentPosition == 0:
		stepSide = 1
	elif currentPosition == finalPoint:
		stepSide = -1
if currentVoyageCount == voyageCount:
	isEnd = True
if isEnd == True:
	print(refuelCount)
else:
	print('-1')


(a, b, f, k) = map(int, input().split())
p = b
i = 0
direct = 'p'
ans = 0
flag = 0
while k > 0:
	if i == 0 and p < f or (i == a and p < a - f):
		flag = 1
		break
	elif i == 0:
		p -= f
		i = f
	elif i == a:
		p -= a - f
		i = f
	else:
		if k == 1:
			if direct == 'p':
				if p < a - f and b >= a - f:
					p = b
					ans += 1
				elif b < a - f:
					flag = 1
					break
			elif direct == 'n':
				if p < f and b >= f:
					p = b
					ans += 1
				elif b < f:
					flag = 1
					break
		elif direct == 'p':
			if p < 2 * (a - f) and b >= 2 * (a - f):
				p = b
				ans += 1
			elif b < 2 * (a - f):
				flag = 1
				break
			p -= 2 * (a - f)
			direct = 'n'
		elif direct == 'n':
			if p < 2 * f and b >= 2 * f:
				p = b
				ans += 1
			elif b < 2 * f:
				flag = 1
				break
			p -= 2 * f
			direct = 'p'
		k -= 1
	if p < 0:
		flag = 1
		break
if flag == 1:
	print(-1)
else:
	print(ans)


(a, bm, f, k) = [int(i) for i in input().split()]
b = bm
(r1, r2) = (f, a - f)
count = 0
for i in range(k):
	b -= r1
	if b < 0:
		print(-1)
		exit(0)
	if b < 2 * r2 and i != k - 1:
		b = bm
		count += 1
	elif i == k - 1:
		if b < r2:
			b = bm
			count += 1
	b -= r2
	if b < 0:
		print(-1)
		exit(0)
	(r1, r2) = (r2, r1)
print(count)


(a, b, f, k) = map(int, input().split())
(s, t) = (0, b - f)
g = f = a - f
for i in range(k):
	if t < 0:
		break
	if k - 1 - i:
		g += f
	if t < g:
		(s, t) = (s + 1, b)
	t -= g
	g = f = a - f
print(-1 if t < 0 else s)


def calculate_minimal_refueling(obj_pos, fuel_capacity, gas_station_pos, trip_required):
	direction = True
	current_gas = fuel_capacity
	refuel_count = 0
	for trip in range(trip_required):
		if direction:
			current_gas -= gas_station_pos
			if current_gas < 0:
				return -1
			elif trip + 1 != trip_required and current_gas < 2 * (obj_pos - gas_station_pos) or current_gas < obj_pos - gas_station_pos:
				current_gas = fuel_capacity
				refuel_count += 1
			current_gas -= obj_pos - gas_station_pos
			if current_gas < 0:
				return -1
			direction = False
		else:
			current_gas -= obj_pos - gas_station_pos
			if current_gas < 0:
				return -1
			elif trip + 1 != trip_required and current_gas < 2 * gas_station_pos or current_gas < gas_station_pos:
				current_gas = fuel_capacity
				refuel_count += 1
			current_gas -= gas_station_pos
			if current_gas < 0:
				return -1
			direction = True
	return refuel_count

def main():
	(a, b, f, k) = map(int, input().split())
	print(calculate_minimal_refueling(a, b, f, k))
main()


(a, b, f, k) = map(int, input().split())
req = 0
live_fuel = b
while k > 0:
	live_fuel -= f
	k -= 1
	if live_fuel < 0:
		req = -1
		break
	else:
		if live_fuel >= 2 * (a - f) or (k == 0 and live_fuel >= a - f):
			live_fuel -= a - f
		else:
			live_fuel = b
			req += 1
			live_fuel -= a - f
		if live_fuel < 0:
			req = -1
			break
		else:
			if k <= 0:
				break
			k -= 1
			live_fuel -= a - f
			if live_fuel < 0:
				req = -1
				break
			else:
				if live_fuel >= 2 * f or (k == 0 and live_fuel >= f):
					live_fuel -= f
				else:
					live_fuel = b - f
					req += 1
				if live_fuel < 0:
					req = -1
					break
print(req)


import sys

def min_refills(end_point, capacity, fuel_point, journeys):
	fuel = capacity
	journey_count = 0
	refills = 0
	while True:
		fuel -= fuel_point
		if fuel < 0:
			return -1
		fuel_needed = 2 * (end_point - fuel_point) if journey_count < journeys - 1 else end_point - fuel_point
		if fuel_needed > fuel:
			refills += 1
			fuel = capacity
		if fuel_needed > capacity:
			return -1
		fuel -= end_point - fuel_point
		journey_count += 1
		if journey_count == journeys:
			break
		fuel -= end_point - fuel_point
		fuel_needed = 2 * fuel_point if journey_count < journeys - 1 else fuel_point
		if fuel_needed > fuel:
			refills += 1
			fuel = capacity
		if fuel_needed > capacity:
			return -1
		fuel -= fuel_point
		journey_count += 1
		if journey_count == journeys:
			break
	return refills
line = sys.stdin.readline()
print(min_refills(*[int(x) for x in line.split()]))


import sys
import os
import math
import re
(a, b, f, k) = map(int, input().split())
fuel = b
trips = 0
first = f
second = a - f
for i in range(k):
	fuel -= first
	if fuel < 0:
		print(-1)
		exit(0)
	if i == k - 1:
		if fuel < second:
			fuel = b
			trips += 1
	elif fuel < 2 * second:
		fuel = b
		trips += 1
	fuel -= second
	if fuel < 0:
		print(-1)
		exit(0)
	temp = first
	first = second
	second = temp
print(trips)


(a, b, f, k) = map(int, input().split())
d = 1
now = 0
res = 0
k += 1
g = b
bb = b
(a, b) = (0, a)
while True:
	if now == a or now == b:
		k -= 1
		g -= abs(now - f)
		now = f
		if not k or g < 0:
			break
	elif now == f:
		c = b - f if d else f
		dis = c if k == 1 else 2 * c
		if g >= dis:
			g -= c
			now = b if d else a
			d ^= 1
		elif bb < dis:
			break
		else:
			g = bb
			res += 1
print(-1 if k else res)


l = [int(x) for x in input().split()]
a = []
b = l[1]
f = 0
c = 0
a.append(0)
for i in range(l[3]):
	if i % 2 == 0:
		a.append(i * l[0] + l[2])
	else:
		a.append((i + 1) * l[0] - l[2])
a.append(l[0] * l[3])
for j in range(1, l[3] + 2):
	if b >= a[j] - a[j - 1]:
		b = b - a[j]
		b = b + a[j - 1]
	else:
		b = l[1]
		if b >= a[j] - a[j - 1]:
			f = f + 1
			b = b - (a[j] - a[j - 1])
		else:
			c = -1
			break
if c == -1:
	print(c)
else:
	print(f)


def get_raw_input():
	raw = input()
	raw = raw.split(' ')
	return raw

def is_tour_possible(total, capo, pos, jrns):
	x = total - pos
	if (2 * x > capo or 2 * pos > capo) and jrns > 2:
		return False
	if jrns == 1 and (x > capo or pos > capo):
		return False
	if jrns == 2 and (2 * x > capo or pos > capo):
		return False
	return True

def need_refuel(curr, next_stop_dst):
	if next_stop_dst > curr:
		return True
	return False

def get_next_distance(iter, dst1, dst2, **special):
	if special.get('last') is None:
		if iter % 2 == 1:
			return dst2
		return dst1
	if special.get('last'):
		if iter % 2 == 1:
			return dst2 / 2
		return dst1 / 2

def drive(iter):
	if iter % 2 == 1:
		return BtoC
	return AtoB
inp = get_raw_input()
total_dst = int(inp[0])
fuel_capo = int(inp[1])
fuel_pos = int(inp[2])
jrn_amount = int(inp[3])
AtoB = 2 * fuel_pos
BtoC = 2 * (total_dst - fuel_pos)
refuels = 0
if is_tour_possible(total_dst, fuel_capo, fuel_pos, jrn_amount):
	jrn = 1
	curr_fuel = fuel_capo - fuel_pos
	while jrn <= jrn_amount - 1:
		if need_refuel(curr_fuel, get_next_distance(jrn, AtoB, BtoC)):
			refuels += 1
			curr_fuel = fuel_capo
		curr_fuel -= drive(jrn)
		jrn += 1
	if need_refuel(curr_fuel, get_next_distance(jrn, AtoB, BtoC, last=True)):
		refuels += 1
	print(refuels)
else:
	print(-1)


(a, b, f, k) = map(int, input().split())
tank = b
dist = [f, a - f]
direction = 0
total = 0
res = 0
journeys = 0
while journeys < k:
	if total + tank >= k * a:
		break
	if tank < dist[direction]:
		res = -1
		break
	tank -= dist[direction]
	total += dist[direction]
	if tank < 2 * dist[(direction + 1) % 2]:
		tank = b
		res += 1
	tank -= dist[(direction + 1) % 2]
	total += dist[(direction + 1) % 2]
	direction = (direction + 1) % 2
	journeys += 1
	if tank < 0 or (tank < dist[direction] and journeys < k):
		res = -1
		break
print(res)


(a, b, f, k) = input().split()
(a, b, f, k) = (int(a), int(b), int(f), int(k))
if k > 2 and b < max(2 * f, 2 * (a - f)):
	print(-1)
	exit()
if k == 1 and b < max(f, a - f):
	print(-1)
	exit()
if k == 2 and (b < 2 * (a - f) or b < f):
	print(-1)
	exit()
v = b
count = 0
while k > 0:
	v = v - f
	if v < 0:
		count = -1
		break
	if k > 1 and v < 2 * (a - f):
		v = b
		count += 1
	elif k == 1 and v < a - f:
		v = b
		count += 1
	if k > 1:
		v = v - 2 * (a - f)
	else:
		v = v - (a - f)
	k -= 1
	if k > 1 and v < 2 * f:
		v = b
		count += 1
	elif k == 1 and v < f:
		v = b
		count += 1
	v = v - f
	k -= 1
print(count)


R = lambda : list(map(int, input().split()))
(a, b, f, k) = R()
p = b
s = 0
if k == 1:
	if f > b or a - f > b:
		print(-1)
	elif b >= a:
		print(0)
	else:
		print(1)
elif k == 2:
	if b < 2 * (a - f) or b < f:
		print(-1)
	elif b >= 2 * a:
		print(0)
	elif b >= a + a - f:
		print(1)
	elif b >= a + f:
		print(1)
	else:
		print(2)
elif b < 2 * (a - f) or b < 2 * f:
	print(-1)
else:
	for i in range(k):
		if i == k - 1:
			if b < a:
				s += 1
		elif i % 2 == 0:
			if b >= a + a - f:
				b -= a
			else:
				s += 1
				b = p - (a - f)
		elif b >= a + f:
			b -= a
		else:
			b = p - f
			s += 1
	print(s)


(a, b, c, d) = map(int, input().split())
x = b - c
f = 1
if b < c or b < a - c or (d >= 2 and b < (a - c) * 2) or (d > 2 and b < c * 2):
	print(-1)
	exit()
k = 0
for i in range(d):
	if i + 1 == d:
		if f == 1:
			if x >= a - c:
				print(k)
			else:
				print(k + 1)
		elif x >= c:
			print(k)
		else:
			print(k + 1)
		exit()
	if f == 1:
		if x >= (a - c) * 2:
			x = x - (a - c) * 2
		else:
			x = b - (a - c) * 2
			k = k + 1
		f = 2
	else:
		if x >= c * 2:
			x = x - c * 2
		else:
			x = b - c * 2
			k = k + 1
		f = 1


(a, b, f, k) = list(map(int, input().split()))
i = 0
bi = b
ans = 0
while i < k:
	if f > bi:
		print(-1)
		return
	bi -= f
	if k - i == 1:
		if a - f > bi:
			bi = b
			ans += 1
		if a - f > b:
			print(-1)
			return
		break
	i += 1
	if 2 * (a - f) > bi:
		bi = b
		ans += 1
	if 2 * (a - f) > b:
		print(-1)
		return
	bi -= 2 * (a - f)
	if k - i == 1:
		if f > bi:
			bi = b
			ans += 1
		break
	if 2 * f > bi:
		bi = b
		ans += 1
	if 2 * f > b:
		print(-1)
		return
	bi -= f
	i += 1
print(ans)


(b, max_fuel, f, k) = map(int, input().split())
now_fuel = max_fuel
ans = 0
part_1 = f
part_2 = b - f
now_fuel -= part_1
if now_fuel < 0:
	print('-1')
	exit()
while k != 0:
	if k > 1:
		if now_fuel < part_2 * 2:
			ans += 1
			now_fuel = max_fuel
		now_fuel -= part_2 * 2
		k -= 1
		if now_fuel < 0:
			print('-1')
			exit()
	else:
		if now_fuel < part_2:
			ans += 1
			now_fuel = max_fuel
		now_fuel -= part_2
		k -= 1
		if now_fuel < 0:
			print('-1')
			exit()
		break
	if k > 1:
		if now_fuel < part_1 * 2:
			ans += 1
			now_fuel = max_fuel
		now_fuel -= part_1 * 2
		k -= 1
		if now_fuel < 0:
			print('-1')
			exit()
	else:
		if now_fuel < part_1:
			ans += 1
			now_fuel = max_fuel
		now_fuel -= part_1
		k -= 1
		if now_fuel < 0:
			print('-1')
			exit()
		break
print(ans)


(a, b, f, k) = tuple([int(i) for i in input().split(' ')])
pos = True
route = 0
petrol = 0
if abs(f) > b:
	print(-1)
else:
	tank = b
	need = abs(f)
	for i in range(k + 1):
		tank -= need
		route += need
		if i % 2 == 1:
			need = abs(f) * 2
		else:
			need = abs(a - f) * 2
		if route + need > a * k:
			need = a * k - route
		if need > b:
			pos = False
			break
		elif need > tank:
			petrol += 1
			tank = b
	if pos:
		print(petrol)
	else:
		print(-1)


import sys

def solve():
	(end, full, real_mid, times) = map(int, sys.stdin.readline().split())
	oil = full
	cnt = 0
	for i in range(times):
		if i % 2 == 0:
			mid = real_mid
		else:
			mid = end - real_mid
		if mid > oil:
			return -1
		oil -= mid
		if i != times - 1:
			if (end - mid) * 2 > full:
				return -1
			if (end - mid) * 2 > oil:
				oil = full
				cnt += 1
		else:
			if end - mid > full:
				return -1
			if end - mid > oil:
				oil = full
				cnt += 1
		oil -= end - mid
	return cnt
print(solve())


def solve(a, b, f, k):
	cur_b = b
	cur_k = 0
	refueling_count = 0
	can_0f = cur_b - f >= 0
	if not can_0f:
		return (refueling_count, cur_k)
	else:
		cur_b -= f
	while cur_k < k:
		faf_path = 2 * (a - f)
		can_faf = cur_b - faf_path >= 0
		can_faf_with_refueling = b - faf_path >= 0
		can_fa = cur_b - (a - f) >= 0
		can_fa_with_refueling = b - (a - f) >= 0
		if can_faf and k - cur_k > 1:
			cur_b = cur_b - faf_path
			cur_k += 1
		elif can_faf_with_refueling and k - cur_k > 1:
			refueling_count += 1
			cur_b = b - faf_path
			cur_k += 1
		elif can_fa:
			cur_k += 1
			return (refueling_count, cur_k)
		elif can_fa_with_refueling:
			cur_k += 1
			refueling_count += 1
			return (refueling_count, cur_k)
		else:
			return (refueling_count, cur_k)
		if cur_k == k:
			return (refueling_count, cur_k)
		f0f_path = 2 * f
		can_f0f = cur_b - f0f_path >= 0
		can_f0f_with_refueling = b - f0f_path >= 0
		can_f0 = cur_b - f >= 0
		can_f0_with_refueling = b - f >= 0
		if can_f0f and k - cur_k > 1:
			cur_b = cur_b - f0f_path
			cur_k += 1
		elif can_f0f_with_refueling and k - cur_k > 1:
			refueling_count += 1
			cur_b = b - f0f_path
			cur_k += 1
		elif can_f0:
			cur_k += 1
			return (refueling_count, cur_k)
		elif can_f0_with_refueling:
			cur_k += 1
			refueling_count += 1
			return (refueling_count, cur_k)
		else:
			return (refueling_count, cur_k)
	return (refueling_count, cur_k)

def main():
	(a, b, f, k) = map(int, input().split())
	(refueling_count, cur_k) = solve(a, b, f, k)
	if cur_k == k:
		print(refueling_count)
	else:
		print(-1)
main()


(a, b, f, k) = (int(x) for x in input().split())
z = 0
curr_petrol = b
curr_races_made = 0
ans = 0
z___f = f - z
f___a = a - f
if k == 1:
	if z___f > b or f___a > b:
		print(-1)
		return
elif k == 2:
	if 2 * f___a > b:
		print(-1)
		return
elif 2 * z___f > b or 2 * f___a > b:
	print(-1)
	return
curr_save = None
route = [z___f, f___a, f___a, z___f]
while curr_races_made < 2 * k:
	curr_pos = curr_races_made % 4
	curr_petrol -= route[curr_pos]
	curr_races_made += 1
	if curr_petrol < 0:
		curr_petrol = b
		ans += 1
		curr_races_made = curr_save
		continue
	if curr_pos == 0 or curr_pos == 2:
		curr_save = curr_races_made
print(ans)


(a, b, f, k) = map(int, input().split())
now = b
da = [0, f, a]
an = 0
for r in range(k):
	if r == k - 1:
		if r % 2 == 0:
			if now < f:
				print(-1)
				exit(0)
			now -= f
			if now < a - f:
				now = b
				an += 1
			if now < a - f:
				print(-1)
				exit(0)
			now -= a - f
		else:
			if now < a - f:
				print(-1)
				exit(0)
			now -= a - f
			if now < f:
				now = b
				an += 1
			if now < f:
				print(-1)
				exit(0)
			now -= f
	elif r % 2 == 0:
		if now < f:
			print(-1)
			exit(0)
		now -= f
		if now < 2 * (a - f):
			now = b
			an += 1
		if now < a - f:
			print(-1)
			exit(0)
		now -= a - f
	else:
		if now < a - f:
			print(-1)
			exit(0)
		now -= a - f
		if now < 2 * f:
			now = b
			an += 1
		if now < f:
			print(-1)
			exit(0)
		now -= f
print(an)


(a, b, f, k) = list(map(int, input().split()))
t = b
ans = 0

def go(dist):
	global ans, t
	if dist > b:
		print(-1)
		exit()
	if t < dist:
		t = b
		ans += 1
	t -= dist
go(f)
fw = True
for _ in range(k - 1):
	go(2 * (a - f if fw else f))
	fw = not fw
go(a - f if fw else f)
print(ans)


(a, b, f, k) = map(int, input().split())
ans = 0
t = b
l = a - f
x = 0
if b < max(f, l):
	ans = -1
else:
	while k > 0:
		if x == 0:
			t -= f
			if t < 0:
				ans = -1
				break
			t -= l
			if k == 1:
				l = 0
			if b - l < 0:
				ans = -1
				break
			if t - l < 0:
				t = b - l
				ans += 1
			k -= 1
			x = a
		else:
			t -= l
			if t < 0:
				ans = -1
				break
			t -= f
			if k == 1:
				f = 0
			if b - f < 0:
				ans = -1
				break
			if t - f < 0:
				t = b - f
				ans += 1
			k -= 1
			x = 0
print(ans)


(a, b, f, k) = list(map(int, input().split()))
g = b
ans = 0
(p1, p2) = (0, f)
for i in range(2 * k):
	if p1 == 0 and p2 == f:
		if b >= p2 - p1:
			b = b - (p2 - p1)
		else:
			ans = -1
			break
		p1 = f
		p2 = a
	elif p1 == f and p2 == a:
		y = 1 if i == 2 * k - 1 else 2
		if b >= y * (p2 - p1):
			b = b - (p2 - p1)
		else:
			b = g
			b = b - (p2 - p1)
			if b < 0:
				ans = -1
				break
			else:
				ans = ans + 1
		p1 = a
		p2 = f
	elif p1 == a and p2 == f:
		if b >= p1 - p2:
			b = b - (p1 - p2)
		else:
			ans = -1
			break
		p1 = f
		p2 = 0
	elif p1 == f and p2 == 0:
		y = 1 if i == 2 * k - 1 else 2
		if b >= y * (p1 - p2):
			b = b - (p1 - p2)
		else:
			b = g
			b = b - (p1 - p2)
			if b < 0:
				ans = -1
				break
			else:
				ans = ans + 1
		p1 = 0
		p2 = f
print(ans)


import sys
DEBUG = False
(a, b, f, k) = map(int, input().split())

def game_over():
	print(-1)
	sys.exit()
fuel = b
add_fuel_count = 0
fuel_on_next_stop = fuel - f
if fuel_on_next_stop < 0:
	game_over()
distance = 0
for i in range(1, k + 1):
	fuel = fuel_on_next_stop
	if DEBUG:
		print('i= {} : '.format(i))
		print('\t fuel_on_station = {} '.format(fuel))
	if i == k:
		if i % 2:
			distance = a - f
		else:
			distance = f
	elif i % 2:
		distance = 2 * (a - f)
	else:
		distance = 2 * f
	if fuel < distance:
		(fuel, add_fuel_count) = (b, add_fuel_count + 1)
	fuel_on_next_stop = fuel - distance
	if fuel_on_next_stop < 0:
		game_over()
	if DEBUG:
		print('\t distance = {} '.format(distance))
		print('\t fuel_on_next_stop = {} '.format(fuel_on_next_stop))
		if fuel == b:
			print('\t YES')
print(add_fuel_count)


(a, b, f, k) = map(int, input().split())
im = False
fuel = b
cnt = 0
for i in range(k):
	if i % 2 == 0:
		if fuel - f < 0:
			im = True
			break
		if i < k - 1:
			if fuel - (2 * a - f) < 0:
				cnt += 1
				fuel = b - (a - f)
			else:
				fuel -= a
		elif fuel - a < 0:
			cnt += 1
			fuel = b - (a - f)
		else:
			fuel -= a
	else:
		if fuel - (a - f) < 0:
			im = True
			break
		if i < k - 1:
			if fuel - (a + f) < 0:
				cnt += 1
				fuel = b - f
			else:
				fuel -= a
		elif fuel - a < 0:
			cnt += 1
			fuel = b - f
		else:
			fuel -= a
	if fuel < 0:
		im = True
		break
print(-1 if im else cnt)


(a, b, f, k) = map(int, input().split())
(c, v) = (b, 0)

def t(d):
	global c, v
	if c < d:
		(c, v) = (b, v + 1)
		if c < d:
			print(-1)
			exit()
	c -= d
t(f)
for i in range(k - 1):
	t(2 * f if i % 2 else 2 * (a - f))
t(a - f if k % 2 else f)
print(v)


(a, b, f, k) = [int(i) for i in input().split()]
if b < f:
	print(-1)
	return
journeys = 0
previous = 0
refuels1 = 0
tank = b - f
while journeys != k:
	if previous == 0:
		if tank >= a - f + a * (k - journeys - 1):
			print(refuels1)
			return
		if b >= a - f + a * (k - journeys - 1):
			print(refuels1 + 1)
			return
		if tank >= 2 * (a - f):
			tank -= 2 * (a - f)
		elif b >= 2 * (a - f):
			refuels1 += 1
			tank = b - 2 * (a - f)
		else:
			print(-1)
			return
		journeys += 1
		previous = a
	if previous == a:
		if tank >= f + a * (k - journeys - 1):
			print(refuels1)
			return
		if b >= f + a * (k - journeys - 1):
			print(refuels1 + 1)
			return
		if tank >= 2 * f:
			tank -= 2 * f
		elif b >= 2 * f:
			refuels1 += 1
			tank = b - 2 * f
		else:
			print(-1)
			return
		journeys += 1
		previous = 0
if journeys == k:
	print(refuels1)
else:
	print(-1)


(a, b, f, k) = map(int, input().split())
cur = b
good = 1
cnt = 0
for i in range(k):
	if i % 2 == 0:
		if i == k - 1:
			if cur < f:
				good = 0
			elif cur >= a:
				cur -= a
				cnt += 0
			elif b >= a - f:
				cnt += 1
			else:
				good = 0
		elif 2 * (a - f) > b:
			good = 0
		elif cur >= 2 * a - f:
			cnt += 0
			cur -= a
		elif cur < f:
			good = 0
		else:
			cnt += 1
			cur = b - (a - f)
	elif i == k - 1:
		if cur < a - f:
			good = 0
		elif cur >= a:
			cur -= a
			cnt += 0
		elif b >= f:
			cnt += 1
		else:
			good = 0
	elif 2 * f > b:
		good = 0
	elif cur >= a + f:
		cur -= a
		cnt += 0
	elif cur < a - f:
		good = 0
	else:
		cnt += 1
		cur = b - f
if good == 1:
	print(cnt)
else:
	print(-1)


(a, b, f, k) = list(map(int, input().split(' ')))
fuel_level = b
point = 0
direction = 1
journays = 0
impossible = 0
refuel_counter = 0
if k == 1 and (b < a - f or b < f):
	print(-1)
elif k == 2 and (b < f or b < 2 * (a - f)):
	print(-1)
elif k > 2 and (b < 2 * f or b < 2 * (a - f)):
	print(-1)
else:
	while journays < k:
		if point == 0 and direction == 1:
			fuel_level -= f
			point = f
		elif point == f and direction == 1:
			if fuel_level < 2 * (a - f) and journays < k - 1 or (fuel_level < a - f and journays == k - 1):
				refuel_counter += 1
				fuel_level = b - (a - f)
				journays += 1
				direction = -1
				point = a
			else:
				fuel_level -= a - f
				journays += 1
				direction = -1
				point = a
		elif point == a and direction == -1:
			fuel_level -= a - f
			point = f
		elif point == f and direction == -1:
			if fuel_level < 2 * f and journays < k - 1 or (fuel_level < f and journays == k - 1):
				refuel_counter += 1
				fuel_level = b - f
				journays += 1
				direction = 1
				point = 0
			else:
				fuel_level -= f
				journays += 1
				direction = 1
				point = 0
	print(refuel_counter)


(a, b, f, k) = map(int, input().split())
tmp = b
flag = 0
c = 0
for i in range(k):
	if i % 2 == 0:
		if f > b:
			flag = 1
			break
		else:
			b = b - f
			if i != k - 1:
				if 2 * (a - f) > b:
					c += 1
					b = tmp
				b = b - (a - f)
			elif a - f > b:
				b = tmp
				if a - f > b:
					flag = 1
				else:
					c += 1
	elif b < a - f:
		flag = 1
		break
	else:
		b = b - (a - f)
		if i != k - 1:
			if 2 * f > b:
				c += 1
				b = tmp
			b = b - f
		elif f > b:
			b = tmp
			if f > b:
				flag = 1
			else:
				c += 1
if flag == 0:
	print(c)
else:
	print(-1)


(a, b, f, k) = map(int, input().split())
d = b
n = 0
s = 0
x = a - f
d -= f
if x * 2 > b or f * 2 > b:
	if k < 3:
		if k == 1:
			if a <= b:
				print(0)
			elif f <= b and x <= b:
				print(1)
			else:
				print(-1)
		if k == 2:
			if a + x <= b:
				print(1)
			elif f <= b and x * 2 <= b:
				print(2)
			else:
				print(-1)
	else:
		print(-1)
else:
	while n < k:
		if n + 1 == k:
			if d < x:
				s += 1
			break
		if d < x * 2:
			s += 1
			d = b
		n += 1
		d -= x * 2
		if n + 1 == k:
			if d < f:
				s += 1
			break
		if d < f * 2:
			s += 1
			d = b
		n += 1
		d -= f * 2
	print(s)


(a, b, f, k) = map(int, input().split())
ans = 0
cb = b
for i in range(k):
	if i % 2 == 0:
		if f > cb:
			print(-1)
			return
		else:
			cb -= f
			if i != k - 1:
				if cb < 2 * (a - f):
					ans += 1
					cb = b
				cb -= a - f
			else:
				if cb < a - f:
					ans += 1
					cb = b
				cb -= a - f
				if cb < 0:
					print(-1)
					return
	elif a - f > cb:
		print(-1)
		return
	else:
		cb -= a - f
		if i != k - 1:
			if cb < 2 * f:
				ans += 1
				cb = b
			cb -= f
		else:
			if cb < f:
				ans += 1
				cb = b
			cb -= f
			if cb < 0:
				print(-1)
				return
print(ans)


(a, b, f, k) = map(int, input().split())
ff = 1
if k == 1:
	if b >= a:
		print(0)
	elif b >= f and b >= a - f:
		print(1)
	else:
		print(-1)
else:
	p = b - f
	ans = 0
	for i in range(k - 1):
		if i % 2 == 0:
			if b < 2 * (a - f):
				ff = 0
				break
			if p < 2 * (a - f):
				p = b - 2 * (a - f)
				ans += 1
			else:
				p -= 2 * (a - f)
		else:
			if b < 2 * f:
				ff = 0
				break
			if p < 2 * f:
				p = b - 2 * f
				ans += 1
			else:
				p -= 2 * f
	if k % 2 == 0:
		if b < f:
			ff = 0
		if p < f:
			ans += 1
	elif k % 2 == 1:
		if b < a - f:
			ff = 0
		if p < a - f:
			ans += 1
	if ff == 0:
		print(-1)
	else:
		print(ans)


line = input()
thing = list(map(int, line.split()))
a = thing[0]
b = thing[1]
f = thing[2]
k = thing[3]
fuel = b - f
fa = True
refuels = 0
trips = 0
while True:
	if fuel < 0:
		refuels = -1
		break
	if fa:
		if trips + 1 == k:
			distance = a - f
			if fuel < distance:
				refuels += 1
				fuel = b
				if b < distance:
					refuels = -1
					break
			break
		distance = 2 * (a - f)
		if fuel < distance:
			refuels += 1
			fuel = b
			if b < distance:
				refuels = -1
				break
		fuel = fuel - distance
		trips += 1
		fa = False
	if not fa:
		if trips + 1 == k:
			distance = f
			if fuel < distance:
				refuels += 1
				fuel = b
				if b < distance:
					refuels = -1
					break
			break
		distance = 2 * f
		if fuel < distance:
			refuels += 1
			fuel = b
			if b < distance:
				refuels = -1
				break
		fuel = fuel - distance
		trips += 1
		fa = True
print(refuels)


(a, b, f, k) = map(int, input().split())
bv = 0
j = 0
fu = 0
x = 0
ch = True
bv += b

def a_fs():
	if b >= f:
		return True
	return False

def a_ej(x, j, b):
	if j % 2 == 0 and a - x <= b or (j % 2 == 1 and x <= b):
		return True
	return False

def a_nfs(x, j, b):
	if j % 2 == 0 and b >= 2 * (a - x) or (j % 2 == 1 and b >= 2 * x):
		return True
	return False

def a_ejbv(x, j, bv):
	if j % 2 == 0 and a - x <= bv or (j % 2 == 1 and x <= bv):
		return True
	return False

def a_nfsbv(x, j, bv):
	if j % 2 == 0 and bv >= 2 * (a - x) or (j % 2 == 1 and bv >= 2 * x):
		return True
	return False

def x_nfs(x, j):
	if j % 2 == 0:
		return 2 * (a - x)
	return 2 * x

def x_ej(x, j):
	if j % 2 == 0:
		return a - x
	return x
if a_fs():
	x = f
	bv -= f
	if k > 2:
		if a_nfs(x, 0, b) and a_nfs(x, 1, b):
			while k - j > 1:
				if a_nfsbv(x, j, bv):
					bv -= x_nfs(x, j)
					j += 1
				else:
					fu += 1
					bv = b - x_nfs(x, j)
					j += 1
			if a_ejbv(x, j, bv):
				print(fu)
			else:
				print(fu + 1)
		else:
			print('-1')
	elif k == 2:
		if a_nfs(x, j, b):
			if a_nfsbv(x, j, bv):
				j += 1
				if a_ejbv(x, j, bv):
					print(fu)
				else:
					print(fu + 1)
			else:
				j += 1
				fu += 1
				bv = b - 2 * (a - f)
				if a_ejbv(x, j, bv):
					print(fu)
				else:
					print(fu + 1)
		else:
			print(-1)
	elif a_ej(x, j, b):
		if a_ejbv(x, j, bv):
			print(0)
		else:
			print(1)
	else:
		print('-1')
else:
	print('-1')


(a, b, f, k) = map(int, input().split())
p = 0
r = 0
m = b
if k == 1:
	if m < f or m < a - f:
		print(-1)
		quit()
(d1, d2) = (2 * a - f, a + f)
for _ in range(k - 1):
	if p == 0:
		if f > m:
			r = -1
			break
		if m < d1:
			r += 1
			m = b - a + f
		else:
			m -= a
		p = a
	else:
		if a - f > m:
			r = -1
		if m < d2:
			r += 1
			m = b - f
		else:
			m -= a
		p = 0
if p == 0:
	if m < f:
		r = -1
	elif m < a:
		r += 1
elif m < a - f:
	r = -1
elif m < a:
	r += 1
print(r)


(a, b, f, k) = map(int, input().split())
c = b
cnt = 0
if cnt == 0:
	for i in range(k):
		if i & 1 == 0:
			dis = a - f
		else:
			dis = f
		c -= a - dis
		if c < 0:
			cnt = -1
			break
		if i < k - 1 and c < 2 * dis:
			cnt += 1
			c = b
		if i == k - 1 and c < dis:
			cnt += 1
			c = b
		c -= dis
		if c < 0:
			cnt = -1
			break
print(cnt)


(a, b, f, k) = map(int, input().split(' '))
if k > 2 and (b < 2 * f or b < 2 * (a - f)) or (k == 1 and (b < f or b < a - f)) or (k == 2 and (b < f or b < 2 * (a - f))):
	print(-1)
else:
	state = 2
	cir = 0
	rb = b - f
	c = 0
	while cir < k:
		if state == 1:
			if cir + 1 == k:
				if rb < f:
					c += 1
				break
			else:
				if rb < 2 * f:
					rb = b
					c += 1
				rb -= 2 * f
				cir += 1
				state = 2
		elif state == 2:
			if cir + 1 == k:
				if rb < a - f:
					c += 1
				break
			else:
				if rb < 2 * (a - f):
					rb = b
					c += 1
				rb -= 2 * (a - f)
				state = 1
				cir += 1
	print(c)


(a, b, f, k) = map(int, input().split())
(r, p, s, t) = (0, b - f, 1, [2 * f, 2 * (a - f)])
if p < 0:
	r -= 1
else:
	for i in range(k - 1):
		if p < t[s]:
			p = b
			r += 1
		if p < t[s]:
			r = -1
			break
		p -= t[s]
		s = 1 - s
	if t[s] // 2 > p:
		r += 1
		if t[s] // 2 > b:
			r = -1
print(r)


(a, b, f, k) = map(int, input().split())

def distanceToFuel(pos):
	return a - f if pos else f
if f > b:
	print(-1)
else:
	total = k * a
	pos = 0
	remaining = b
	refuel = 0
	while total > 0:
		remaining -= distanceToFuel(pos)
		total -= distanceToFuel(pos)
		if k == 1:
			if distanceToFuel(pos ^ 1) > b:
				refuel = -1
				break
			elif remaining < distanceToFuel(pos ^ 1):
				refuel = 1
				break
			else:
				refuel = 0
				break
		if total == distanceToFuel(pos ^ 1):
			if remaining >= distanceToFuel(pos ^ 1):
				break
			else:
				refuel += 1
				break
		elif 2 * distanceToFuel(pos ^ 1) > remaining:
			if 2 * distanceToFuel(pos ^ 1) > b:
				refuel = -1
				break
			remaining = b
			refuel += 1
		pos ^= 1
		total -= distanceToFuel(pos)
		remaining -= distanceToFuel(pos)
	print(refuel)


import sys
(a, v, f, k) = map(int, input().split())
st_v = v
s1 = f
s2 = a - f
res = 0
for i in range(2 * k):
	if i % 2 == 0:
		if i % 4 == 0:
			v -= s1
			if v < 0:
				print(-1)
				sys.exit()
			if i != 2 * k - 2:
				if v < 2 * s2:
					v = st_v
					res += 1
			elif v < s2:
				v = st_v
				res += 1
		else:
			v -= s2
			if v < 0:
				print(-1)
				sys.exit()
			if i != 2 * k - 2:
				if v < 2 * s1:
					v = st_v
					res += 1
			elif v < s1:
				v = st_v
				res += 1
	else:
		if (i - 1) % 4 == 0:
			v -= s2
		elif (i - 1) % 4 == 2:
			v -= s1
		if v < 0:
			print(-1)
			sys.exit()
print(res)


(a, b, f, k) = input().split()
a = int(a)
b = int(b)
f = int(f)
k = int(k)
i = 0
j = 1
fill = 0
store = b
direct = 1
while j <= k:
	if i == 0:
		n = f
		direct = 1
		if j > 1:
			store -= abs(f)
	elif i == a:
		n = f
		direct = 0
		store -= abs(f - a)
	elif direct == 0:
		n = 0
		store -= abs(f - a)
	else:
		n = a
		store -= abs(f)
	if store < 0:
		fill = -1
		break
	if i == f:
		if store < 2 * abs(n - i) and j < k:
			fill += 1
			store = b
		elif store < abs(n - i) and j == k:
			fill += 1
			store = b
		if b < abs(n - i):
			fill = -1
			break
	if n == 0 or n == a:
		j += 1
	i = n
print(fill)


def main():
	(a, b, f, k) = input().split(' ')
	endpoint = int(a)
	capacity = int(b)
	station = int(f)
	journeys = int(k)
	print(betterBus(endpoint, capacity, station, journeys))

def bus(endpoint, capacity, station, journeys):
	refuels = 0
	current = capacity
	to = True
	for j in range(journeys):
		r = range(endpoint)
		if not to:
			r = range(endpoint, 0, -1)
			to = True
		else:
			to = False
		for e in r:
			if e == station:
				if j == journeys - 1:
					if current - e < 0:
						current = capacity
						refuels += 1
				elif current - (endpoint - station) * 2 < 0:
					current = capacity
					refuels += 1
			elif current == 0:
				return -1
			current -= 1
	return refuels

def betterBus(endpoint, capacity, station, journeys):
	refuels = 0
	current = capacity
	to = True
	for j in range(journeys):
		if to:
			current -= station
			if current < 0:
				return -1
			if j == journeys - 1:
				if current - (endpoint - station) < 0:
					current = capacity
					if current - (endpoint - station) < 0:
						return -1
					refuels += 1
			elif current - (endpoint - station) * 2 < 0:
				current = capacity
				refuels += 1
			current -= endpoint - station
			to = False
		else:
			current -= endpoint - station
			if current < 0:
				return -1
			if j == journeys - 1:
				if current - station < 0:
					current = capacity
					if current - station < 0:
						return -1
					refuels += 1
			elif current - station * 2 < 0:
				current = capacity
				refuels += 1
			current -= station
			to = True
	return refuels
main()


(a, b, f, k) = map(int, input().split())
x = 0
g = b
for kk in range(k - 1):
	if kk % 2 == 0:
		d = a + (a - f)
		if g < d:
			if g < f:
				x = -1
				break
			x += 1
			g = b - (a - f)
			if g < 0:
				x = -1
				break
		else:
			g -= a
	else:
		d = a + f
		if g < d:
			if g < a - f:
				x = -1
				break
			x += 1
			g = b - f
			if g < 0:
				x = -1
				break
		else:
			g -= a
if (k - 1) % 2 == 0:
	if g < a:
		if g < f:
			x = -1
		else:
			x += 1
			g = b - (a - f)
			if g < 0:
				x = -1
elif g < a:
	if g < a - f:
		x = -1
	else:
		x += 1
		g = b - f
		if g < 0:
			x = -1
print(x)


a = 0
b = 0
f = 0
k = 0

def get_user_input():
	global a
	global b
	global f
	global k
	interval_info = input('').split()
	a = int(interval_info[0])
	b = int(interval_info[1])
	f = int(interval_info[2])
	k = int(interval_info[3])

def calc():
	global b
	m = 0
	count = 0
	B = b
	if B < a - f or B < f:
		return -1
	while m + 1 < k:
		if m % 2 == 0 and b < a + (a - f):
			count += 1
			m += 1
			b = B - (a - f)
			if b < a - f:
				return -1
		elif m % 2 != 0 and b < a + f:
			count += 1
			m += 1
			b = B - f
			if b < f:
				return -1
		else:
			m += 1
			b = b - a
	if b - a < 0:
		count += 1
	return count
get_user_input()
print(calc())


import sys
(a, b, f, k) = map(int, input().split())
l1 = 2 * (a - f)
l2 = 2 * f
t = b
cnt = 0
r = True
if t >= f:
	t -= f
	for i in range(k - 1):
		if r:
			if t >= l1:
				t -= l1
				r = False
			elif b >= l1:
				cnt += 1
				t = b - l1
				r = False
			else:
				print(-1)
				sys.exit()
		elif t >= l2:
			t -= l2
			r = True
		elif b >= l2:
			cnt += 1
			t = b - l2
			r = True
		else:
			print(-1)
			sys.exit()
	if k % 2 == 1:
		if t >= a - f:
			print(cnt)
		elif b >= a - f:
			print(cnt + 1)
		else:
			print(-1)
	elif t >= f:
		print(cnt)
	elif b >= f:
		print(cnt + 1)
	else:
		print(-1)
else:
	print(-1)


(a, b, f, k) = map(lambda x: int(x), input().split())
if b < f:
	print(-1)
	exit()
cnt = 0
t = b - f
g = f = a - f
for i in range(k):
	if t < 0:
		break
	if k - i - 1:
		g += f
	if t < g:
		cnt += 1
		t = b
	t -= g
	g = f = a - f
print(-1 if t < 0 else cnt)


(a, b, f, k) = tuple(map(int, input().split()))
d1 = f - 0
d2 = a - f

def sim():
	x = b
	c = 0
	for i in range(1, k + 1, 2):
		if x < d1:
			return -1
		x -= d1
		if x < d2 or (i < k and x < 2 * d2):
			x = b
			c += 1
		if x < d2:
			return -1
		x -= d2
		if i == k:
			break
		if x < d2:
			return -1
		x -= d2
		if x < d1 or (i + 1 < k and x < 2 * d1):
			x = b
			c += 1
		if x < d1:
			return -1
		x -= d1
	return c
print(sim())


info = [int(num) for num in input().split()]
a = info[0]
b = info[1]
f = info[2]
k = info[3]
gas_spots = [a * i + (f if i % 2 == 0 else a - f) for i in range(k)]
gas_spots.append(k * a)
curr_x = 0
curr_gas = b
result = 0
for spot in gas_spots:
	to_travel = spot - curr_x
	if to_travel > b:
		print(-1)
		break
	elif to_travel > curr_gas:
		result += 1
		curr_gas = b
	curr_gas -= to_travel
	curr_x = spot
else:
	print(result)


(a, b, f, k) = [int(x) for x in input().split()]
oil = b
num = 0
oil -= f
if b < f or b < a - f or (b < 2 * (a - f) and k >= 2) or (b < 2 * f and k >= 3):
	print(-1)
else:
	for i in range(1, k):
		if i % 2 == 1:
			if oil >= 2 * (a - f):
				oil -= 2 * (a - f)
			else:
				oil = b
				num += 1
				oil -= 2 * (a - f)
		elif oil >= 2 * f:
			oil -= 2 * f
		else:
			oil = b
			num += 1
			oil -= 2 * f
	if k % 2 == 1:
		if oil < a - f:
			num += 1
	elif oil < f:
		num += 1
	print(num)


def find_refuels(a, b, f, k):
	if b < f or b < a - f:
		return -1
	if b < 2 * (a - f) and k > 1:
		return -1
	if b < 2 * f and k > 2:
		return -1
	curr_fuel = b - f
	refuel_count = 0
	remaining_trips = k
	while remaining_trips:
		remaining_trips -= 1
		if curr_fuel < 2 * (a - f) and remaining_trips or (curr_fuel < a - f and (not remaining_trips)):
			refuel_count += 1
			curr_fuel = b
		curr_fuel -= 2 * (a - f)
		if not remaining_trips:
			break
		remaining_trips -= 1
		if curr_fuel < 2 * f and remaining_trips or (curr_fuel < f and (not remaining_trips)):
			refuel_count += 1
			curr_fuel = b
		curr_fuel -= 2 * f
	return refuel_count
(a, b, f, k) = [int(x) for x in input().strip().split()]
print(find_refuels(a, b, f, k))


(a, b, f, k) = map(int, input().split())
tf = a - f
gas = b - f
if gas < 0:
	print(-1)
	exit()
ans = 0
for i in range(k):
	if i % 2 == 0:
		if i == k - 1:
			if gas < tf:
				gas = b
				ans += 1
		elif gas < tf * 2:
			gas = b
			ans += 1
		if i == k - 1:
			gas -= tf
		else:
			gas -= tf * 2
		if gas < 0:
			print(-1)
			exit()
	else:
		if i == k - 1:
			if gas < f:
				gas = b
				ans += 1
		elif gas < f * 2:
			gas = b
			ans += 1
		if i == k - 1:
			gas -= f
		else:
			gas -= f * 2
		if gas < 0:
			print(-1)
			exit()
print(ans)


from sys import stdin, stdout
(a, b, f, k) = map(int, stdin.readline().split())
(ans, position) = (0, 0)
current = b
label = 1
for i in range(k):
	if not position:
		distance = a + a - f
		curd = a - f
		last = a
		oil = f
	else:
		distance = a + f
		curd = f
		last = 0
		oil = a - f
	if distance <= current or (a <= current and i == k - 1):
		current -= a
	elif oil <= current:
		ans += 1
		current = b - curd
	else:
		current = -1
	position = last
	if current < 0:
		label = 0
if not label:
	stdout.write('-1')
else:
	stdout.write(str(ans))


(a, b, f, k) = map(int, input().split())
if b < f or b < a - f:
	print(-1)
	exit()
com = b // a
ca = b % a
poi = com % 2
ans = 0
t = 0
while com < k:
	t += 1
	if poi == 0:
		if ca < f:
			ca = b - f
			ans += 1
		else:
			ca = b - a + f
			ans += 1
			com += 1
	elif ca < a - f:
		ca = b - a + f
		ans += 1
	else:
		ca = b - f
		ans += 1
		com += 1
	com += ca // a
	ca = ca % a
	poi = com % 2
	if t > 1000000:
		print(-1)
		exit()
print(ans)


inp = input().split(' ')
a = int(inp[0])
b = int(inp[1])
f = int(inp[2])
k = int(inp[3])
b_temp = b
i = 0
doz = 0
if k > 2 and b < 2 * f or (k > 1 and b < 2 * (a - f)):
	print(-1)
else:
	while i < k:
		if k == 1 and max(f, a - f) > b:
			print(-1)
			break
		else:
			b = b - f
			if k - i == 1:
				if b < a - f:
					doz = doz + 1
					i = i + 1
					b = b_temp
					b = b - (a - f)
				elif b == a - f:
					i = i + 1
					b = b - (a - f)
				elif b < 2 * (a - f) and b >= a - f:
					i = i + 1
					b = b_temp
					b = b - (a - f)
				elif b >= 2 * (a - f):
					b = b - (a - f)
					i = i + 1
			elif b < 2 * (a - f):
				doz = doz + 1
				i = i + 1
				b = b_temp
				b = b - (a - f)
			elif b >= 2 * (a - f):
				b = b - (a - f)
				i = i + 1
			if i == k:
				print(doz)
				break
			b = b - (a - f)
		if k - i == 1:
			if b < f:
				doz = doz + 1
				i = i + 1
				b = b_temp
				b = b - f
			elif b == f:
				i = i + 1
				b = b - f
			elif b < 2 * f and b >= f:
				i = i + 1
				b = b_temp
				b = b - f
			elif b >= 2 * f:
				b = b - f
				i = i + 1
		elif b < 2 * f:
			doz = doz + 1
			i = i + 1
			b = b_temp
			b = b - f
		elif b >= 2 * f:
			b = b - f
			i = i + 1
		if i == k:
			print(doz)


(a, b, f, k) = map(int, input().split())
if max(2 * f, 2 * (a - f)) > b and k > 2:
	print('-1')
elif k == 1 and max(f, a - f) > b:
	print('-1')
elif k == 2 and (b < 2 * (a - f) or b < f):
	print('-1')
else:
	m = b
	dir = 1
	l = 0
	pos = 1
	x = 0
	while l < k:
		if pos == 1 and m >= f and (dir == 1):
			m -= f
			dir = 1
			pos = 2
		elif pos == 2 and dir == 1:
			if k - l > 1 and m >= 2 * (a - f):
				dir = 2
				pos = 2
				l += 1
				m -= 2 * (a - f)
			elif k - l == 1 and m >= a - f:
				l += 1
			else:
				m = b
				x += 1
		elif pos == 2 and dir == 2:
			if k - l > 1 and m >= 2 * f:
				dir = 1
				pos = 2
				l += 1
				m -= 2 * f
			elif k - l == 1 and m >= f:
				l += 1
			else:
				m = b
				x += 1
	print(x)


DEBUG = False

def cover_distance():
	(a, b, f, k) = map(int, input().split())
	fuel = b
	add_fuel_count = 0
	fuel_on_next_stop = fuel - f
	if fuel_on_next_stop < 0:
		return -1
	distance_to_destination = 0
	distance_to_gas_station = 0
	for i in range(1, k + 1):
		if DEBUG:
			print('i= {} : '.format(i))
			print('\t fuel_on_station = {} '.format(fuel_on_next_stop))
		if i == k:
			if i % 2:
				distance_to_destination = a - f
			else:
				distance_to_destination = f
			fuel = fuel_on_next_stop
			if fuel < distance_to_destination:
				fuel = b
				add_fuel_count += 1
			fuel_on_next_stop = fuel - distance_to_destination
		else:
			if i % 2:
				distance_to_gas_station = 2 * (a - f)
			else:
				distance_to_gas_station = 2 * f
			fuel = fuel_on_next_stop
			if fuel < distance_to_gas_station:
				fuel = b
				add_fuel_count += 1
			fuel_on_next_stop = fuel - distance_to_gas_station
		if DEBUG:
			if distance_to_destination:
				distance = distance_to_destination
			else:
				distance = distance_to_gas_station
			print('\t distance = {} '.format(distance))
			print('\t fuel_on_next_stop = {} '.format(fuel_on_next_stop))
			if fuel == b:
				print('\t YES')
		if fuel_on_next_stop < 0:
			return -1
	return add_fuel_count
print(cover_distance())


import os
import sys
import re
if 'PYCHARM' in os.environ:
	sys.stdin = open('in', 'r')
(a, b, f, k) = map(int, input().split())
x = b
ans = 0

def go(l):
	if l > b:
		print(-1)
		sys.exit(0)
	global ans, x
	if x < l:
		ans += 1
		x = b
	x -= l
go(f)
fw = True
for i in range(k - 1):
	go(2 * (a - f if fw else f))
	fw = not fw
go(a - f if fw else f)
print(ans)


(a, b, f, k) = [int(i) for i in input().split()]
if k >= 3:
	if f > b or 2 * f > b or 2 * (a - f) > b:
		print(-1)
	else:
		fuel = 0
		fwd = 1
		rem = b - f
		while k != 1:
			if fwd == 1:
				if rem >= 2 * (a - f):
					rem = rem - 2 * (a - f)
				else:
					rem = b - 2 * (a - f)
					fuel += 1
				k -= 1
				fwd = 0
			else:
				if rem >= 2 * f:
					rem = rem - 2 * f
				else:
					rem = b - 2 * f
					fuel += 1
				k -= 1
				fwd = 1
		if fwd == 1:
			if rem >= a - f:
				print(fuel)
			else:
				print(fuel + 1)
		elif rem >= f:
			print(fuel)
		else:
			print(fuel + 1)
elif k == 1:
	if f > b or a - f > b:
		print(-1)
	elif b >= a:
		print(0)
	else:
		print(1)
elif f > b or 2 * (a - f) > b:
	print(-1)
else:
	fuel = 0
	rem = b - f
	if rem < 2 * (a - f):
		rem = b - 2 * (a - f)
		fuel += 1
	else:
		rem = rem - 2 * (a - f)
	if rem >= f:
		print(fuel)
	else:
		print(fuel + 1)