import java.util.*
import kotlin.math.max
fun main() {
val br = System.`in`.bufferedReader()
val bw = System.out.bufferedWriter()
val n = br.readLine().toInt()
val lines = mutableListOf<Pair<Int, Int>>()
for (i in 0 until n) {
var (h, o) = br.readLine().split(" ").map { it.toInt() }
if (h > o) {
val temp = h
h = o
o = temp
}
lines.add(Pair(h, o))
}
lines.sortBy { it.second }
val d = br.readLine().toInt()
var answer = 0
val pq = PriorityQueue<Int>(compareBy { it })
for (i in 0 until n) {
pq.add(lines[i].first)
while (pq.isNotEmpty() && pq.peek() < (lines[i].second - d)) pq.poll()
answer = max(answer, pq.size)
}
bw.write("$answer")
br.close()
bw.close()
}
O(n * logn)