Simple treasure hunter
Variable names
Variables such as a, b, c, d are meaningless.  Use names with meaning such as position, numChests, chestValues, etc.  Sure, this is just a small program with 8 total variables, but you should get in the habit of producing readable code and not just correct code.
Bug
You don't allocate enough space for your string here:

char *d = malloc(a * sizeof(char));
scanf(&quot;%s&quot;, d);


Suppose a had value 5, as in the example.  The string &quot;TVTTT&quot; has 5 characters plus a terminating null character, for a total of 6 characters.  So you need to allocate an extra byte for the null character when you call malloc().
Also, it is unsafe to just call scanf() because if the input string happened to be wrong and contain more than 5 characters, you would overflow your buffer.  To be safe, you can use fgets(), which limits the number of characters it writes to your buffer:
char *chestValues = malloc(numChests+1);
fgets(chestValues, numChests+1, stdin);

Note also that sizeof(char) is always equal to 1, so you can omit that.
No need for second loop
You have a second loop to count the number of X in your chest array.  But you could have counted the number of chests found that were T in your first loop and then you wouldn't need the second loop at all.
Sample rewrite
Here is a rewrite of your program which fixes all of the above:
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;

int main(void)
{
    int   numChests   = 0;
    int   position    = 0;
    int   numMoves    = 0;
    int   numFound    = 0;
    char *chestValues = NULL;

    scanf(&quot;%d %d %d\n&quot;, &amp;numChests, &amp;position, &amp;numMoves);
    chestValues = malloc(numChests+1);
    fgets(chestValues, numChests+1, stdin);

    for (int i = 0; i &lt; numMoves; i++) {
        char direction = 0;
        int  distance  = 0;
        scanf(&quot; %c %d&quot;, &amp;direction, &amp;distance);
        for (int j = 0; j &lt;= distance; j++) {
            if (chestValues[position - 1] == 'T') {
                chestValues[position - 1] = 'X';
                numFound++;
            }
            position += (direction == 'E' ? 1 : -1);
        }
    }
    printf(&quot;%d\n&quot;, numFound);
    return 0;
}