#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespac e std;

char s[2001],t[2001];
int dp[2001][2001][2];//s?????????i,t?????????j,??´??????I->0,O->1
int main() {
	int m,n;scanf("%d%d%s%s",&m,&n,s,t);
	rep(i,m+1)rep(j,n+1){
		if(i==0&&j==0)continue;
		int x=m-i,y=n-j;
		if(x<m){
			if(s[x]=='I')dp[i][j][0]=dp[i-1][j][1]+1;
			else dp[i][j][1]=dp[i-1][j][0]+1;
		}
		if(y<n){
			if(t[y]=='I'){
				
			}
			else{
				
			}
		}
	}
}