How to calculate number of all atoms in rings in a molecule?

Is there a way or a formula to find number of all atoms in all rings?  

EDIT : I wanna explain it with pictures : [![Anthracene with hydrogens](https://i.stack.imgur.com/QwxEO.png)](https://i.stack.imgur.com/QwxEO.png)


this is an anthracene which have 14 atoms in ring.
what thing it has that is 14?  

2nd EDIT:  

i have number of atoms bonds rings carbon atoms oxygen atoms and ... the connections.I want a formula with these things also i want it to work for no ring molecules like C2H4.




That 'thing that has 14' is the *Smallest Set of Smallest Rings*, or SSSR. Calculating the SSSR is a perennial problem in cheminformatics. Treatises have been written about this subject.


Many ring perception algorithms have been devised, and they are too numerous to list here.


I would start with this paper:


Downs, G. M., Gillet, V. J., Holliday, J. D., & Lynch, M. F. (1989). *Review of ring perception algorithms for chemical graphs*. *AUGUST*. https://doi.org/10.1021/ci00063a007
which gives an introduction to the subject. As it's an old paper, you could then move onto:


May, J. W., & Steinbeck, C. (2014). Efficient ring perception for the Chemistry Development Kit. *Journal of Cheminformatics*, *6*(1), 1–12. https://doi.org/10.1186/1758-2946-6-3
which then describes some more modern approaches to the problem.
**EDIT**


'i have number of atoms bonds rings carbon atoms oxygen atoms and ... the connections.I want a formula with these things also i want it to work for no ring molecules like C2H4.'


You're not asking much, are you?!
What you are talking about, in essence, is *cheminformatics*. Representing chemical structures using computers.


It's a well established and very significant discipline.
I'd start with this book:
[https://www.amazon.com/Introduction-Chemoinformatics-Andrew-R-Leach/dp/1402013477](https://rads.stackoverflow.com/amzn/click/com/1402013477)


It's a really good introduction to the discipline.


 2