#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char a[105], b[105];
int n;
struct node
{
char data;
struct node *l, *r;
};
int max(int a, int b){return a > b ? a : b;}
struct node *build(char a[], char b[], int len)
{
if(len == 0)return NULL;
struct node *h = (struct node *)malloc(sizeof(struct node ));
h -> l = h -> r = NULL;
h -> data = a[0];
int pos;
for(pos = 0; pos < len; pos++)if(b[pos] == a[0])break;
h -> l = build(a + 1, b, pos);
h -> r = build(a + pos + 1, b + pos + 1, len - pos - 1);
return h;
};
int gethight(struct node *h)
{
if(h == NULL)return 0;
int ans = 1 + max(gethight(h -> l), gethight(h -> r));
return ans;
}
int main()
{
int ans;
while(scanf("%d", &n) != EOF)
{
scanf("%s %s", a, b);
struct node *h = build(a, b, n);
ans = gethight(h);
printf("%d\n", ans);
}
}