#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int x = (s[0] - '0') * 10 + s[1] - '0';
  int y = (s[3] - '0') * 10 + s[4] - '0';
  int cnt = 0, a = 0, b, c, d, e, m = y, n;
  for (int i = x; i <= 23; i++) {
    for (int j = y; j < 60; j++) {
      if (i < 10) {
        a = 0;
        b = i;
      } else if (i >= 10) {
        a = i / 10;
        b = i % 10;
      }
      if (j < 10) {
        c = 0;
        d = j;
      } else if (j >= 10) {
        c = j / 10;
        d = j % 10;
      }
      if (a == d && b == c) {
        cout << cnt << endl;
        return 0;
      }
      cnt++;
    }
    y = 0;
  }
  cout << 60 - m << endl;
  return 0;
}
