Define roll-up summary fields on the object that is on the master side of a master-detail relationship. If a relationship does not already exist, first create a master-detail relationship between the master object that displays the value and the detail object containing the records you are summarizing.
When Roll-Up Summary is grey out that means you cannot create this type of field on this object because it is not the master in a master-detail relationship.
Setup > Customize > Accounts > Fields
Account Custom Field & Relationships > New (Create new roll up summary field)
Select (Roll-Up Summary) > Next
Enter the details
Field Label: (Mandatory Field)
Field Name: (Auto Populates and Mandatory Field)
Select the object on the detail side of a master-detail relationship. This object contains the records you want to summarize.
Summarized Object: Opportunities
Count: Total the number of related records.
Sum: Totals the values in the field you select in the Field to Aggregate option. Only number, currency, and percent fields are available.
Min: Displays the lowest value of the field you select. Only number, currency, percent, date, and date/time fields are available.
Max: Displays the highest value of the field you select. Only number, currency, percent, date, and date/time fields are available.
Select Roll-Up Type > Count
Filter Criteria > All records should be included in the calculation > Next
Select the profiles to which you want to grant access to this field via field level security> Next
Select the page layout you want to add this field and then save.
Roll-Up field created
On account detail page you can see Roll Up Summary field “Count Opportunity” counting the number of opportunities associated to that account.