#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  vector<long long> dp(s.size() + 1);
  for (int i = 1; i <= s.size(); i++) {
    dp[i] = dp[i - 1];
    if ((s[i - 1] - '0') % 4 == 0) dp[i]++;
    if (i > 1 && ((s[i - 2] - '0') * 10 + (s[i - 1] - '0')) % 4 == 0)
      dp[i] += i - 1;
  }
  cout << dp[s.size()];
}
