#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 47;
const int maxN = 50;
int dp[maxN][maxN][3];
int main()
{
int n;
cin >> n;
for (int l = 0; l < n; l++)
{
for (int r = 0; r < n; r++)
{
for (int x = 0; x < 3; x++)
{
dp[l][r][x] = INF;
}
}
}
vector<string> a(2);
for (int i = 0; i < 2; i++)
{
cin >> a[i];
for (int j = 0; j < n; j++)
{
if (a[i][j] == 'R')
{
dp[j][j][i] = 0;
}
}
}
for (int l = n - 1; l >= 0; l--)
{
for (int r = l; r < n; r++)
{
for (int x = 0; x < 3; x++)
{
if (l != r)
{
dp[l][r][x] = min(dp[l][r][x], dp[l + 1][r][x] + 1);
dp[l][r][x] = min(dp[l][r][x], dp[l][r - 1][x] + 1);
}
for (int m = l; m < r; m++)
{
dp[l][r][x] = min(dp[l][r][x], dp[l][m][x] + dp[m + 1][r][x]);
}
}
dp[l][r][2] = min(dp[l][r][2], dp[l][r][0] + dp[l][r][1]);
dp[l][r][2] = min(dp[l][r][2], dp[l][r][0] + 1);
dp[l][r][2] = min(dp[l][r][2], dp[l][r][1] + 1);
dp[l][r][0] = min(dp[l][r][0], dp[l][r][2]);
dp[l][r][1] = min(dp[l][r][1], dp[l][r][2]);
}
}
cout << dp[0][n - 1][2] << "\n";
return 0;
}