local n = io.read("*n", "*l") local s = io.read() local ret, t = 0, {} local org = false for i = 1, n - 1 do local a = s:sub(i, i) == "A" local b = s:sub(i + 1, i + 1) == "A" if a and b then ret = ret + 1 elseif a then t[i] = true elseif b then t[i + 1] = true else org = true end end if org then ret = ret + 1 end for k, v in pairs(t) do ret = ret + 1 end print(ret)