#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define fast_in_out  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ln "\n"
#define sc scanf
#define pr printf

const double EPS = (double) 1e-9;
const double pii = acos(-1);
const int mod = 1000000007;
const int N = (int) 1e5;
ll arr[N + 1];

void prefixSum()
{
    for(int i = 1; i <= N; i++)
    {
        arr[i] += arr[i - 1];
    }
}

int main()
{
    fast_in_out;
    map <char, int> mp;
    char ch = 'a';
    int num = 1;
    while(ch <= 'z')
    {
        mp.insert({ch, num});
        ch++;
        num++;
    }
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    for(int i = 0; i < n; i++)
    {
        arr[i] = mp[s[i]];
    }
    prefixSum();
    for(int i = 0; i < q; i++)
    {
        int l, r;
        cin >> l >> r;
        l--;
        r--;
        ll ans = arr[r];
        if(l)
        {
            ans -= arr[l - 1];
        }
        cout << ans << ln;
    }
}
