import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()

S = input()[:-1]
po = [0 for i in range(n)]

for i in range(n-1,-1,-1):
    if i == n-1:
        if S[i] == "R":
            po[i] += 1
    else:
        if S[i] == "R":
            po[i] += po[i+1]+1
        else:
            po[i] += po[i+1]
co = 0

for i in range(n):
    if po[i] - co > 0 and S[i] != "R":
        co += 1
print(co) import sys,collections as cl,bisect as bs sys collections bisect sys.setrecursionlimit(100000) sys.setrecursionlimit sys setrecursionlimit 100000 input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline mod = 10**9+7 mod 10**9+7 10**9 10 9 7 Max = sys.maxsize Max sys.maxsize sys maxsize def l(): #intのlist
    return list(map(int,input().split())) l return list(map(int,input().split())) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split def m(): #複数文字
    return map(int,input().split()) m return map(int,input().split()) map(int,input().split()) map int input().split() ().split () input split def onem(): #Nとかの取得
    return int(input()) onem return int(input()) int(input()) int input() input def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a s a = [] a [] if len(x) == 0:
        return []
     len(x) == 0 len(x) len x 0 return [] [] aa = x[0] aa x[0] x 0 su = 1 su 1 for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
     i range(len(x)-1) range len(x)-1 len(x) len x 1 if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
     aa != x[i+1] aa x[i+1] x i+1 i 1 a.append([aa,su]) a.append a append [aa,su] aa su aa = x[i+1] aa x[i+1] x i+1 i 1 su = 1 su 1 su += 1 su 1 a.append([aa,su]) a.append a append [aa,su] aa su return a a x x def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x)) jo return " ".join(map(str,x)) " ".join(map(str,x)) " ".join " " join map(str,x) map str x x x def max2(x): #他のときもどうように作成可能
    return max(map(max,x)) max2 return max(map(max,x)) max(map(max,x)) max map(max,x) map max x x x def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False In k = bs.bisect_left(a,x) k bs.bisect_left(a,x) bs.bisect_left bs bisect_left a x if k != len(a) and a[k] ==  x:
        return True
    else:
        return False k != len(a) and a[k] ==  x k != len(a) k len(a) len a a[k] ==  x a[k] a k x return True True return False False x x a a def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans pow_k ans = 1 ans 1 while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
     n if n % 2:
            ans *= x
         n % 2 n 2 ans *= x ans x x *= x x x n >>= 1 n 1 return ans ans x x n n """
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
""" n = onem() n onem() onem S = input()[:-1] S input()[:-1] () input :-1 -1 0 for i in range(n) for i in range(n) i range(n) range n for i in range(n) 0 po = [0 for i in range(n)] po [0 for i in range(n)] for i in range(n-1,-1,-1):
    if i == n-1:
        if S[i] == "R":
            po[i] += 1
    else:
        if S[i] == "R":
            po[i] += po[i+1]+1
        else:
            po[i] += po[i+1] i range(n-1,-1,-1) range n-1 n 1 -1 -1 if i == n-1:
        if S[i] == "R":
            po[i] += 1
    else:
        if S[i] == "R":
            po[i] += po[i+1]+1
        else:
            po[i] += po[i+1] i == n-1 i n-1 n 1 if S[i] == "R":
            po[i] += 1
     S[i] == "R" S[i] S i "R" po[i] += 1 po[i] po i 1 if S[i] == "R":
            po[i] += po[i+1]+1
        else:
            po[i] += po[i+1] S[i] == "R" S[i] S i "R" po[i] += po[i+1]+1 po[i] po i po[i+1]+1 po[i+1] po i+1 i 1 1 po[i] += po[i+1] po[i] po i po[i+1] po i+1 i 1 co = 0 co 0 for i in range(n):
    if po[i] - co > 0 and S[i] != "R":
        co += 1 i range(n) range n if po[i] - co > 0 and S[i] != "R":
        co += 1 po[i] - co > 0 and S[i] != "R" po[i] - co > 0 po[i] - co po[i] po i co 0 S[i] != "R" S[i] S i "R" co += 1 co 1 print(co) print co def max2(x): #他のときもどうように作成可能
    return max(map(max,x)) def max2(x): #他のときもどうように作成可能
    return max(map(max,x)) max2 def onem(): #Nとかの取得
    return int(input()) def onem(): #Nとかの取得
    return int(input()) onem def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False In input = sys.stdin.readline sys.stdin.readline input def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans pow_k co = 0 0 co def m(): #複数文字
    return map(int,input().split()) def m(): #複数文字
    return map(int,input().split()) m Max = sys.maxsize sys.maxsize Max S = input()[:-1] input()[:-1] S def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a s mod = 10**9+7 10**9+7 mod def l(): #intのlist
    return list(map(int,input().split())) def l(): #intのlist
    return list(map(int,input().split())) l po = [0 for i in range(n)] [0 for i in range(n)] po def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x)) def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x)) jo n = onem() onem() n co += 1 1 co
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()

S = input()[:-1]
po = [0 for i in range(n)]

for i in range(n-1,-1,-1):
    if i == n-1:
        if S[i] == "R":
            po[i] += 1
    else:
        if S[i] == "R":
            po[i] += po[i+1]+1
        else:
            po[i] += po[i+1]
co = 0

for i in range(n):
    if po[i] - co > 0 and S[i] != "R":
        co += 1
print(co)
