#include <bits/stdc++.h>
using namespace std;

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

char G[105][105];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll h,w; cin>>h>>w;
  rep(i,h) rep(j,w) cin>>G[i][j];
  
  ll ans=0;
  rep(i,h){
    rep(j,w){
      if(G[i][j]=='.' && G[i][j+1]=='.') ans++;
      if(G[i][j]=='.' && G[i+1][j]=='.') ans++;
    }
  }
  cout<<ans<<endl;
}
// *********************************************************************************
// *                        MURTAZA MUSTAFA KHUMUSI                                *
// *                        NIT-DGP,CSE - 2019-2023                                *
// *********************************************************************************

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007;
#define loop(i, a, n) for (int i = a; i < n; i++)
#define loop1(i, b, n) for (int i = b; i <= n; i++)
#define loopit(a) for (auto it = a.begin(); it != a.end(); it++)
#define ms(a, b) memset(a, b, sizeof(a))
#define pb(a) push_back(a)
#define MP make_pair
#define pi pair<int, int>
#define ff first
#define ss second
#define bloop(i, a, b) for (int i = a; i > b; i--)
#define bloop1(i, a, b) for (int i = a; i >= b; i--)
#define PQ priority_queue<int> pq;
#define vi vector<int>
#define si set<int>
#define MPQ priority_queue<pi, vector<int>, greater<pi>> mpq;
#define io                        \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL);
const int maxm = 100001;
ll m = pow(1e9, 2);
vector<vi> adj;
vi h;
vi sz;
vi in;
//NOT FOR NEGATIVE NUMBERS
// void sc(int &number)
// {
//     register long long c;
//     number = 0;
//     c = getchar();
//     for (; (c>47 && c<58); c=getchar())
//         number = number *10 + c - 48;

// }

// void dis(vi &a)
// {
//     cout << "\n....Display starts...\n";
//     loop(i, 0, a.size())
//     {
//         cout << a[i] << " ";
//     }
//     cout << "\n....Display ends...\n";
// }

ll fe(ll base, ll exp)
{
    ll res = 1;
    while (exp > 0)
    {
        if (exp % 2 == 1)
            res = (res * base) % MOD;
        base = (base * base) % MOD;
        exp /= 2;
    }
    return res % MOD;
}

void dfs_h_sz(int cur, int par)
{
    h[cur] = h[par] + 1;
    sz[cur]++;
    for (const auto &v : adj[cur])
    {
        if (v == par)
            continue;
        dfs_h_sz(v, cur);
        sz[cur] += sz[v];
    }
}

void buildGraph(int n, int m)
{
    adj = vector<vi>(n + 1);
    h = vector<int>(n + 1);
    sz = vector<int>(n + 1);
    in = vector<int>(n + 1);

    loop(i, 0, m)
    {
        int a, b;
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    dfs_h_sz(1, 0);
}
struct cmp
{
    bool operator()(const pi &a, const pi &b)
    {
        return a.ff < b.ff;
    }
};
ll add(ll a, ll b)
{
    return ((a % m) + (b % m)) % m;
}
ll mul(ll a, ll b)
{
    return ((a % m) * (b % m)) % m;
}
ll sub(ll a, ll b)
{
    return ((a % m) - (b % m) + m) % m;
}
ll ipt(ll cur){
    ll k = cur;
    ll ret = 0;

    while (cur != 1)
    {
        if (cur % 3 == 0)
        {
            cur /= 3;
            ret++;
        }else
        {
            return -1;
        }
        
    }
    return (ret ? ret :-1);
}
void solve()
{
    ll n;
    cin >> n;
    ll ini = 5;
    int v1 = 1;

    while (ini < n)
    {
        ll cur = n - ini;
        ll ret = ipt(cur);
        if (ret!=-1)
        {
            cout<<ret<<" "<<v1<<"\n";
            return;
        }

        ini *= 5;
        v1++;
    }
    cout << -1 << "\n";
}
int main()
{
    io;

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int test;
    // cin >> test;
    test = 1;
    while (test--)
    {
        solve();
    }
    return 0;
}
