Accessing a variable wich is in another script C#

Main.cs

public class Main : MonoBehaviour {
    public int a = new int();
    // Use this for initialization
    void Start () {
		a = 0;
	}

void Update () {
a++;
if(a>20)
{ a = 0; }

}
}

Program.cs

public class Balls : MonoBehaviour {
    public int num;
    public int s;
    // Use this for initialization
    void Start () {
        Renderer rend = GetComponent<Renderer>();

       // rend.material.shader = Shader.Find("Specular");
        num = System.Convert.ToInt32(GetComponent<SpriteRenderer>().name);
        Debug.Log(num);

        s = 0;

    }
	public int c=0;
	// Update is called once per frame
	void Update ()
    {
       c = Main.a;
        if (num == c)
        {
            GetComponent<SpriteRenderer>().color = Color.red;
        }
        else
        {
            GetComponent<SpriteRenderer>().color = Color.white;
        }
 
    }


}

I tried every way that told in forums but i take same error

Object Reference Not Set To An Instance Of An Object

Thank You for your helps…

If your Main may be something like GameManager, You can use static variable or singleton:

public class Main : MonoBehaviour {
public static Main instance = null;

void Awake() {
    if (instance == null) instance = this;
    else if (instance != this) Destroy(gameObject); 

    DontDestroyOnLoad(gameObject);
}

public int a = new int();
void Start () {
     a = 0;
     }
}

Then You can access variables in Main by:

c = Main.instance.a;

If Main is just an gameObject like any else then You need to store reference to this script in another one:

public class Balls : MonoBehaviour {
     public int num;
     public int s;
     public Main main;
...

void Update ()
{
     c = main.a;
...

Change the line public int a = new int (); to public static int a;

Because you’re not declaring an instance of Main to hold the a variable, you need to make it static.