#include <bits/stdc++.h>
using namespace std;
string s;
int n, a, b, ans, nr1, nr0, minD;
int main() {
  cin >> n >> a >> b;
  cin >> s;
  a--;
  b--;
  minD = (int)1e8;
  nr1 = (int)1e8;
  nr0 = (int)1e8;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == s[a]) {
      nr1 = i;
      if (abs(nr1 - nr0) < minD) minD = abs(nr1 - nr0);
    }
    if (s[i] == s[b]) {
      nr0 = i;
      if (abs(nr0 - nr1) < minD) minD = abs(nr0 - nr1);
    }
  }
  cout << minD;
  return 0;
}
