Our teacher, the Beit Yosef, wrote in section 3: One who prays with the congregation while it is still day—he counts with them without a blessing. And if he remembers at night—he shall bless and count. Thus far his words. And it does not mean specifically while it is still day, for if so, how does the congregation recite blessings in vain? And why should he count with them to strengthen the hands of transgressors? Furthermore: why does it say "and if he remembers"—is he not obligated to remember, since he did not fulfill his obligation at all? Rather, the intention is that it is not yet actual night, but rather bein hashemashot, when it is permitted to count then, as I have written. However, he is not accustomed to counting except at night. Therefore, he should count with them without a blessing, and intend that if he does not remember—he fulfills his obligation with this counting. And if he does remember—he does not fulfill his obligation. And a condition is effective in such a case. And this is what our teacher, the Rema, concluded, and this is his wording: And even if he answered "Amen" to the blessing of the congregation, if his intention was not to fulfill his obligation—he shall return and bless and count at night. Thus far his words, and this is according to our words. (And so it is implied in the Taz, subsection 6. And the Magen Avraham, subsection 7, labored over his words, see there. And examine carefully and you will find it simple.) And that which he wrote "if his intention was not to fulfill his obligation" is because ordinarily, since he counts with the congregation—his intention is to fulfill his obligation. And even according to the one who holds that mitzvot require intention—this is like intention, since he counts with the congregation. (See Magen Avraham, subsection 8. And in my humble opinion it appears as I have written. And examine carefully and you will find it simple.)
כתב רבינו הבית יוסף בסעיף ג: המתפלל עם הציבור מבעוד יום – מונה עמהם בלא ברכה. ואם יזכור בלילה – יברך ויספור. עד כאן לשונו. ולאו דווקא מבעוד יום, דאם כן היאך מברכין הציבור ברכות לבטלות? ולמה ימנה עמהם לחזק ידי עוברי עבירה? ועוד: למה קאמר "ואם יזכור" – הלא מחוייב לזכור, שהרי לא יצא כלל. אלא הכוונה שאין עדיין לילה ממש, אלא בין השמשות דמותר לספור אז, כמו שכתבתי. אך הוא אינו רגיל לספור אלא בלילה. ולכן יספור עמהם בלא ברכה, ויכוין שאם לא יזכור – יצא בספירה זו. ואם יזכור – לא יצא. ותנאי מועיל בכי האי גוונא. וזהו שסיים רבינו הרמ"א, וזה לשונו: ואפילו ענה "אמן" על ברכת הציבור, אם היה דעתו שלא לצאת – יחזור ויברך ויספור בלילה. עד כאן לשונו, וזהו כדברינו. (וכן משמע בט"ז סעיף קטן ו. והמגן אברהם סעיף קטן ז טרח בדבריו, עיין שם. ודייק ותמצא קל.)וזה שכתב "אם היה דעתו שלא לצאת" משום דמסתמא כיון שמונה עם הצבור – דעתו לצאת. ואפילו למאן דסבירא ליה מצוות צריכות כוונה – זהו ככוונה, כיון שמונה עם הצבור. (עיין מגן אברהם סעיף קטן ח. ולעניות דעתי נראה כמו שכתבתי. ודייק ותמצא קל.)