#include <fstream>
#include <string>
#include <sstream>

using namespace std;

ifstream input("STRD4.inp");
ofstream output("STRD4.out");

int main()
{
	int count = 0;
	string a;
	input >> a;
	for (int i = 0; i < a.size(); ++i)
	{
		a[i] -= '0';
		if (a[i] % 4 == 0)
		{
			count++;
		}
	}
	for (int i = 0; i < a.size() - 1; ++i)
	{
		int n = a[i] * 10 + a[i + 1];
		if (n % 4 == 0)
		{
			count += i + 1;
		}
	}
	output << count;
	input.close();
	output.close();
}