#include <bits/stdc++.h>
using namespace std;
void solve() {
  char hh[2], temp, mm[2];
  cin >> hh[0] >> hh[1] >> temp >> mm[0] >> mm[1];
  int a = (hh[0] - '0') * 10;
  a += (hh[1] - '0');
  int needed = (hh[1] - '0') * 10;
  needed += (hh[0] - '0');
  int b = (mm[0] - '0') * 10;
  b += (mm[1] - '0');
  int new_needed, ans = 0;
  if (a < 6 && needed >= b) {
    cout << needed - b;
  } else if (a > 9 && a < 16 && needed >= b) {
    cout << needed - b;
  } else if (a > 19 && needed >= b) {
    cout << needed - b;
  } else {
    ans += (60 - b);
    a++;
    if (a >= 6 && a <= 9) {
      while (a <= 9) {
        ans += 60;
        a++;
      }
    } else if (a >= 16 && a <= 19) {
      while (a <= 19) {
        ans += 60;
        a++;
      }
    }
    if (a == 24) {
      cout << 60 - b;
      return;
    }
    new_needed = (a % 10) * 10;
    new_needed += (a / 10);
    ans += new_needed;
    cout << ans;
  }
}
signed main() {
  int t;
  t = 1;
  while (t--) {
    solve();
  }
}
