


fun main(args: Array<String>?) {
    readLine()!!.toInt()
    val str = readLine()!!
    val memo = IntArray(str.length + 1){0}
    for (i in memo.indices.reversed().drop(1)) {
        memo[i] = memo[i + 1]
        if (i + 1 in str.indices && str[i] != str[i + 1]) {
            memo[i] = java.lang.Math.max(memo[i], memo[i + 2] + 1)
        }
    }
    println(memo.first())
}
