#include <bits/stdc++.h>

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)

using namespace std;

const int N = 1e6 + 10;

char S[N], T[N];
int n;
int delt[N];

int main(){
	scanf("%d%s%s", &n, S + 1, T + 1);

	bool flag = true;
	For(i, 1, n) if(S[i] ^ T[i]){
		flag = false;
		break;
	}
	if(flag){
		puts("0");
		return 0;
	}

	int ans = 0, cnt = 0, d = 0;
	int j = n;
	Forr(i, n, 1){
		cnt -= delt[i + d], delt[i + d] = 0;
		ans = max(ans, cnt + 1);
		
		//printf("%d %d %d\n", i, d, cnt);

		if(T[i] == T[i - 1]) continue;

		if(j > i) j = i;
		while(j && S[j] != T[i]) --j;
		if(!j){
			puts("-1");
			return 0;
		}

		++cnt, ++d;
		delt[j - 1 + d]++;
	}

	printf("%d\n", ans);
	return 0;
}
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>


/* 
*    coder :: ATUL_PANDEY_2608
*        >>> INDIA <<<
*/
using namespace std;
using namespace __gnu_pbds;

// #define  part ..
#define pb(a) push_back(a)
#define all(a) a.begin(),a.end() 
#define mod 1000000007
//#define maxx 200006
#define ll long long 
#define quick    ios_base::sync_with_stdio(NULL),cin.tie(0);
#define listll vector< long long > 
#define listi vector< int> 
#define pii   pair<int , int> 
#define pll pair<long long , long long > 
#define minheap priority_queue<long long , vector< long long >, greater<long long > >
#define rep(i,a,b) for(int i=a;i<b;i++)
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


template < class T > using oset = tree< T , null_type, less  < T  > , rb_tree_tag , tree_order_statistics_node_update > ;


// end of #define 

// define globals ...
const int maxx = 2e5+26;

//write function from here ...







int Main(){


int n =3;
ll arr[n];
for(int i=0 ; i  <n;i++)
cin>>arr[i];

sort(arr,arr+n);

int cnt  =0 ;
for(int i=0;i<=1;i++)
{
	
	if(arr[i]==arr[i+1])
	cnt++;
	
	
}

if(cnt==1)
cout<<"Yes\n";
else
cout<<"No\n";


return 0;

}






int main(){
 quick;
int t =1; 
//cin>>t;
while(t-- )
 Main();

 return 0;


}
