how many openings you should know for both black and white piece?


At 400? 1 (e4) as White, and 2 (against e4, your choice of e5/c5 and against d4, your choice of d5/Nf6) as Black. No. There are no titled players, let alone GMs, who only play one opening as each color.
You need 2 defenses for black: against 1 e4 and 1 d4 and 1 opening for white.
Fischer and Kasparov played:
Sicilian Najdorf Variation and King's Indian Defense as black, and Ruy Lopez as white.

No There is no GM who use only 2 openings , yes but there are expert level players who have very limited repertoire, one such expert whom I knew played the petroff defence e4 e5 Nf3 Nf6 against e4 and played the nimzo Indian / Queen's Indian against d4 and as white only played the English opening , he was a very solid player and extremely difficult to beat because he had developed great expertise in the few limited openings that he played
@4
"There is no GM who use only 2 openings"
++ Last time I checked Fischer and Kasparov were GM.
After 1.e4 or 1.d4 there are about 6 major defenses you should be ready for.
For example after 1.e4 you should know at least a little about the Spanish, Sicilian, French, Caro, Pirc, Alekhine, and Scandanavian. After 1.d4 maybe something like queen's gambit accepted, queen's gambit decliend, slav, king's indian, queen's indian, Grunfeld, and Dutch.
Ok I guess that's 7 each.
And then for each of those, the most popular ones have at least 4 main variations, sometimes many more.
But as a beginner, maybe just start with 1. Start with the first 5 moves after 1.e4 e5 or 1.d4 d5. Other than that mainly focus on developing quickly and castling. Then as you get better try to learn the first 5 moves of the main lines in each of the 7 things I listed (depending on if you play 1.e4 or 1.d4). That shouldn't be too hard.
Of course many times your opponents wont play the moves you've memorized, and so you'll have to rely on general principles, which is fine. You don't need to study openings unless your opponents are playing them and you're getting a worse position... but yeah, I think it'd be fine to start with memorizing 5 moves for 7 main openings. You can slowly add to that as needed.
Learn really well one opening for e4 and one for d4 for Black. For White learn one line for each major defence. This will take you 2-3 years. After that, feel free to revisit whether you need more openings.
for white. you control the game, have a main (for me nf3) and a secondary or two if your opponent has been beating your main, (for me b4 and g3.) as black, you need to have one response for all 20 first moves. here is my checklist: did they play e4, or g4? if no, they i go nf6. if they went e4, or g4. i play e5, and d5 respectively. the reason this works, is because the only 2 moves that prevent nf6, are e4 and g4. everything else is fair game, and will most likely lead into a semi slav or some queens pawn postion.

indeed. @ post #7~i think you misunderstood the question & context (?!) As White, Bobby Fischer played 1. e4 ("Best by Test") and Garry Kasparov mainly played 1. d4. As Black, Fischer mainly played the Sicilian; notedly the Sicilian Najdorf & King's Indian Defence as the Main (vs 1. d4) although he did dabble in QGD Ragozin & Grunfeld (on special occasions). Kasparov, however initially used the CK but transitioned into the Scheveningen Sicilian (sometimes transposed from the Najdorf) and was a virtuoso in the KID as well. Your chart did not really reflect the context accurately. Yes, their opening prep overlaps into other openings but that's not the point of the discussion. It's about their Repertoire: their Life long Two Defenses they Ultimately used to reach the Pinnacle of Success.
indeed. @ post #7~i think you misunderstood the question & context (?!) As White, Bobby Fischer played 1. e4 ("Best by Test") and Garry Kasparov mainly played 1. d4. As Black, Fischer mainly played the Sicilian; notedly the Sicilian Najdorf & King's Indian Defence as the Main (vs 1. d4) although he did dabble in QGD Ragozin & Grunfeld (on special occasions). Kasparov, however initially used the CK but transitioned into the Scheveningen Sicilian (sometimes transposed from the Najdorf) and was a virtuoso in the KID as well. Your chart did not really reflect the context accurately. Yes, their opening prep overlaps into other openings but that's not the point of the discussion. It's about their Repertoire: their Life long Two Defenses they Ultimately used to reach the Pinnacle of Success.
Sure Fischer played 1.e4, but 1.e4 isn't an opening so...?
OP's question doesn't make any sense to me, so I probably don't understand the context, that's true. Professional players are like living encyclopedias of chess, they know thousands of detailed opening lines... plus you can't "only use 2 openings" since you can't control what your opponent plays. It's the type of question someone asks if they don't know how to play chess.
@7
The data only support what I said.
Fischer: 125 + 83 = 208 Sicilian Najdorf, 117 King's Indian Defense, 128 + 79 = 207 Ruy Lopez.
Kasparov: 349 + 112 + 78 = 539 Sicilian Najdorf, 158 King's Indian Defense, 102 Ruy Lopez.
Fischer played the same 3 openings from the very start of his career.
Kasparov originally played different openings, but then converged to the same 3.
Occasionally they deviated in matches.
Another example in the modern engine era: Maxime Vachier-Lagrave:
Sicilian Najdorf and Grünfeld Indian Defense as black, Ruy Lopez as white.

Ideally, you want to have a repertoire that consists of one white opening, an e4 defense, and a d4 defense (at the minimum).
As you get more experience, though, you'll probably explore other openings and your repertoire may expand.
Many GMs have a "core" repertoire that they stick to, but most are generally familiar with all the main openings and defenses, and will vary their opening choices depending on their mood, on their opponent, or on the importance of the game itself ...
@15
Match tactics made Fischer play unexpected openings (Alekhine, Pirc, English) against Spassky, as Spassky was a natural player, but had been force-fed theory by Geller et. al.
Fischer played the same 3 openings Najdorf, King's Indian Defense, Ruy Lopez throughout his whole career, with very few occasional exceptions for surprise value.
Kasparov originally played 3 different openings (Caro-Kann, Tarrasch, Queen's Indian Defense), but later converged to the same 3: Najdorf, King's Indian Defense, Ruy lopez.
Look at the numbers @7.
Of the modern players Carlsen plays everything.
Maxime Vachier-Lagrave plays only 3: Najdorf, Grünfeld, Ruy Lopez.
@4
"There is no GM who use only 2 openings"
++ Last time I checked Fischer and Kasparov were GM.
When Kasparov played the Caro Kann (and occasionally the Sheveningen) plus the Benoni as Black in his youth, he was still named Weinstein. But this does not make your false statement more valid.
And Fischer played a lot of different openings against, say, Spassky.
Fischer played vs the d4 KID, Grunfeld, Tartakower QGD, semi-Tarrash QGD, Ragozin, Nimzo, Benoni even Benko, QGA. For 1.e4 Najdorf , Alekhine, Pirc.
That's a rather broad repertoire, he played more or less anything that strived for dynamic equality, some more than others of course.
The reputation of having narrow repertoire is unfair and coming mostly from his very junior years.
As a coach what is your view for non pros and repertoire breadth ? Most of us don't have (and will never have) Fischer's talent, ambitions, chess knowledge, time devoted to the game etc, so spreading out too much means risking becoming jacks of all trades. I've been sticking my guns to 1 response for d4 and one for d4, I may play lots of variations within those responses but don't deviate the main response, with near religious dedication. Not so much because Botvinnik said so 70 years ago but that's how our brains acquire knowledge, by repetition and non-pros can only become experts in a finite amount of positions.
A narrow repertoire means that most middlegames we see will be System I work, while a wide repertoire will include a lot of System II, as it's unlikely we'll be able to play learn well all critical positions from the repertoire if it's broad.
@15
Match tactics made Fischer play unexpected openings (Alekhine, Pirc, English) against Spassky, as Spassky was a natural player, but had been force-fed theory by Geller et. al.
Fischer played the same 3 openings Najdorf, King's Indian Defense, Ruy Lopez throughout his whole career, with very few occasional exceptions for surprise value.
Kasparov originally played 3 different openings (Caro-Kann, Tarrasch, Queen's Indian Defense), but later converged to the same 3: Najdorf, King's Indian Defense, Ruy lopez.
Look at the numbers @7.
Of the modern players Carlsen plays everything.
Maxime Vachier-Lagrave plays only 3: Najdorf, Grünfeld, Ruy Lopez.
The mature Fischer (in chess terms) had a very wide repertoire. The fact that we didn't see the mature Fischer playing a lot is a different topic but I wouldn't mix stats from his junior period to the 70-72 period. He played openings he used to call lemons as a teenager, so his views and attitude towards his openings had clearly changed.
@17
"Fischer played vs the d4 KID" ++ Mainly: 117 games,
"Nimzo" ++ Sometimes: 23 games
"Grunfeld" ++ Sometimes: 20 games
Tartakower QGD, semi-Tarrash QGD 9, Ragozin, Benoni 8 even Benko, QGA ++ Rarely
"For 1.e4 Najdorf" ++ almost exclusively: 211 Games
"Alekhine" ++ Only 7 games
"Pirc" ++ Only 1 game as a complete surprise as match tactic.
"That's a rather broad repertoire" ++ No, it was narrow
"The reputation of having narrow repertoire" ++ is justified
"what is your view for non pros and repertoire breadth?"
++ Amateurs should play as narrow a repertoire as possible
Better know something about something than nothing about everything.
@18
"The mature Fischer (in chess terms) had a very wide repertoire." ++ No, it was narrow.
"we didn't see the mature Fischer playing a lot" ++ In his 1992 rematch against Spassky he also played his 3: Sicilian, King's Indian Defense, Ruy Lopez.
"his views and attitude towards his openings had clearly changed" ++ No, he stayed true to himself as always. For example he never even once opened 1 d4 'on principle'. Against Spassky he played d4 openings for match tactics, but true to himself via transposition 1 c4.
He struggled against 1 d4. He loved his King's Indian Defense, but he felt not really confident in it and then played Grünfeld (against Botvinnik), or Nimzo, or semi-Tarrasch.
He also struggled as white against the Caro-Kann, and he tried the Panov, the 2 Knights,
the Classical, and ultimately the Exchange Variation.
@18
"The mature Fischer (in chess terms) had a very wide repertoire." ++ No, it was narrow.
"we didn't see the mature Fischer playing a lot" ++ In his 1992 rematch against Spassky he also played his 3: Sicilian, King's Indian Defense, Ruy Lopez.
"his views and attitude towards his openings had clearly changed" ++ No, he stayed true to himself as always. For example he never even once opened 1 d4 'on principle'. Against Spassky he played d4 openings for match tactics, but true to himself via transposition 1 c4.
He struggled against 1 d4. He loved his King's Indian Defense, but he felt not really confident in it and then played Grünfeld (against Botvinnik), or Nimzo, or semi-Tarrasch.
He also struggled as white against the Caro-Kann, and he tried the Panov, the 2 Knights,
the Classical, and ultimately the Exchange Variation.
in '92 vs d4, which Spassky played more often, he played KID, QGA, Benko. His repertoire was broad.
vs e4 he played the Sicilian, though we don't know which open Sicilians he had prepared as Spassky didn't play the open. Here we can't assess the broadness, as we don't know which Sicilians he had prepared.
Also, in 1992 he wasn't at his peak anymore, peak Fischer we only saw a little.
The fact that while he loved his King's Indian, he also played a bunch of other stuff shows that he was versatile.
He was clearly an 1.e4 player though interestingly (according to Spassky, they were friends & talked) in his later years he told Spassky that he concluded in the end that 1.d4 is better, even though he never played it, so if we are to believe Spassky, he must have changed his view on this at a time later than his last recorded game. His insistence on 1.e4 was probably the only narrowness in his repertoire though in his mature years, though he was also happy with 1.c4 ( he had tried 1.b3 vs Ulf Andersson as well).
In his mature years, Fischer really was versatile and played a lot of openings.