#include <iostream>
#include <fstream>
#include <string>
#include <cctype>  // برای بررسی حروف
using namespace std;

int main() {
    string filename;
    string line;
    int wordCount = 0, lineCount = 0, charCount = 0;
    ifstream inputFile;

    cout << "Enter the file name (with extension): ";
    cin >> filename;

    inputFile.open(filename);

    if (!inputFile) {
        cout << "Error: Unable to open the file." << endl;
        return 1;
    }

    while (getline(inputFile, line)) {
        lineCount++;  // هر بار که یک خط خونده میشه، شمارش می‌کنیم

        for (char c : line) {
            if (isalpha(c)) {  // بررسی می‌کنیم که آیا حرف است
                charCount++;  // افزایش شمارش حروف
            }
        }

        // شمارش کلمات (با تقسیم کردن بر فاصله‌ها)
        size_t pos = 0;
        while ((pos = line.find(" ", pos)) != string::npos) {
            wordCount++;
            pos++;
        }
        if (!line.empty()) {
            wordCount++;  // آخرین کلمه بعد از آخرین فاصله
        }
    }

    inputFile.close();

    cout << "Number of lines: " << lineCount << endl;
    cout << "Number of words: " << wordCount << endl;
    cout << "Number of characters: " << charCount << endl;

    return 0;
}