_ = Int(readLine()!)!
let CN = Array(readLine()!)

var an: [Int] = [0]
var count = 0
for i in 0..<CN.count {
    if CN[i] == "R" {
        count += 1
    }
    an.append(count)
}

var result = CN.count
for i in 0..<an.count {
    let tmp = max(i - an[i], an[an.count-1] - an[i])
    result = min(result, tmp)
}
print(result)
