#include <bits/stdc++.h>
using namespace std;
int N;
string A[100000];
int B[100000];
int S[100000];
int H[100000];
bool cmp(int a, int b) { return S[a] / (double)H[a] > S[b] / (double)H[b]; }
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    B[i] = i;
    S[i] = 0;
    H[i] = 0;
    for (int j = 0; j < A[i].size(); j++)
      if (A[i][j] == 's')
        S[i]++;
      else
        H[i]++;
  }
  sort(B, B + N, cmp);
  long long res = 0;
  long long ss = 0;
  for (int i = 0; i < N; i++) {
    int idx = B[i];
    int temp = 0;
    for (int j = 0; j < A[idx].size(); j++) {
      if (A[idx][j] == 's')
        temp++;
      else
        res += temp;
    }
    res += ss * H[idx];
    ss += S[idx];
  }
  cout << res << endl;
}
