Range Queries on Number of elements of an array in a given range with a value Ki

Given an array of N numbers, and a number of queries where each query will contain three numbers(l, r and k). The task is to calculate the number of array elements which equal to K in the subarray[L, R].(L and R are inclusive)

I am thinking to solve it using fenwick tree and offline queries but not getting the correct method of doing? Can anyone help me? Thank you!