Connecting an arduino uno to an arduino due
if(Serial.available())
{
 if (b == Serial.available())
{
 while(Serial.available())
 {


I think you may be getting your knickers in a twist there.

... Is serial available? Yes. Is serial available? Still yes! But yes doesn't equal '$'!!!... WHAT?!

You really really need to rethink your understanding of serial communication.

Read this: http://hacking.majenko.co.uk/reading-serial-on-the-arduino