#include <bits/stdc++.h>
using namespace std;
string s, s1;
int ans, h, hh, m, mm;
int main() {
  cin >> s;
  while (1) {
    h = s[0] - 48;
    hh = s[1] - 48;
    m = s[3] - 48;
    mm = s[4] - 48;
    if (h == mm && hh == m) {
      break;
    }
    mm++;
    if (mm == 10) {
      mm = 0;
      m++;
      if (m == 6) {
        m = 0;
        hh++;
        if (hh == 10) {
          hh = 0;
          h++;
        }
        if (hh == 4 && h == 2) {
          hh = 0;
          h = 0;
        }
      }
    }
    s[0] = h + 48;
    s[1] = hh + 48;
    s[3] = m + 48;
    s[4] = mm + 48;
    ans++;
  }
  cout << ans;
  return 0;
}
