#include <bits/stdc++.h>   using namespace std;   char _;   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   long long fpow(long long b, long long exp, long long mod) {     if (exp == 0) return 1;     long long t = fpow(b, exp / 2, mod);     if (exp & 1) return t * t % mod * b % mod;     return t * t % mod;   }   int num_boxes, req, start, vals[55], dp[55][2005];   char type[55];   int solve(int box, int sum) {     if (sum >= req) return 0;     if (dp[box][sum] != -1) return dp[box][sum];     int res = INT_MAX;     for (int i = 1; i <= num_boxes; i++)       if (vals[i] > vals[box] && type[i] != type[box])         if (solve(i, sum + vals[i]) != INT_MAX)           res = min(res, abs(i - box) + solve(i, sum + vals[i]));     return dp[box][sum] = res;   }   int main() {     scanf( %d %d %d , &num_boxes, &start, &req);     for (int i = 1; i <= num_boxes; i++) scanf(  %d , &vals[i]);     for (int i = 1; i <= num_boxes; i++) scanf(  %c , &type[i]);     memset(dp, -1, sizeof dp);     int res = solve(start, vals[start]);     for (int i = 1; i <= num_boxes; i++)       if (solve(i, vals[i]) != INT_MAX)         res = min(res, abs(i - start) + solve(i, vals[i]));     printf( %d n , (res == INT_MAX ? -1 : res));   }   