Suppose that I have the set $S=\{1,2,3,4,5\}$. I will label the elements as $S_i$ where $i=1,…,5$. So, for example, $S_1=1, S_2=2$ and so on. I call $\tilde{S}^k$ Any permutation of $S$ for $k=1,…,5!$.
I want to find the number of permutations $\tilde{S}^k$ of $S$ such that
- $\tilde{S}_i \neq S_i$ for any $i$ (So, the first element must be different than 1, the second element different than 2 etc..)
- $\tilde{S}_i \neq S_j$ for any $i\neq j$, where $j$ can be either one index or a subset of the indexes $1,2,3,4,5$(For example, if $j=1$, the first element of these permutations must be 1, if $j\in \{1,2\}$ the first and second element must be 1 and 2 respectively and so on).
Is there a general approach to tackle these kind of questions?
EDIT
As someone complained about the lack of context of my question, let me make a concrete example where this problem may arise.
Let's say that we have two identical decks of 5 cards each. Each card is numbered from $1$ to $5$. We shuffle both decks and we put the first deck' cards on a row, face down. We then put the cards from the second deck, face-up, one over each of the other cards. I want to compute the following probabilities
- $p_0 = p(\text{No cards match})$
- $p_1 = p(\text{Only 1 matching})$
- $p_2 = p(\text{Only 2 matchings})$
- $p_3 = p(\text{Only 3 matchings})$
- $p_4 = p(\text{Only 4 matchings}) = p_5= p(\text{Only 5 matchings}) $
There are 5! possible permutations. Therefore, to compute $p_0$ I need to count how many rearrangements of 5 cards there are, such that the first card is not 1 AND the second card is not 2 AND the third card is not 3 and so on.
By direct counting, I know that there are 44 such permutations (see image below), therefore $p_0 = 44/5! = 11/30$.

Let's take now $p_3$. This case is simple, since the problem asks for exactly 3 matchings and, give three matchings, the other two numbers either match or not. Therefore, for each combination of 5 over 3 elements, there is only one possible permutation, and $$ p_3 = \binom{5}{3}\frac{1}{5!} = 1/12 $$
I can keep going on, but I think the question should be clear now.
The answer to this problem is easy if expressed in terms of counting derangements. The solution is simply then
$$ p_k = \binom{n}{k}\frac{!(n-k)}{n!} $$
where $!x$ is the sub-factorial.