#include <bits/stdc++.h>
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("unroll-loops")
using namespace std;
const int maxN = (int)1e3 + 100;
const int N = (int)1e6 + 100;
const int MOD = (int)1e9 + 7;
const int INF = INT_MAX;
const long long LL_INF = LLONG_MAX;
const double PI = acos(-1.0);
mt19937 gen(time(NULL));
bool u = false;
long long cnt = 0, ans = 0;
int read() {
  bool mn = false;
  int res = 0;
  char ch;
  for (ch = getchar(); ch < '0' && ch > '9'; ch = getchar()) {
    if (ch == '-') break;
  }
  if (ch == '-')
    mn = true;
  else
    res = ch - '0';
  for (ch = getchar(); ch >= '0' && ch <= '9'; ch = getchar()) {
    res = res * 10 + (ch - '0');
  }
  return (mn ? -res : res);
}
long long check(string str) {
  long long cnt, res;
  cnt = res = 0;
  for (int i = 0; i < (int)str.size(); ++i) {
    if (str[i] == 's') {
      ++cnt;
      continue;
    }
    res += cnt;
  }
  return res;
}
struct elem {
  string str;
};
int n;
vector<elem> s;
bool operator<(const elem& x, const elem& y) {
  return check(x.str + y.str) < check(y.str + x.str);
}
void solve(string str) { printf("%lld\n", check(str)); }
int main() {
  n = read();
  for (int i = 0; i < n; ++i) {
    elem S;
    cin >> S.str;
    s.push_back(S);
  }
  sort((s).begin(), (s).end());
  string ans;
  for (int i = n - 1; i >= 0; --i) {
    ans += s[i].str;
  }
  solve(ans);
  return 0;
}
